Merge "logd_integration_test: check dropped logs" am: e8d09fb437 am: ce795d2aeb am: 4d6c6e2efc am: f63ef07fb4
Original change: https://android-review.googlesource.com/c/platform/system/logging/+/2523938
Change-Id: I9670e3f66283494604f85b14ec1c129dca82f6b3
Signed-off-by: Automerger Merge Worker <[email protected]>
diff --git a/logd/integration_test/logd_integration_test.py b/logd/integration_test/logd_integration_test.py
index a7e129c..8001871 100755
--- a/logd/integration_test/logd_integration_test.py
+++ b/logd/integration_test/logd_integration_test.py
@@ -15,6 +15,7 @@
# limitations under the License.
#
+import re
import subprocess
import unittest
@@ -53,6 +54,29 @@
continue
test_case.assertTrue(a_service_worked)
+def get_dropped_logs(test_case, buffer):
+ output = subprocess.check_output(["adb", "logcat", "-b", buffer, "--statistics"]).decode()
+ output = iter(output.split("\n"))
+
+ res = []
+
+ # Search for these lines, in order. Consider output:
+ # :) adb logcat -b system -S | grep -E "Total|Now"
+ # size/num system Total
+ # Total 883973/6792 883973/6792
+ # Now 883973/6792 883973/6792
+ for indication in ["Total", "Now"]:
+ reLineCount = re.compile(f"^{indication}.*\s+[0-9]+/([0-9]+)")
+ while True:
+ line = next(output)
+ match = reLineCount.match(line)
+ if match:
+ res.append(int(match.group(1)))
+ break
+
+ total, now = res
+ return total - now
+
class LogdIntegrationTest(unittest.TestCase):
def test_no_logs(self):
for service, pid in iter_service_pids(self, KNOWN_NON_LOGGING_SERVICES):
@@ -66,6 +90,15 @@
lines = get_pid_logs(pid)
self.assertTrue("\n" in lines, f"{service} ({pid}) should have logs, but found: {lines}")
+ def test_no_dropped_logs(self):
+ for buffer in ["system", "main", "kernel", "crash"]:
+ dropped = get_dropped_logs(self, buffer)
+ if buffer == "main":
+ # after b/276957640, should be able to reduce this to ~4000
+ self.assertLess(dropped, 30000, f"Buffer {buffer} has {dropped} dropped logs.")
+ else:
+ self.assertEqual(dropped, 0, f"Buffer {buffer} has {dropped} dropped logs.")
+
def main():
unittest.main(verbosity=3)