andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 1 | /* |
| 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.org | 8826e34 | 2013-03-25 16:23:37 +0000 | [diff] [blame] | 11 | #include "webrtc/test/test_suite.h" |
andrew@webrtc.org | 4c27c03 | 2013-03-22 17:13:23 +0000 | [diff] [blame] | 12 | |
andrew@webrtc.org | e41c6b2 | 2013-09-05 21:16:29 +0000 | [diff] [blame] | 13 | #include "gflags/gflags.h" |
andrew@webrtc.org | 4c27c03 | 2013-03-22 17:13:23 +0000 | [diff] [blame] | 14 | #include "testing/gmock/include/gmock/gmock.h" |
| 15 | #include "testing/gtest/include/gtest/gtest.h" |
andrew@webrtc.org | 8826e34 | 2013-03-25 16:23:37 +0000 | [diff] [blame] | 16 | #include "webrtc/test/testsupport/fileutils.h" |
| 17 | #include "webrtc/test/testsupport/trace_to_stderr.h" |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 18 | |
andrew@webrtc.org | e41c6b2 | 2013-09-05 21:16:29 +0000 | [diff] [blame] | 19 | DEFINE_bool(logs, false, "print logs to stderr"); |
| 20 | |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 21 | namespace webrtc { |
| 22 | namespace test { |
| 23 | |
andrew@webrtc.org | 221798a | 2013-10-22 12:50:00 +0000 | [diff] [blame] | 24 | TestSuite::TestSuite(int argc, char** argv) { |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 25 | SetExecutablePath(argv[0]); |
| 26 | testing::InitGoogleMock(&argc, argv); // Runs InitGoogleTest() internally. |
andrew@webrtc.org | b0fb1d6 | 2013-09-17 00:54:09 +0000 | [diff] [blame] | 27 | // AllowCommandLineParsing allows us to ignore flags passed on to us by |
| 28 | // Chromium build bots without having to explicitly disable them. |
| 29 | google::AllowCommandLineReparsing(); |
andrew@webrtc.org | e41c6b2 | 2013-09-05 21:16:29 +0000 | [diff] [blame] | 30 | google::ParseCommandLineFlags(&argc, &argv, true); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 31 | } |
| 32 | |
| 33 | TestSuite::~TestSuite() { |
| 34 | } |
| 35 | |
| 36 | int TestSuite::Run() { |
| 37 | Initialize(); |
| 38 | int result = RUN_ALL_TESTS(); |
| 39 | Shutdown(); |
| 40 | return result; |
| 41 | } |
| 42 | |
| 43 | void TestSuite::Initialize() { |
andrew@webrtc.org | e41c6b2 | 2013-09-05 21:16:29 +0000 | [diff] [blame] | 44 | if (FLAGS_logs) |
| 45 | trace_to_stderr_.reset(new TraceToStderr); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 46 | } |
| 47 | |
| 48 | void TestSuite::Shutdown() { |
| 49 | } |
andrew@webrtc.org | 4c27c03 | 2013-03-22 17:13:23 +0000 | [diff] [blame] | 50 | |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 51 | } // namespace test |
| 52 | } // namespace webrtc |