[go: nahoru, domu]

blob: f2a54d51686f0b181b6c429c342e55ea666c7fa4 [file] [log] [blame]
eroman02b4fe562016-03-04 12:15:161// Copyright 2016 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "base/at_exit.h"
Matt Menkeb931f4c2017-07-27 23:32:286#include "base/command_line.h"
eroman02b4fe562016-03-04 12:15:167#include "base/i18n/icu_util.h"
mmenke9937d6d62016-04-22 21:59:348#include "base/logging.h"
Francois Dorayd2162d42017-07-25 17:51:489#include "base/test/scoped_task_environment.h"
eroman02b4fe562016-03-04 12:15:1610
11namespace {
12
mmenke9937d6d62016-04-22 21:59:3413// Set up globals that a number of network tests use.
eroman02b4fe562016-03-04 12:15:1614//
15// Note that in general static initializers are not allowed, however this is
16// just being used by test code.
mmenke9937d6d62016-04-22 21:59:3417struct InitGlobals {
Francois Dorayd2162d42017-07-25 17:51:4818 InitGlobals()
19 : scoped_task_environment(
20 base::test::ScopedTaskEnvironment::MainThreadType::IO) {
Matt Menkeb931f4c2017-07-27 23:32:2821 base::CommandLine::Init(0, nullptr);
22
mmenke9937d6d62016-04-22 21:59:3423 // Set up ICU. ICU is used internally by GURL, which is used throughout the
24 // //net code. Initializing ICU is important to prevent fuzztests from
25 // asserting when handling non-ASCII urls.
26 CHECK(base::i18n::InitializeICU());
mmenke0960f752016-05-02 20:08:3427
mmoroza2a767102017-01-23 18:45:3928 // Disable noisy logging as per "libFuzzer in Chrome" documentation:
29 // testing/libfuzzer/getting_started.md#Disable-noisy-error-message-logging.
30 logging::SetMinLogLevel(logging::LOG_FATAL);
mmenke9937d6d62016-04-22 21:59:3431 }
32
Francois Dorayd2162d42017-07-25 17:51:4833 // A number of tests use async code which depends on there being a
34 // ScopedTaskEnvironment. Setting one up here allows tests to reuse the
35 // ScopedTaskEnvironment between runs.
36 base::test::ScopedTaskEnvironment scoped_task_environment;
mmenke9937d6d62016-04-22 21:59:3437
eroman02b4fe562016-03-04 12:15:1638 base::AtExitManager at_exit_manager;
39};
40
mmenke9937d6d62016-04-22 21:59:3441InitGlobals* init_globals = new InitGlobals();
eroman02b4fe562016-03-04 12:15:1642
43} // namespace