summaryrefslogtreecommitdiffstats
path: root/tests/gtest_main.cpp
diff options
context:
space:
mode:
authorYabin Cui <yabinc@google.com>2015-02-26 19:03:54 -0800
committerYabin Cui <yabinc@google.com>2015-02-26 19:03:54 -0800
commitf6237470a3f5ce801b5df2500f3d0ffb1aec4515 (patch)
treefa2996123c2f5b5a0078051b6539b7d803b50402 /tests/gtest_main.cpp
parentf8eec1e54fbfb7b0304b73cb9ce2de44760a672e (diff)
downloadbionic-f6237470a3f5ce801b5df2500f3d0ffb1aec4515.zip
bionic-f6237470a3f5ce801b5df2500f3d0ffb1aec4515.tar.gz
bionic-f6237470a3f5ce801b5df2500f3d0ffb1aec4515.tar.bz2
Make bionic gtest main be compatible with gtest output format for cts test.
Bug: 17589740 Change-Id: Ifab521da379a33bf0a7bf11c21386f936f0d494c
Diffstat (limited to 'tests/gtest_main.cpp')
-rw-r--r--tests/gtest_main.cpp33
1 files changed, 30 insertions, 3 deletions
diff --git a/tests/gtest_main.cpp b/tests/gtest_main.cpp
index 664e4a1..b1953fc 100644
--- a/tests/gtest_main.cpp
+++ b/tests/gtest_main.cpp
@@ -295,6 +295,32 @@ static void OnTestIterationStartPrint(const std::vector<TestCase>& testcase_list
fflush(stdout);
}
+// bionic cts test needs gtest output format.
+#if defined(USING_GTEST_OUTPUT_FORMAT)
+
+static void OnTestEndPrint(const TestCase& testcase, size_t test_id) {
+ ColoredPrintf(COLOR_GREEN, "[ RUN ] ");
+ printf("%s\n", testcase.GetTestName(test_id).c_str());
+
+ const std::string& test_output = testcase.GetTest(test_id).GetTestOutput();
+ printf("%s", test_output.c_str());
+
+ TestResult result = testcase.GetTestResult(test_id);
+ if (result == TEST_SUCCESS) {
+ ColoredPrintf(COLOR_GREEN, "[ OK ] ");
+ } else {
+ ColoredPrintf(COLOR_RED, "[ FAILED ] ");
+ }
+ printf("%s", testcase.GetTestName(test_id).c_str());
+ if (testing::GTEST_FLAG(print_time)) {
+ printf(" (%" PRId64 " ms)", testcase.GetTestTime(test_id) / 1000000);
+ }
+ printf("\n");
+ fflush(stdout);
+}
+
+#else // !defined(USING_GTEST_OUTPUT_FORMAT)
+
static void OnTestEndPrint(const TestCase& testcase, size_t test_id) {
TestResult result = testcase.GetTestResult(test_id);
if (result == TEST_SUCCESS) {
@@ -307,16 +333,17 @@ static void OnTestEndPrint(const TestCase& testcase, size_t test_id) {
printf("%s", testcase.GetTestName(test_id).c_str());
if (testing::GTEST_FLAG(print_time)) {
- printf(" (%" PRId64 " ms)\n", testcase.GetTestTime(test_id) / 1000000);
- } else {
- printf("\n");
+ printf(" (%" PRId64 " ms)", testcase.GetTestTime(test_id) / 1000000);
}
+ printf("\n");
const std::string& test_output = testcase.GetTest(test_id).GetTestOutput();
printf("%s", test_output.c_str());
fflush(stdout);
}
+#endif // !defined(USING_GTEST_OUTPUT_FORMAT)
+
static void OnTestIterationEndPrint(const std::vector<TestCase>& testcase_list, size_t /*iteration*/,
int64_t elapsed_time_ns) {