From f6051de6f47d1a668f4d369d190e310014f52058 Mon Sep 17 00:00:00 2001 From: Jonathan Basseri Date: Fri, 15 Sep 2017 17:03:10 -0700 Subject: [PATCH] Support -c and -m for GTEST. This takes the --test-class and --test-method options and builds a --gtest_filter value to use when invoking native tests. How it works: ARGS to runtest ARG to GTEST --test-class= --test-method= --test-class=Foo --test-method= --gtest_filter=Foo.* --test-class= --test-method=Bar --gtest_filter=*.Bar --test-class=Foo --test-method=Bar --gtest_filter=Foo.Bar Advanced: -m *Iptables* runs all test methods containing 'Iptables' in any class. -c *ControllerTest runs all tests in any class ending with 'ControllerTest'. Note that the '.' and '*' characters above are not shell globs. The '*' are wildcards, and the '.' are literals. Test: runtest -x system/netd/server/netd_unit_test.cpp -m '*Iptables*' Test: runtest -x system/netd/server/netd_unit_test.cpp -c BandwidthControllerTest Test: runtest -x system/netd/server/netd_unit_test.cpp -c BandwidthControllerTest -m '*Iptables*' Change-Id: I967296da1bdcbc404f5ab91d24f9714eec7b475b --- testrunner/test_defs/gtest.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/testrunner/test_defs/gtest.py b/testrunner/test_defs/gtest.py index cceead960..90d8e52ef 100644 --- a/testrunner/test_defs/gtest.py +++ b/testrunner/test_defs/gtest.py @@ -49,7 +49,19 @@ class GTestSuite(test_suite.AbstractTestSuite): options: command line options adb: adb interface """ - shell_cmd = adb.PreviewShellCommand(self.GetTargetExecPath()) + + test_class = "*" + test_method = "*" + if options.test_class is not None: + test_class = options.test_class.lstrip() + if options.test_method is not None: + test_method = options.test_method.lstrip() + filter_arg = "" + if test_class != "*" or test_method != "*": + filter_arg = "--gtest_filter=%s.%s" % (test_class, test_method) + + shell_cmd = adb.PreviewShellCommand( + " ".join((self.GetTargetExecPath(), filter_arg))) logger.Log(shell_cmd) if not options.preview: # gtest will log to test results to stdout, so no need to do any