Skip to content

Commit 96de847

Browse files
Run more WTF tests
https://bugs.webkit.org/show_bug.cgi?id=174970 Reviewed by Michael Catanzaro. Source/WTF: CHAR_BIT is not defined. * wtf/LEBDecoder.h: Tools: Some of WTF tests are not executed in non Apple ports while they are generic ones. This patch adds these tests to non-Apple port TestWebKitAPI. Currently, we do not add Signals.cpp since it depends on signal functionality. * TestWebKitAPI/CMakeLists.txt: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WTF/PriorityQueue.cpp: (isHigherPriority): (TEST): * TestWebKitAPI/Tests/WTF/Signals.cpp: Copied from Tools/TestWebKitAPI/Tests/WTF/ThreadMessages.cpp. (TEST): * TestWebKitAPI/Tests/WTF/ThreadMessages.cpp: (TEST): git-svn-id: http://svn.webkit.org/repository/webkit/trunk@220562 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 167235e commit 96de847

File tree

8 files changed

+121
-51
lines changed

8 files changed

+121
-51
lines changed

Source/WTF/ChangeLog

+11
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
2017-08-10 Yusuke Suzuki <[email protected]>
2+
3+
Run more WTF tests
4+
https://bugs.webkit.org/show_bug.cgi?id=174970
5+
6+
Reviewed by Michael Catanzaro.
7+
8+
CHAR_BIT is not defined.
9+
10+
* wtf/LEBDecoder.h:
11+
112
2017-08-09 Yusuke Suzuki <[email protected]>
213

314
[WTF] ThreadSpecific should not introduce additional indirection

Source/WTF/wtf/LEBDecoder.h

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
#include "Compiler.h"
2929
#include <algorithm>
30+
#include <limits.h>
3031

3132
// This file contains a bunch of helper functions for decoding LEB numbers.
3233
// See https://en.wikipedia.org/wiki/LEB128 for more information about the

Tools/ChangeLog

+21
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
2017-08-10 Yusuke Suzuki <[email protected]>
2+
3+
Run more WTF tests
4+
https://bugs.webkit.org/show_bug.cgi?id=174970
5+
6+
Reviewed by Michael Catanzaro.
7+
8+
Some of WTF tests are not executed in non Apple ports while they are generic ones.
9+
This patch adds these tests to non-Apple port TestWebKitAPI.
10+
Currently, we do not add Signals.cpp since it depends on signal functionality.
11+
12+
* TestWebKitAPI/CMakeLists.txt:
13+
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
14+
* TestWebKitAPI/Tests/WTF/PriorityQueue.cpp:
15+
(isHigherPriority):
16+
(TEST):
17+
* TestWebKitAPI/Tests/WTF/Signals.cpp: Copied from Tools/TestWebKitAPI/Tests/WTF/ThreadMessages.cpp.
18+
(TEST):
19+
* TestWebKitAPI/Tests/WTF/ThreadMessages.cpp:
20+
(TEST):
21+
122
2017-08-10 obinna obike <[email protected]>
223

324
Remove obsolete link from webkit-queues status page

Tools/TestWebKitAPI/CMakeLists.txt

