Merge "logd: test modernization"

This commit is contained in:
Mark Salyzyn 2015-06-01 21:16:34 +00:00 committed by Gerrit Code Review
commit a8b6131ddf
1 changed files with 36 additions and 48 deletions

View File

@ -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;
}
if (benchmark_newline && (benchmark > benchmark_newline)) {
benchmark = benchmark_newline;
}
cp = benchmark;
if (!cp) {
break;
}
cp += 3;
while (isdigit(*cp) || (*cp == 'g') || (*cp == 'o') || (*cp == 'n')) {
cp = benchmark + sizeof(signature);
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;
}
benchmark = cp;
while (isdigit(*cp)) {
++cp;
}
} while ((value < 900000ULL) && *cp);
return cp;
while (isspace(*cp)) {
++cp;
}
unsigned long value = 0;
while (isdigit(*cp)) {
value = value * 10ULL + *cp - '0';
++cp;
}
if (value > 100000UL) {
break;
}
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);