summaryrefslogtreecommitdiffstats
path: root/logcat
diff options
context:
space:
mode:
authorMark Salyzyn <salyzyn@google.com>2017-03-24 07:58:10 -0700
committerMark Salyzyn <salyzyn@google.com>2017-03-27 11:57:53 -0700
commitfbc0fe429b4b97011fcd0a1f1ed449371c03ea4a (patch)
tree4f607196fa5e6cb989ca4a5fcc774543b32b9964 /logcat
parentca622b4e78cd6ddc8b7d10a5acc9f685b3f11c04 (diff)
downloadsystem_core-fbc0fe429b4b97011fcd0a1f1ed449371c03ea4a.tar.gz
system_core-fbc0fe429b4b97011fcd0a1f1ed449371c03ea4a.tar.bz2
system_core-fbc0fe429b4b97011fcd0a1f1ed449371c03ea4a.zip
logcat: test: run 256 simultaneous logcats
For logd daemon, heavy reader stress. For system popen fork and execute of logcat measure baseline against liblogcat. For liblogcat local concurrent thread, locking, argument parsing and context scaling for popen-style pair of android_logcat_run_command_thread* functions. NB: 1000 logcat executables ran, but did not scale well on time blocked for more than a minute. With 343 contexts of android_logcat_run_command_thread ran out of local resources to even return a file descriptor, and the per-context event tag mappings coincidentally ran out at 340 when threads ran, although that path was consistently 15% faster than the popen test. Test: gtest logcat-unit-tests --gtest_filter=*.End_to_End_multitude Bug: 35326290 Change-Id: I0e1a5d4f8ffbd77fa8db13d53f4d328973731895
Diffstat (limited to 'logcat')
-rw-r--r--logcat/tests/logcat_test.cpp50
1 files changed, 50 insertions, 0 deletions
diff --git a/logcat/tests/logcat_test.cpp b/logcat/tests/logcat_test.cpp
index 0895834b2..a3a017609 100644
--- a/logcat/tests/logcat_test.cpp
+++ b/logcat/tests/logcat_test.cpp
@@ -479,6 +479,56 @@ TEST(logcat, End_to_End) {
ASSERT_EQ(1, count);
}
+TEST(logcat, End_to_End_multitude) {
+ pid_t pid = getpid();
+
+ log_time ts(CLOCK_MONOTONIC);
+
+ ASSERT_LT(0, __android_log_btwrite(0, EVENT_TYPE_LONG, &ts, sizeof(ts)));
+
+ FILE* fp[256]; // does this count as a multitude!
+ memset(fp, 0, sizeof(fp));
+ logcat_define(ctx[sizeof(fp) / sizeof(fp[0])]);
+ size_t num = 0;
+ do {
+ EXPECT_TRUE(NULL !=
+ (fp[num] = logcat_popen(
+ ctx[num], "logcat -v brief -b events -t 100")));
+ if (!fp[num]) {
+ fprintf(stderr,
+ "WARNING: limiting to %zu simultaneous logcat operations\n",
+ num);
+ break;
+ }
+ } while (++num < sizeof(fp) / sizeof(fp[0]));
+
+ char buffer[BIG_BUFFER];
+
+ size_t count = 0;
+
+ for (size_t idx = 0; idx < sizeof(fp) / sizeof(fp[0]); ++idx) {
+ if (!fp[idx]) break;
+ while (fgets(buffer, sizeof(buffer), fp[idx])) {
+ int p;
+ unsigned long long t;
+
+ if ((2 != sscanf(buffer, "I/[0] ( %d): %llu", &p, &t)) ||
+ (p != pid)) {
+ continue;
+ }
+
+ log_time tx((const char*)&t);
+ if (ts == tx) {
+ ++count;
+ }
+ }
+
+ logcat_pclose(ctx[idx], fp[idx]);
+ }
+
+ ASSERT_EQ(num, count);
+}
+
static int get_groups(const char* cmd) {
FILE* fp;
logcat_define(ctx);