+6-1
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ set(TestWTF_SOURCES
4242
${TESTWEBKITAPI_DIR}/TestsController.cpp
4343
${TESTWEBKITAPI_DIR}/Tests/WTF/AtomicString.cpp
4444
${TESTWEBKITAPI_DIR}/Tests/WTF/BloomFilter.cpp
45-
${TESTWEBKITAPI_DIR}/Tests/WTF/CrossThreadTask.cpp
4645
${TESTWEBKITAPI_DIR}/Tests/WTF/CString.cpp
4746
${TESTWEBKITAPI_DIR}/Tests/WTF/CheckedArithmeticOperations.cpp
4847
${TESTWEBKITAPI_DIR}/Tests/WTF/Condition.cpp
48+
${TESTWEBKITAPI_DIR}/Tests/WTF/CrossThreadTask.cpp
4949
${TESTWEBKITAPI_DIR}/Tests/WTF/DateMath.cpp
5050
${TESTWEBKITAPI_DIR}/Tests/WTF/Deque.cpp
5151
${TESTWEBKITAPI_DIR}/Tests/WTF/EnumTraits.cpp
@@ -55,6 +55,7 @@ set(TestWTF_SOURCES
5555
${TESTWEBKITAPI_DIR}/Tests/WTF/HashMap.cpp
5656
${TESTWEBKITAPI_DIR}/Tests/WTF/HashSet.cpp
5757
${TESTWEBKITAPI_DIR}/Tests/WTF/IntegerToStringConversion.cpp
58+
${TESTWEBKITAPI_DIR}/Tests/WTF/LEBDecoder.cpp
5859
${TESTWEBKITAPI_DIR}/Tests/WTF/LifecycleLogger.cpp
5960
${TESTWEBKITAPI_DIR}/Tests/WTF/ListHashSet.cpp
6061
${TESTWEBKITAPI_DIR}/Tests/WTF/Lock.cpp
@@ -68,6 +69,7 @@ set(TestWTF_SOURCES
6869
${TESTWEBKITAPI_DIR}/Tests/WTF/Optional.cpp
6970
${TESTWEBKITAPI_DIR}/Tests/WTF/OptionSet.cpp
7071
${TESTWEBKITAPI_DIR}/Tests/WTF/ParkingLot.cpp
72+
${TESTWEBKITAPI_DIR}/Tests/WTF/PriorityQueue.cpp
7173
${TESTWEBKITAPI_DIR}/Tests/WTF/RedBlackTree.cpp
7274
${TESTWEBKITAPI_DIR}/Tests/WTF/Ref.cpp
7375
${TESTWEBKITAPI_DIR}/Tests/WTF/RefCounter.cpp
@@ -79,12 +81,15 @@ set(TestWTF_SOURCES
7981
${TESTWEBKITAPI_DIR}/Tests/WTF/ScopedLambda.cpp
8082
${TESTWEBKITAPI_DIR}/Tests/WTF/SetForScope.cpp
8183
${TESTWEBKITAPI_DIR}/Tests/WTF/StringBuilder.cpp
84+
${TESTWEBKITAPI_DIR}/Tests/WTF/StringConcatenate.cpp
8285
${TESTWEBKITAPI_DIR}/Tests/WTF/StringHasher.cpp
8386
${TESTWEBKITAPI_DIR}/Tests/WTF/StringImpl.cpp
8487
${TESTWEBKITAPI_DIR}/Tests/WTF/StringOperators.cpp
8588
${TESTWEBKITAPI_DIR}/Tests/WTF/StringView.cpp
89+
${TESTWEBKITAPI_DIR}/Tests/WTF/SynchronizedFixedQueue.cpp
8690
${TESTWEBKITAPI_DIR}/Tests/WTF/TextBreakIterator.cpp
8791
${TESTWEBKITAPI_DIR}/Tests/WTF/ThreadGroup.cpp
92+
${TESTWEBKITAPI_DIR}/Tests/WTF/ThreadMessages.cpp
8893
${TESTWEBKITAPI_DIR}/Tests/WTF/Time.cpp
8994
${TESTWEBKITAPI_DIR}/Tests/WTF/UniqueRef.cpp
9095
${TESTWEBKITAPI_DIR}/Tests/WTF/Variant.cpp

Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj

+5-1
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,7 @@
645645
D34E08761E4E42E1005FF14A /* WKWebViewGetContents.mm in Sources */ = {isa = PBXBuildFile; fileRef = D3BE5E341E4CE85E00FD563A /* WKWebViewGetContents.mm */; };
646646
E1220DCA155B28AA0013E2FC /* MemoryCacheDisableWithinResourceLoadDelegate.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = E1220DC9155B287D0013E2FC /* MemoryCacheDisableWithinResourceLoadDelegate.html */; };
647647
E194E1BD177E53C7009C4D4E /* StopLoadingFromDidReceiveResponse.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = E194E1BC177E534A009C4D4E /* StopLoadingFromDidReceiveResponse.html */; };
648+
E373D7911F2CF35200C6FAAF /* Signals.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E3953F951F2CF32100A76A2E /* Signals.cpp */; };
648649
E3DEA8111F0A589000CBC2E8 /* ThreadGroup.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E3DEA8101F0A588000CBC2E8 /* ThreadGroup.cpp */; };
649650
ECA680CE1E68CC0900731D20 /* StringUtilities.mm in Sources */ = {isa = PBXBuildFile; fileRef = ECA680CD1E68CC0900731D20 /* StringUtilities.mm */; };
650651
F407FE391F1D0DFC0017CF25 /* enormous.svg in Copy Resources */ = {isa = PBXBuildFile; fileRef = F407FE381F1D0DE60017CF25 /* enormous.svg */; };
@@ -1652,6 +1653,7 @@
16521653
E194E1BA177E5145009C4D4E /* StopLoadingFromDidReceiveResponse.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = StopLoadingFromDidReceiveResponse.mm; sourceTree = "<group>"; };
16531654
E194E1BC177E534A009C4D4E /* StopLoadingFromDidReceiveResponse.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = StopLoadingFromDidReceiveResponse.html; sourceTree = "<group>"; };
16541655
E19DB9781B32137C00DB38D4 /* NavigatorLanguage.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = NavigatorLanguage.mm; sourceTree = "<group>"; };
1656+
E3953F951F2CF32100A76A2E /* Signals.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Signals.cpp; sourceTree = "<group>"; };
16551657
E3DEA8101F0A588000CBC2E8 /* ThreadGroup.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ThreadGroup.cpp; sourceTree = "<group>"; };
16561658
E40019301ACE9B5C001B0A2A /* BloomFilter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BloomFilter.cpp; sourceTree = "<group>"; };
16571659
E490296714E2E3A4002BEDD1 /* TypingStyleCrash.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TypingStyleCrash.mm; sourceTree = "<group>"; };
@@ -2448,6 +2450,7 @@
24482450
DC69AA621CF77C6500C6272F /* ScopedLambda.cpp */,
24492451
0BCD85691485C98B00EA2003 /* SetForScope.cpp */,
24502452
CD5393C91757BAC400C07123 /* SHA1.cpp */,
2453+
E3953F951F2CF32100A76A2E /* Signals.cpp */,
24512454
81B50192140F232300D9EB58 /* StringBuilder.cpp */,
24522455
7CD4C26C1E2C0E6E00929470 /* StringConcatenate.cpp */,
24532456
93ABA80816DDAB91002DB2FA /* StringHasher.cpp */,
@@ -3000,6 +3003,7 @@
30003003
7C83DF121D0A590C00FEBCF3 /* ScopedLambda.cpp in Sources */,
30013004
7C83DF3D1D0A590C00FEBCF3 /* SetForScope.cpp in Sources */,
30023005
7C83DF2A1D0A590C00FEBCF3 /* SHA1.cpp in Sources */,
3006+
E373D7911F2CF35200C6FAAF /* Signals.cpp in Sources */,
30033007
7C83DF321D0A590C00FEBCF3 /* StringBuilder.cpp in Sources */,
30043008
7CD4C26E1E2C0E6E00929470 /* StringConcatenate.cpp in Sources */,
30053009
7C83DF361D0A590C00FEBCF3 /* StringHasher.cpp in Sources */,
@@ -3069,6 +3073,7 @@
30693073
8349D3C21DB96DDE004A9F65 /* ContextMenuDownload.mm in Sources */,
30703074
5C2936931D5BF70D00DEAB1E /* CookieAcceptPolicy.mm in Sources */,
30713075
51D1249B1E785425002B2820 /* CookieManager.cpp in Sources */,
3076+
9999108B1F393C96008AD455 /* Copying.mm in Sources */,
30723077
7CCE7EAC1A411A3400447C4C /* Counters.cpp in Sources */,
30733078
7AEAD47F1E20116C00416EFE /* CrossPartitionFileSchemeAccess.mm in Sources */,
30743079
7CCE7EDB1A411A9200447C4C /* CSSParser.cpp in Sources */,
@@ -3318,7 +3323,6 @@
33183323
51DB16CE1F085137001FA4C5 /* WebViewIconLoading.mm in Sources */,
33193324
7CCE7F1B1A411AE600447C4C /* WillLoad.cpp in Sources */,
33203325
7CCE7ED71A411A7E00447C4C /* WillPerformClientRedirectToURLCrash.mm in Sources */,
3321-
9999108B1F393C96008AD455 /* Copying.mm in Sources */,
33223326
7CCE7F1C1A411AE600447C4C /* WillSendSubmitEvent.cpp in Sources */,
33233327
7CCE7ED81A411A7E00447C4C /* WillSendSubmitEvent.mm in Sources */,
33243328
7CCE7ED91A411A7E00447C4C /* WindowlessWebViewWithMedia.mm in Sources */,

