Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(80)

Side by Side Diff: third_party/WebKit/Source/platform/testing/RunAllTests.cpp

Issue 2199493002: libFuzzer for blink::MHTMLParser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Don't call base::i18n::InitializeICU during setup of regular unit tests. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 10 matching lines...) Expand all
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "base/memory/discardable_memory_allocator.h" 31 #include "base/bind.h"
32 #include "base/test/test_discardable_memory_allocator.h" 32 #include "base/test/launcher/unit_test_launcher.h"
33 #include "base/test/test_io_thread.h" 33 #include "base/test/test_io_thread.h"
34 #include "base/test/test_suite.h"
34 #include "mojo/edk/embedder/embedder.h" 35 #include "mojo/edk/embedder/embedder.h"
35 #include "mojo/edk/test/scoped_ipc_support.h" 36 #include "mojo/edk/test/scoped_ipc_support.h"
36 #include "platform/EventTracer.h"
37 #include "platform/HTTPNames.h"
38 #include "platform/heap/Heap.h" 37 #include "platform/heap/Heap.h"
39 #include "platform/testing/TestingPlatformSupport.h" 38 #include "platform/testing/TestingPlatformSupport.h"
40 #include "public/platform/Platform.h"
41 #include "wtf/CryptographicallyRandomNumber.h"
42 #include "wtf/CurrentTime.h"
43 #include "wtf/PtrUtil.h"
44 #include "wtf/WTF.h"
45 #include "wtf/allocator/Partitions.h"
46 #include <base/bind.h>
47 #include <base/bind_helpers.h>
48 #include <base/command_line.h>
49 #include <base/metrics/statistics_recorder.h>
50 #include <base/test/launcher/unit_test_launcher.h>
51 #include <base/test/test_suite.h>
52 #include <cc/blink/web_compositor_support_impl.h>
53 #include <memory> 39 #include <memory>
54 40
55 namespace { 41 namespace {
56 42
57 double dummyCurrentTime()
58 {
59 return 0.0;
60 }
61
62 int runTestSuite(base::TestSuite* testSuite) 43 int runTestSuite(base::TestSuite* testSuite)
63 { 44 {
64 int result = testSuite->Run(); 45 int result = testSuite->Run();
65 blink::ThreadHeap::collectAllGarbage(); 46 blink::ThreadHeap::collectAllGarbage();
66 return result; 47 return result;
67 } 48 }
68 49
69 class DummyPlatform final : public blink::Platform {
70 public:
71 DummyPlatform() { }
72 };
73
74 } // namespace 50 } // namespace
75 51
76 int main(int argc, char** argv) 52 int main(int argc, char** argv)
77 { 53 {
78 base::CommandLine::Init(argc, argv); 54 blink::ScopedUnittestsEnvironmentSetup testEnvironmentSetup(
79 55 argc, argv, blink::ScopedUnittestsEnvironmentSetup::TestType::UnitTests) ;
80 base::TestDiscardableMemoryAllocator discardableMemoryAllocator;
81 base::DiscardableMemoryAllocator::SetInstance(&discardableMemoryAllocator);
82
83 base::StatisticsRecorder::Initialize();
84
85 std::unique_ptr<DummyPlatform> platform = wrapUnique(new DummyPlatform);
86 blink::Platform::setCurrentPlatformForTesting(platform.get());
87
88 WTF::Partitions::initialize(nullptr);
89 WTF::setTimeFunctionsForTesting(dummyCurrentTime);
90 WTF::initialize(nullptr);
91 int result = 0; 56 int result = 0;
92 { 57 {
93 blink::TestingPlatformSupport::Config platformConfig;
94 cc_blink::WebCompositorSupportImpl compositorSupport;
95 platformConfig.compositorSupport = &compositorSupport;
96 blink::TestingPlatformSupport platform(platformConfig);
97
98 blink::ProcessHeap::init();
99 blink::ThreadState::attachMainThread();
100 blink::ThreadState::current()->registerTraceDOMWrappers(nullptr, nullptr , nullptr);
101 blink::EventTracer::initialize();
102 blink::HTTPNames::init();
103
104 base::TestSuite testSuite(argc, argv); 58 base::TestSuite testSuite(argc, argv);
105 59
106 mojo::edk::Init(); 60 mojo::edk::Init();
107 base::TestIOThread testIoThread(base::TestIOThread::kAutoStart); 61 base::TestIOThread testIoThread(base::TestIOThread::kAutoStart);
108 std::unique_ptr<mojo::edk::test::ScopedIPCSupport> ipcSupport(wrapUnique (new mojo::edk::test::ScopedIPCSupport(testIoThread.task_runner()))); 62 std::unique_ptr<mojo::edk::test::ScopedIPCSupport> ipcSupport(wrapUnique (new mojo::edk::test::ScopedIPCSupport(testIoThread.task_runner())));
109 result = base::LaunchUnitTests(argc, argv, base::Bind(runTestSuite, base ::Unretained(&testSuite))); 63 result = base::LaunchUnitTests(argc, argv, base::Bind(runTestSuite, base ::Unretained(&testSuite)));
110
111 blink::ThreadState::detachMainThread();
112 blink::ProcessHeap::shutdown();
113 } 64 }
114 WTF::shutdown();
115 WTF::Partitions::shutdown();
116 return result; 65 return result;
117 } 66 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698