diff options
author | Mark Salyzyn <salyzyn@google.com> | 2014-06-06 13:38:42 -0700 |
---|---|---|
committer | Mark Salyzyn <salyzyn@google.com> | 2014-06-18 11:12:27 -0700 |
commit | 0c57bd864d2353e8f03c8b128bdacb58fc5dce95 (patch) | |
tree | 18975cf68fccd30fdd4e0fbbff1907216c69d18a /logd | |
parent | 0ef3fa24fb0c3c58b8440527e4de4f3f98ddaaa5 (diff) | |
download | system_core-0c57bd864d2353e8f03c8b128bdacb58fc5dce95.zip system_core-0c57bd864d2353e8f03c8b128bdacb58fc5dce95.tar.gz system_core-0c57bd864d2353e8f03c8b128bdacb58fc5dce95.tar.bz2 |
logd: test: modernize
- Correct default tense for kernel or user logger
- harden code that parses the benchmark data
- give more meaning to the spam filter test
Change-Id: I97699037ca9d56718f53f08d22be79092fb431de
Diffstat (limited to 'logd')
-rw-r--r-- | logd/tests/Android.mk | 2 | ||||
-rw-r--r-- | logd/tests/logd_test.cpp | 19 |
2 files changed, 11 insertions, 10 deletions
diff --git a/logd/tests/Android.mk b/logd/tests/Android.mk index 123e317..f851288 100644 --- a/logd/tests/Android.mk +++ b/logd/tests/Android.mk @@ -34,7 +34,7 @@ test_c_flags := \ -Werror \ -fno-builtin \ -ifeq ($(TARGET_USES_LOGD),true) +ifneq ($(TARGET_USES_LOGD),false) test_c_flags += -DTARGET_USES_LOGD=1 endif diff --git a/logd/tests/logd_test.cpp b/logd/tests/logd_test.cpp index 5b51b1f..d30eee2 100644 --- a/logd/tests/logd_test.cpp +++ b/logd/tests/logd_test.cpp @@ -568,10 +568,11 @@ TEST(logd, benchmark) { while (fgets(buffer, sizeof(buffer), fp)) { for (unsigned i = 0; i < sizeof(ns) / sizeof(ns[0]); ++i) { - if (strncmp(benchmarks[i], buffer, strlen(benchmarks[i]))) { + char *cp = strstr(buffer, benchmarks[i]); + if (!cp) { continue; } - sscanf(buffer, "%*s %lu %lu", &ns[i], &ns[i]); + sscanf(cp, "%*s %lu %lu", &ns[i], &ns[i]); fprintf(stderr, "%-22s%8lu\n", benchmarks[i], ns[i]); } } @@ -592,15 +593,15 @@ TEST(logd, benchmark) { #endif #ifdef TARGET_USES_LOGD - EXPECT_GE(25000UL, ns[log_maximum]); // 14055 user + EXPECT_GE(30000UL, ns[log_maximum]); // 27305 user #else EXPECT_GE(10000UL, ns[log_maximum]); // 5637 kernel #endif - EXPECT_GE(4000UL, ns[clock_overhead]); // 2008 + EXPECT_GE(4096UL, ns[clock_overhead]); // 4095 #ifdef TARGET_USES_LOGD - EXPECT_GE(250000UL, ns[log_overhead]); // 113219 user + EXPECT_GE(250000UL, ns[log_overhead]); // 121876 user #else EXPECT_GE(100000UL, ns[log_overhead]); // 50945 kernel #endif @@ -612,7 +613,7 @@ TEST(logd, benchmark) { #endif #ifdef TARGET_USES_LOGD - EXPECT_GE(20000000UL, ns[log_delay]); // 9542541 user + EXPECT_GE(20000000UL, ns[log_delay]); // 10500289 user #else EXPECT_GE(55000UL, ns[log_delay]); // 27341 kernel #endif @@ -642,11 +643,11 @@ TEST(logd, benchmark) { // 0/4225? 7454388/303656 31488/755 // ^-- benchmark_statistics_found - unsigned long nowSize = atol(benchmark_statistics_found); + unsigned long nowSpamSize = atol(benchmark_statistics_found); delete [] buf; - ASSERT_NE(0UL, nowSize); + ASSERT_NE(0UL, nowSpamSize); int sock = socket_local_client("logd", ANDROID_SOCKET_NAMESPACE_RESERVED, @@ -673,5 +674,5 @@ TEST(logd, benchmark) { totalSize = (totalSize * 11 ) / 10; // 50% threshold for SPAM filter (<20% typical, lots of engineering margin) - ASSERT_GT(totalSize, nowSize * 2); + ASSERT_GT(totalSize, nowSpamSize * 2); } |