Tools/TestWebKitAPI/Tests/WTF/PriorityQueue.cpp

+10-9
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,16 @@ TEST(WTF_PriorityQueue, CustomPriorityFunction)
9797
}
9898

9999
template<bool (*isHigherPriority)(const unsigned&, const unsigned&)>
100-
static bool compareMove(const MoveOnly& m1, const MoveOnly& m2)
101-
{
102-
return isHigherPriority(m1.value(), m2.value());
103-
}
104-
100+
struct CompareMove {
101+
static bool compare(const MoveOnly& m1, const MoveOnly& m2)
102+
{
103+
return isHigherPriority(m1.value(), m2.value());
104+
}
105+
};
105106

106107
TEST(WTF_PriorityQueue, MoveOnly)
107108
{
108-
PriorityQueue<MoveOnly, compareMove<isLessThan<unsigned>>> queue;
109+
PriorityQueue<MoveOnly, CompareMove<isLessThan<unsigned>>::compare> queue;
109110

110111
Vector<unsigned> values = { 23, 54, 4, 8, 1, 2, 4, 0 };
111112
Vector<unsigned> sorted = values;
@@ -122,7 +123,7 @@ TEST(WTF_PriorityQueue, MoveOnly)
122123

123124
TEST(WTF_PriorityQueue, DecreaseKey)
124125
{
125-
PriorityQueue<MoveOnly, compareMove<isLessThan<unsigned>>> queue;
126+
PriorityQueue<MoveOnly, CompareMove<isLessThan<unsigned>>::compare> queue;
126127

127128
Vector<unsigned> values = { 23, 54, 4, 8, 1, 2, 4, 0 };
128129
Vector<unsigned> sorted = values;
@@ -148,7 +149,7 @@ TEST(WTF_PriorityQueue, DecreaseKey)
148149

149150
TEST(WTF_PriorityQueue, IncreaseKey)
150151
{
151-
PriorityQueue<MoveOnly, compareMove<isGreaterThan<unsigned>>> queue;
152+
PriorityQueue<MoveOnly, CompareMove<isGreaterThan<unsigned>>::compare> queue;
152153

153154
Vector<unsigned> values = { 23, 54, 4, 8, 1, 2, 4, 0 };
154155
Vector<unsigned> sorted = values;
@@ -174,7 +175,7 @@ TEST(WTF_PriorityQueue, IncreaseKey)
174175

175176
TEST(WTF_PriorityQueue, Iteration)
176177
{
177-
PriorityQueue<MoveOnly, compareMove<isGreaterThan<unsigned>>> queue;
178+
PriorityQueue<MoveOnly, CompareMove<isGreaterThan<unsigned>>::compare> queue;
178179

179180
Vector<unsigned> values = { 23, 54, 4, 8, 1, 2, 4, 0 };
180181
Vector<unsigned> sorted = values;
+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
* Copyright (C) 2017 Apple Inc. All rights reserved.
3+
*
4+
* Redistribution and use in source and binary forms, with or without
5+
* modification, are permitted provided that the following conditions
6+
* are met:
7+
* 1. Redistributions of source code must retain the above copyright
8+
* notice, this list of conditions and the following disclaimer.
9+
* 2. Redistributions in binary form must reproduce the above copyright
10+
* notice, this list of conditions and the following disclaimer in the
11+
* documentation and/or other materials provided with the distribution.
12+
*
13+
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15+
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17+
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23+
* THE POSSIBILITY OF SUCH DAMAGE.
24+
*/
25+
26+
#include "config.h"
27+
28+
#include <type_traits>
29+
#include <wtf/DataLog.h>
30+
#include <wtf/Threading.h>
31+
#include <wtf/threads/Signals.h>
32+
33+
class ReflectedThread : public Thread {
34+
public:
35+
using Thread::m_mutex;
36+
using Thread::m_handle;
37+
using Thread::hasExited;
38+
};
39+
40+
TEST(Signals, SignalsWorkOnExit)
41+
{
42+
static bool handlerRan = false;
43+
installSignalHandler(Signal::Usr, [] (Signal, SigInfo&, PlatformRegisters&) -> SignalAction {
44+
dataLogLn("here");
45+
handlerRan = true;
46+
return SignalAction::Handled;
47+
});
48+
49+
Atomic<bool> receiverShouldKeepRunning(true);
50+
RefPtr<Thread> receiverThread = (Thread::create("ThreadMessage receiver",
51+
[&receiverShouldKeepRunning] () {
52+
while (receiverShouldKeepRunning.load()) { }
53+
}));
54+
ASSERT_TRUE(receiverThread);
55+
56+
bool signalFired;
57+
{
58+
std::unique_lock<std::mutex> locker(static_cast<ReflectedThread*>(receiverThread.get())->m_mutex);
59+
receiverShouldKeepRunning.store(false);
60+
EXPECT_FALSE(static_cast<ReflectedThread*>(receiverThread.get())->hasExited());
61+
sleep(1);
62+
signalFired = !pthread_kill(static_cast<ReflectedThread*>(receiverThread.get())->m_handle, std::get<0>(toSystemSignal(Signal::Usr)));
63+
}
64+
65+
receiverThread->waitForCompletion();
66+
EXPECT_TRUE(handlerRan || !signalFired);
67+
}

Tools/TestWebKitAPI/Tests/WTF/ThreadMessages.cpp

-40
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,10 @@
2525

2626
#include "config.h"
2727

28-
#include <type_traits>
29-
#include <wtf/DataLog.h>
3028
#include <wtf/HashSet.h>
3129
#include <wtf/Ref.h>
3230
#include <wtf/ThreadMessage.h>
3331
#include <wtf/Vector.h>
34-
#include <wtf/threads/Signals.h>
3532

3633
static void runThreadMessageTest(unsigned numSenders, unsigned numMessages)
3734
{
@@ -84,40 +81,3 @@ TEST(ThreadMessage, MultipleSenders)
8481
runThreadMessageTest(10, 100);
8582
runThreadMessageTest(10, 10000);
8683
}
87-
88-
class ReflectedThread : public Thread {
89-
public:
90-
using Thread::m_mutex;
91-
using Thread::m_handle;
92-
using Thread::hasExited;
93-
};
94-
95-
TEST(ThreadMessage, SignalsWorkOnExit)
96-
{
97-
static bool handlerRan = false;
98-
installSignalHandler(Signal::Usr, [] (Signal, SigInfo&, PlatformRegisters&) -> SignalAction {
99-
dataLogLn("here");
100-
handlerRan = true;
101-
return SignalAction::Handled;
102-
});
103-
104-
Atomic<bool> receiverShouldKeepRunning(true);
105-
RefPtr<Thread> receiverThread = (Thread::create("ThreadMessage receiver",
106-
[&receiverShouldKeepRunning] () {
107-
while (receiverShouldKeepRunning.load()) { }
108-
}));
109-
ASSERT_TRUE(receiverThread);
110-
111-
bool signalFired;
112-
{
113-
std::unique_lock<std::mutex> locker(static_cast<ReflectedThread*>(receiverThread.get())->m_mutex);
114-
receiverShouldKeepRunning.store(false);
115-
EXPECT_FALSE(static_cast<ReflectedThread*>(receiverThread.get())->hasExited());
116-
sleep(1);
117-
signalFired = !pthread_kill(static_cast<ReflectedThread*>(receiverThread.get())->m_handle, std::get<0>(toSystemSignal(Signal::Usr)));
118-
}
119-
120-
receiverThread->waitForCompletion();
121-
EXPECT_TRUE(handlerRan || !signalFired);
122-
}
123-

0 commit comments

Comments
 (0)