Merge "Add --gtest-filter as synonym for --gtest_filter in bionic gtest main."

This commit is contained in:
Yabin Cui 2015-01-29 02:30:24 +00:00 committed by Gerrit Code Review
commit 017da8bc58
1 changed files with 13 additions and 0 deletions

View File

@ -91,6 +91,8 @@ static void PrintHelpInfo() {
" --warnline=[TIME_IN_MS]\n" " --warnline=[TIME_IN_MS]\n"
" Test running longer than [TIME_IN_MS] will be warned.\n" " Test running longer than [TIME_IN_MS] will be warned.\n"
" It takes effect only in isolation mode. Default warnline is 2000 ms.\n" " It takes effect only in isolation mode. Default warnline is 2000 ms.\n"
" --gtest-filter=POSITIVE_PATTERNS[-NEGATIVE_PATTERNS]\n"
" Used as a synonym for --gtest_filter option in gtest.\n"
"\nDefault bionic unit test option is -j.\n" "\nDefault bionic unit test option is -j.\n"
"\n"); "\n");
} }
@ -720,6 +722,15 @@ static size_t GetProcessorCount() {
return static_cast<size_t>(sysconf(_SC_NPROCESSORS_ONLN)); return static_cast<size_t>(sysconf(_SC_NPROCESSORS_ONLN));
} }
static void AddGtestFilterSynonym(std::vector<char*>& args) {
// Support --gtest-filter as a synonym for --gtest_filter.
for (size_t i = 1; i < args.size(); ++i) {
if (strncmp(args[i], "--gtest-filter", strlen("--gtest-filter")) == 0) {
args[i][7] = '_';
}
}
}
struct IsolationTestOptions { struct IsolationTestOptions {
bool isolate; bool isolate;
size_t job_count; size_t job_count;
@ -748,6 +759,8 @@ static bool PickOptions(std::vector<char*>& args, IsolationTestOptions& options)
} }
} }
AddGtestFilterSynonym(args);
// if --bionic-selftest argument is used, only enable self tests, otherwise remove self tests. // if --bionic-selftest argument is used, only enable self tests, otherwise remove self tests.
bool enable_selftest = false; bool enable_selftest = false;
for (size_t i = 1; i < args.size(); ++i) { for (size_t i = 1; i < args.size(); ++i) {