diff options
| author | Mark Salyzyn <salyzyn@google.com> | 2016-11-10 10:24:44 -0800 |
|---|---|---|
| committer | Mark Salyzyn <salyzyn@google.com> | 2017-04-14 12:54:25 -0700 |
| commit | 5768d3d9769c37ede68efa2f7df98bb146881e62 (patch) | |
| tree | 98f4809e437fc5231a0341b7728e10cd615901e0 /logcat | |
| parent | 46186a7238973c4f60ffcf1af0e2bee737bef63d (diff) | |
| download | system_core-5768d3d9769c37ede68efa2f7df98bb146881e62.tar.gz system_core-5768d3d9769c37ede68efa2f7df98bb146881e62.tar.bz2 system_core-5768d3d9769c37ede68efa2f7df98bb146881e62.zip | |
liblog: logprint supports number of seconds time event field
Add s to report time in seconds. The time could be a period, duration
or monotonic, expanded to seconds, minutes, hours and days. gTest has
to acquire a dynamic tag allocation as there are no users of this
feature yet.
Looking to the future, audio media logging has binary content similar
to the binary events structures Android logging uses and they have
a definition of a duration field in their internal binary logging, so
may be of use when we unify the logs.
Test: gTest logcat-unit-tests --gtest_filter=*.descriptive
Bug: 31456426
Change-Id: I262c03775983b3bc7b1b00227ce2bb2b0f357bec
Diffstat (limited to 'logcat')
| -rw-r--r-- | logcat/event.logtags | 1 | ||||
| -rw-r--r-- | logcat/tests/logcat_test.cpp | 43 |
2 files changed, 44 insertions, 0 deletions
diff --git a/logcat/event.logtags b/logcat/event.logtags index 9f053511b..efcc8179b 100644 --- a/logcat/event.logtags +++ b/logcat/event.logtags @@ -30,6 +30,7 @@ # 4: Number of allocations # 5: Id # 6: Percent +# s: Number of seconds (monotonic time) # Default value for data of type int/long is 2 (bytes). # # TODO: generate ".java" and ".h" files with integer constants from this file. diff --git a/logcat/tests/logcat_test.cpp b/logcat/tests/logcat_test.cpp index b2b051e66..33355e4f5 100644 --- a/logcat/tests/logcat_test.cpp +++ b/logcat/tests/logcat_test.cpp @@ -32,6 +32,7 @@ #include <android-base/file.h> #include <gtest/gtest.h> +#include <log/event_tag_map.h> #include <log/log.h> #include <log/log_event_list.h> @@ -1671,6 +1672,48 @@ TEST(logcat, descriptive) { EXPECT_LE(0, ret); EXPECT_TRUE(End_to_End(sync.tagStr, "")); } + + { + // Invent new entries because existing can not serve + EventTagMap* map = android_openEventTagMap(nullptr); + ASSERT_TRUE(nullptr != map); + static const char name[] = ___STRING(logcat) "_descriptive_monotonic"; + int myTag = android_lookupEventTagNum(map, name, "(new|1|s)", + ANDROID_LOG_UNKNOWN); + android_closeEventTagMap(map); + ASSERT_NE(-1, myTag); + + const struct tag sync = { (uint32_t)myTag, name }; + + { + android_log_event_list ctx(sync.tagNo); + ctx << (uint32_t)7; + for (ret = -EBUSY; ret == -EBUSY; rest()) ret = ctx.write(); + EXPECT_LE(0, ret); + EXPECT_TRUE(End_to_End(sync.tagStr, "new=7s")); + } + { + android_log_event_list ctx(sync.tagNo); + ctx << (uint32_t)62; + for (ret = -EBUSY; ret == -EBUSY; rest()) ret = ctx.write(); + EXPECT_LE(0, ret); + EXPECT_TRUE(End_to_End(sync.tagStr, "new=1:02")); + } + { + android_log_event_list ctx(sync.tagNo); + ctx << (uint32_t)3673; + for (ret = -EBUSY; ret == -EBUSY; rest()) ret = ctx.write(); + EXPECT_LE(0, ret); + EXPECT_TRUE(End_to_End(sync.tagStr, "new=1:01:13")); + } + { + android_log_event_list ctx(sync.tagNo); + ctx << (uint32_t)(86400 + 7200 + 180 + 58); + for (ret = -EBUSY; ret == -EBUSY; rest()) ret = ctx.write(); + EXPECT_LE(0, ret); + EXPECT_TRUE(End_to_End(sync.tagStr, "new=1d 2:03:58")); + } + } } static bool reportedSecurity(const char* command) { |
