193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)/*
293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * Copyright (C) 2013 Google Inc. All rights reserved.
393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) *
493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * Redistribution and use in source and binary forms, with or without
593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * modification, are permitted provided that the following conditions are
693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * met:
793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) *
893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) *     * Redistributions of source code must retain the above copyright
993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * notice, this list of conditions and the following disclaimer.
1093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) *     * Redistributions in binary form must reproduce the above
1193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * copyright notice, this list of conditions and the following disclaimer
1293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * in the documentation and/or other materials provided with the
1393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * distribution.
1493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) *     * Neither the name of Google Inc. nor the names of its
1593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * contributors may be used to endorse or promote products derived from
1693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * this software without specific prior written permission.
1793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) *
1893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
2093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
2193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) */
3093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
3193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)#include "config.h"
3293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
33323480423219ecd77329f8326dc5e0e3b50926d4Torne (Richard Coles)#include "platform/EventTracer.h"
34a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch#include "platform/Partitions.h"
3507a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch#include "platform/TestingPlatformSupport.h"
366f543c786fc42989f552b4daa774ca5ff32fa697Ben Murdoch#include "platform/heap/Heap.h"
3707a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch#include "wtf/CryptographicallyRandomNumber.h"
3807a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch#include "wtf/MainThread.h"
3907a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch#include "wtf/WTF.h"
4007a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch#include <base/test/test_suite.h>
4107a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch#include <string.h>
4293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
4307a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdochstatic double CurrentTime()
4407a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch{
4507a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch    return 0.0;
4607a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch}
4793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
4807a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdochstatic void AlwaysZeroNumberSource(unsigned char* buf, size_t len)
49591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch{
5007a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch    memset(buf, '\0', len);
51591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch}
52591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch
5307a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdochint main(int argc, char** argv)
5407a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch{
5507a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch    WTF::setRandomSource(AlwaysZeroNumberSource);
5607a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch    WTF::initialize(CurrentTime, 0);
5707a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch    WTF::initializeMainThread(0);
5807a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch
59c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)    blink::TestingPlatformSupport::Config platformConfig;
60c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)    blink::TestingPlatformSupport platform(platformConfig);
6107a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch
62c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)    blink::Heap::init();
63c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)    blink::ThreadState::attachMainThread();
64c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)    blink::Partitions::init();
65c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)    blink::EventTracer::initialize();
66a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch    int result = base::RunUnitTestsUsingBaseTestSuite(argc, argv);
67c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)    blink::Partitions::shutdown();
68c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)    blink::ThreadState::detachMainThread();
69c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)    blink::Heap::shutdown();
70a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch    return result;
7107a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch}
72