Some GTest test cases start with __ ensure we parse those
When collecting tests only, on GTest we match the method
against a regex for typical method name format. Apparently
some GTest (like CtsBionicTestCases) also use format that
starts with __ in some lib so we need to handle that.
Test: unit tests
./cts-tradefed run cts-dev -m CtsBionicTestCases --log-level-display verbose --collect-tests-only
Bug: 116010055
Change-Id: I67dee802bce5e916e28f2a8394bf2bdb00a39e01
Merged-In: I67dee802bce5e916e28f2a8394bf2bdb00a39e01
(cherry picked from commit f81101571e867ca32bb19cecd2870e6eaacffc4e)
diff --git a/src/com/android/tradefed/testtype/GTestListTestParser.java b/src/com/android/tradefed/testtype/GTestListTestParser.java
index 894010e..216f4e0 100644
--- a/src/com/android/tradefed/testtype/GTestListTestParser.java
+++ b/src/com/android/tradefed/testtype/GTestListTestParser.java
@@ -45,7 +45,7 @@
// example: <line start> emptyPlayback<line end>
// example parameterized: <line start> emptyPlayback/0 # GetParam() = (object 1)<line end>
private static final Pattern TEST_METHOD =
- Pattern.compile("\\s+([a-zA-Z]+[\\S]*)(.*)?(\\s+.*)?$");
+ Pattern.compile("\\s+([a-zA-Z_]+[\\S]*)(.*)?(\\s+.*)?$");
// exposed for unit testing
protected List<TestDescription> mTests = new ArrayList<>();
diff --git a/tests/res/testtype/gtest_list1.txt b/tests/res/testtype/gtest_list1.txt
index 0cce19e..1ef5287 100644
--- a/tests/res/testtype/gtest_list1.txt
+++ b/tests/res/testtype/gtest_list1.txt
@@ -8,7 +8,7 @@
drawText
drawText_strikeThruAndUnderline
drawText_forceAlignLeft
- drawColor
+ __drawColor
backgroundAndImage
saveLayer_simple
saveLayer_missingRestore