summaryrefslogtreecommitdiffstats
path: root/logd/tests/logd_test.cpp
diff options
context:
space:
mode:
authorMark Salyzyn <salyzyn@google.com>2015-05-26 11:00:45 -0700
committerMark Salyzyn <salyzyn@google.com>2015-06-01 14:27:02 -0700
commit42ac34f7401f70c3f19ef176df7e1bc2f47396a0 (patch)
tree790ddfe59ebea7c5c6ac3ab06ce9ca6080e361f2 /logd/tests/logd_test.cpp
parent222f8c3ac7315684ce17d125f5732edad352ab1e (diff)
downloadsystem_core-42ac34f7401f70c3f19ef176df7e1bc2f47396a0.zip
system_core-42ac34f7401f70c3f19ef176df7e1bc2f47396a0.tar.gz
system_core-42ac34f7401f70c3f19ef176df7e1bc2f47396a0.tar.bz2
logd: test modernization
(cherry pick from commit 62d6a2a921d5ee5cc455e6ae5e62d4ad2474fd25) Bug: 19603976 Change-Id: Ie920c128e7e6a436fea7a96c7d68bc39e13a2ad4
Diffstat (limited to 'logd/tests/logd_test.cpp')
-rw-r--r--logd/tests/logd_test.cpp82
1 files changed, 35 insertions, 47 deletions
diff --git a/logd/tests/logd_test.cpp b/logd/tests/logd_test.cpp
index 46bd9c0..3266360 100644
--- a/logd/tests/logd_test.cpp
+++ b/logd/tests/logd_test.cpp
@@ -93,53 +93,42 @@ static void alloc_statistics(char **buffer, size_t *length)
static char *find_benchmark_spam(char *cp)
{
// liblog_benchmarks has been run designed to SPAM. The signature of
- // a noisiest UID statistics is one of the following:
+ // a noisiest UID statistics is:
//
- // main: UID/PID Total size/num Now UID/PID[?] Total
- // 0 7500306/304207 71608/3183 0/4225? 7454388/303656
- // <wrap> 93432/1012
- // -or-
- // 0/gone 7454388/303656 93432/1012
+ // Chattiest UIDs in main log buffer: Size Pruned
+ // UID PACKAGE BYTES LINES
+ // 0 root 54164 147569
//
- // basically if we see a *large* number of 0/????? entries
- unsigned long value;
+ char *benchmark = NULL;
do {
- char *benchmark = strstr(cp, " 0/");
- char *benchmark_newline = strstr(cp, "\n0/");
+ static const char signature[] = "\n0 root ";
+
+ benchmark = strstr(cp, signature);
if (!benchmark) {
- benchmark = benchmark_newline;
+ break;
}
- if (benchmark_newline && (benchmark > benchmark_newline)) {
- benchmark = benchmark_newline;
+ cp = benchmark + sizeof(signature);
+ while (isspace(*cp)) {
+ ++cp;
}
- cp = benchmark;
- if (!cp) {
- break;
+ benchmark = cp;
+ while (isdigit(*cp)) {
+ ++cp;
}
- cp += 3;
- while (isdigit(*cp) || (*cp == 'g') || (*cp == 'o') || (*cp == 'n')) {
+ while (isspace(*cp)) {
++cp;
}
- value = 0;
- // ###? or gone
- if ((*cp == '?') || (*cp == 'e')) {
- while (*++cp == ' ');
- while (isdigit(*cp)) {
- value = value * 10ULL + *cp - '0';
- ++cp;
- }
- if (*cp != '/') {
- value = 0;
- continue;
- }
- while (isdigit(*++cp));
- while (*cp == ' ') ++cp;
- if (!isdigit(*cp)) {
- value = 0;
- }
+ unsigned long value = 0;
+ while (isdigit(*cp)) {
+ value = value * 10ULL + *cp - '0';
+ ++cp;
+ }
+ if (value > 100000UL) {
+ break;
}
- } while ((value < 900000ULL) && *cp);
- return cp;
+ benchmark = NULL;
+ } while (*cp);
+ return benchmark;
}
TEST(logd, statistics) {
@@ -179,16 +168,16 @@ TEST(logd, statistics) {
EXPECT_EQ(0, truncated);
#ifdef TARGET_USES_LOGD
- char *main_logs = strstr(cp, "\nmain:");
+ char *main_logs = strstr(cp, "\nChattiest UIDs in main ");
EXPECT_TRUE(NULL != main_logs);
- char *radio_logs = strstr(cp, "\nradio:");
+ char *radio_logs = strstr(cp, "\nChattiest UIDs in radio ");
EXPECT_TRUE(NULL != radio_logs);
- char *system_logs = strstr(cp, "\nsystem:");
+ char *system_logs = strstr(cp, "\nChattiest UIDs in system ");
EXPECT_TRUE(NULL != system_logs);
- char *events_logs = strstr(cp, "\nevents:");
+ char *events_logs = strstr(cp, "\nChattiest UIDs in events ");
EXPECT_TRUE(NULL != events_logs);
#endif
@@ -431,13 +420,13 @@ TEST(logd, benchmark) {
}
#ifdef TARGET_USES_LOGD
- EXPECT_GE(100000UL, ns[log_maximum_retry]); // 42777 user
+ EXPECT_GE(200000UL, ns[log_maximum_retry]); // 104734 user
#else
EXPECT_GE(10000UL, ns[log_maximum_retry]); // 5636 kernel
#endif
#ifdef TARGET_USES_LOGD
- EXPECT_GE(30000UL, ns[log_maximum]); // 27305 user
+ EXPECT_GE(90000UL, ns[log_maximum]); // 46913 user
#else
EXPECT_GE(10000UL, ns[log_maximum]); // 5637 kernel
#endif
@@ -445,13 +434,13 @@ TEST(logd, benchmark) {
EXPECT_GE(4096UL, ns[clock_overhead]); // 4095
#ifdef TARGET_USES_LOGD
- EXPECT_GE(250000UL, ns[log_overhead]); // 121876 user
+ EXPECT_GE(250000UL, ns[log_overhead]); // 126886 user
#else
EXPECT_GE(100000UL, ns[log_overhead]); // 50945 kernel
#endif
#ifdef TARGET_USES_LOGD
- EXPECT_GE(7500UL, ns[log_latency]); // 3718 user space
+ EXPECT_GE(10000UL, ns[log_latency]); // 5669 user space
#else
EXPECT_GE(500000UL, ns[log_latency]); // 254200 kernel
#endif
@@ -483,8 +472,7 @@ TEST(logd, benchmark) {
ASSERT_TRUE(benchmark_statistics_found != NULL);
// Check how effective the SPAM filter is, parse out Now size.
- // Total Now
- // 0/4225? 7454388/303656 31488/755
+ // 0 root 54164 147569
// ^-- benchmark_statistics_found
unsigned long nowSpamSize = atol(benchmark_statistics_found);