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

Bug: 19130480
Change-Id: I0d3df70ee8f692581cc4b9b742c5f347259fd0d2
diff --git a/tests/gtest_main.cpp b/tests/gtest_main.cpp
index b0740b0..e199449 100644
--- a/tests/gtest_main.cpp
+++ b/tests/gtest_main.cpp
@@ -91,6 +91,8 @@
          "  --warnline=[TIME_IN_MS]\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"
+         "  --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"
          "\n");
 }
@@ -720,6 +722,15 @@
   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 {
   bool isolate;
   size_t job_count;
@@ -748,6 +759,8 @@
     }
   }
 
+  AddGtestFilterSynonym(args);
+
   // if --bionic-selftest argument is used, only enable self tests, otherwise remove self tests.
   bool enable_selftest = false;
   for (size_t i = 1; i < args.size(); ++i) {