webrtc_m130/webrtc/test/test_suite.cc

63 lines
1.9 KiB
C++
Raw Normal View History

/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "webrtc/test/test_suite.h"
#include "gflags/gflags.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "webrtc/base/logging.h"
#include "webrtc/test/testsupport/fileutils.h"
#include "webrtc/test/testsupport/trace_to_stderr.h"
#include "webrtc/test/field_trial.h"
DEFINE_bool(logs, false, "print logs to stderr");
DEFINE_string(force_fieldtrials, "",
"Field trials control experimental feature code which can be forced. "
"E.g. running with --force_fieldtrials=WebRTC-FooFeature/Enable/"
" will assign the group Enable to field trial WebRTC-FooFeature.");
namespace webrtc {
namespace test {
Improving the way fileutil.h finds test resources. Adding the argv[0] path to the working directory to make it possible find the project root even when the test is executed from outside the project dir (like it is on some buildbots). Removed tests that moves into directories since they no longer work with this approach. The new functionality have been verified by manual tests of the following cases, example with a checkout root dir called webrtc/: Working dir: Command line: webrtc trunk/out/Debug/test webrtc/trunk out/Debug/test webrtc/trunk/out Debug/test webrtc/trunk/out ./Debug/test webrtc/trunk/out/Debug ./test webrtc/trunk/out/Debug/subdir ../test webrtc/trunk/out/Debug/subdir ./../test I also made another program with its own main method (only links with 'test_support', not 'test_support_main') and made sure that it was still possible to use as before (i.e. works within the project tree but not above it): #include "testsupport/fileutils.h" int main(int argc, char** argv) { printf("Working dir: %s\n", webrtc::test::WorkingDir().c_str()); printf("Project root: %s\n", webrtc::test::ProjectRootPath().c_str()); printf("Output path: %s\n", webrtc::test::OutputPath().c_str()); } BUG=Existing implementation cannot handle when the working directory is outside the project checkout. TEST=test_support_unittests and manual tests with video_codecs_test_framework_integration_tests + passing all trybots + memcheck tool Review URL: https://webrtc-codereview.appspot.com/858014 git-svn-id: http://webrtc.googlecode.com/svn/trunk@2927 4adac7df-926f-26a2-2b94-8c16560cd09d
2012-10-15 18:14:12 +00:00
TestSuite::TestSuite(int argc, char** argv) {
SetExecutablePath(argv[0]);
testing::InitGoogleMock(&argc, argv); // Runs InitGoogleTest() internally.
// AllowCommandLineParsing allows us to ignore flags passed on to us by
// Chromium build bots without having to explicitly disable them.
google::AllowCommandLineReparsing();
google::ParseCommandLineFlags(&argc, &argv, true);
webrtc::test::InitFieldTrialsFromString(FLAGS_force_fieldtrials);
}
TestSuite::~TestSuite() {
}
int TestSuite::Run() {
Initialize();
int result = RUN_ALL_TESTS();
Shutdown();
return result;
}
void TestSuite::Initialize() {
rtc::LogMessage::SetLogToStderr(FLAGS_logs);
if (FLAGS_logs)
trace_to_stderr_.reset(new TraceToStderr);
}
void TestSuite::Shutdown() {
}
} // namespace test
} // namespace webrtc