blob: 2900f0eddb14ebb85dcc09f04ac2451ddbce90d0 [file] [log] [blame]
andrew@webrtc.org19eefdc2011-09-14 17:02:44 +00001/*
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
andrew@webrtc.orgb87cc852013-03-25 16:23:37 +000011#include "webrtc/test/test_suite.h"
andrew@webrtc.orgc1ffd332013-03-22 17:13:23 +000012
andrew@webrtc.orgaa3d1c82013-09-05 21:16:29 +000013#include "gflags/gflags.h"
andrew@webrtc.orgc1ffd332013-03-22 17:13:23 +000014#include "testing/gmock/include/gmock/gmock.h"
15#include "testing/gtest/include/gtest/gtest.h"
andrew88703d72015-09-07 00:34:56 -070016#include "webrtc/base/logging.h"
andrew@webrtc.orgb87cc852013-03-25 16:23:37 +000017#include "webrtc/test/testsupport/fileutils.h"
18#include "webrtc/test/testsupport/trace_to_stderr.h"
andresp@webrtc.org60015d22014-05-16 09:39:51 +000019#include "webrtc/test/field_trial.h"
andrew@webrtc.org19eefdc2011-09-14 17:02:44 +000020
andrew@webrtc.orgaa3d1c82013-09-05 21:16:29 +000021DEFINE_bool(logs, false, "print logs to stderr");
22
andresp@webrtc.org60015d22014-05-16 09:39:51 +000023DEFINE_string(force_fieldtrials, "",
24 "Field trials control experimental feature code which can be forced. "
25 "E.g. running with --force_fieldtrials=WebRTC-FooFeature/Enable/"
26 " will assign the group Enable to field trial WebRTC-FooFeature.");
27
andrew@webrtc.org19eefdc2011-09-14 17:02:44 +000028namespace webrtc {
kjellander@webrtc.org20a370e2011-11-04 01:19:16 +000029namespace test {
kjellander@webrtc.org83b767b2012-10-15 18:14:12 +000030
andrew@webrtc.org31628aa2013-10-22 12:50:00 +000031TestSuite::TestSuite(int argc, char** argv) {
kjellander@webrtc.org193600b2012-10-17 04:39:44 +000032 SetExecutablePath(argv[0]);
kjellander@webrtc.org20a370e2011-11-04 01:19:16 +000033 testing::InitGoogleMock(&argc, argv); // Runs InitGoogleTest() internally.
andrew@webrtc.org15e979b2013-09-17 00:54:09 +000034 // AllowCommandLineParsing allows us to ignore flags passed on to us by
35 // Chromium build bots without having to explicitly disable them.
36 google::AllowCommandLineReparsing();
andrew@webrtc.orgaa3d1c82013-09-05 21:16:29 +000037 google::ParseCommandLineFlags(&argc, &argv, true);
andresp@webrtc.org60015d22014-05-16 09:39:51 +000038
39 webrtc::test::InitFieldTrialsFromString(FLAGS_force_fieldtrials);
andrew@webrtc.org19eefdc2011-09-14 17:02:44 +000040}
41
42TestSuite::~TestSuite() {
43}
44
45int TestSuite::Run() {
46 Initialize();
47 int result = RUN_ALL_TESTS();
48 Shutdown();
49 return result;
50}
51
52void TestSuite::Initialize() {
andrew88703d72015-09-07 00:34:56 -070053 rtc::LogMessage::SetLogToStderr(FLAGS_logs);
andrew@webrtc.orgaa3d1c82013-09-05 21:16:29 +000054 if (FLAGS_logs)
55 trace_to_stderr_.reset(new TraceToStderr);
andrew@webrtc.org19eefdc2011-09-14 17:02:44 +000056}
57
58void TestSuite::Shutdown() {
59}
andrew@webrtc.orgc1ffd332013-03-22 17:13:23 +000060
kjellander@webrtc.org20a370e2011-11-04 01:19:16 +000061} // namespace test
andrew@webrtc.org19eefdc2011-09-14 17:02:44 +000062} // namespace webrtc