1 : // Copyright 2015 Google Inc. All Rights Reserved.
2 : //
3 : // Licensed under the Apache License, Version 2.0 (the "License");
4 : // you may not use this file except in compliance with the License.
5 : // You may obtain a copy of the License at
6 : //
7 : // http://www.apache.org/licenses/LICENSE-2.0
8 : //
9 : // Unless required by applicable law or agreed to in writing, software
10 : // distributed under the License is distributed on an "AS IS" BASIS,
11 : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 : // See the License for the specific language governing permissions and
13 : // limitations under the License.
14 : //
15 : // Test launcher that runs all the tests in a test suite with a large timeout.
16 : //
17 : // By default the unittests run with a timeout of 45 seconds, it's not enough
18 : // for some more intensive tests (like the integration tests). This code is
19 : // pretty much a copy-paste of base/test/run_all_unittests.cc, it just add an
20 : // argument line to the process command line to increase the timeout of the
21 : // unittests.
22 :
23 : #include "base/at_exit.h"
24 : #include "base/bind.h"
25 : #include "base/command_line.h"
26 : #include "base/test/test_suite.h"
27 : #include "base/test/test_switches.h"
28 : #include "base/test/launcher/unit_test_launcher.h"
29 :
30 : namespace {
31 :
32 : class NoAtExitBaseTestSuite : public base::TestSuite {
33 : public:
34 E : NoAtExitBaseTestSuite(int argc, char** argv)
35 : : base::TestSuite(argc, argv, false) {
36 E : }
37 : };
38 :
39 E : int RunTestSuite(int argc, char** argv) {
40 E : return NoAtExitBaseTestSuite(argc, argv).Run();
41 E : }
42 :
43 : } // namespace
44 :
45 E : int main(int argc, char** argv) {
46 E : base::AtExitManager at_exit;
47 E : CommandLine::Init(argc, argv);
48 : // We can't use the value from test_timeouts.h as they require
49 : // TestTimeouts::Initialize to have been called; this function can only be
50 : // called once, however, and gtest calls it later on.
51 : //
52 : // Set the timeout value to five minutes.
53 E : std::string test_timeout_val = "300000";
54 : CommandLine::ForCurrentProcess()->AppendSwitchASCII(
55 E : switches::kTestLauncherTimeout, test_timeout_val);
56 : // We don't need to update |argc| and |argv|, gtest read the value from
57 : // CommandLine::ForCurrentProcess().
58 : return base::LaunchUnitTests(argc,
59 : argv,
60 : base::Bind(&RunTestSuite,
61 : argc,
62 E : argv));
63 E : }
|