From 0e16d89960dff0b690a96d53dc5e0085967c11e5 Mon Sep 17 00:00:00 2001 From: Yuxian Xu Date: Mon, 30 Jul 2018 18:57:55 +0800 Subject: [PATCH] liblog#__android_log_btwrite__android_logger_list_read fail With replaced AOSP system.img, adb can be root by other test. The fail is caused by the reason that logdw is still active after __android_log_close(). This test has a potential bug. proc/net/unix may contain '\0', then "grep" command will treat this file as a bianry file. Using "grep -a" instead of "grep" could be a safer way to get the right results from bianry file. bug: 112250722 Test: Build CTS Test: Pixel 2 XL PPP5.180610.010 passed the following tests Test: run cts-on-gsi -m CtsLiblogTestCases --skip-preconditions Change-Id: I9bfca1522e90ebb68e6cecbdb63e3b67248e47c4 Signed-off-by: Xinghua Yang --- liblog/tests/liblog_test.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/liblog/tests/liblog_test.cpp b/liblog/tests/liblog_test.cpp index a8a9a120a..a20808e92 100644 --- a/liblog/tests/liblog_test.cpp +++ b/liblog/tests/liblog_test.cpp @@ -130,7 +130,7 @@ static bool isPmsgActive() { static bool isLogdwActive() { std::string logdwSignature = - popenToString("grep /dev/socket/logdw /proc/net/unix"); + popenToString("grep -a /dev/socket/logdw /proc/net/unix"); size_t beginning = logdwSignature.find(' '); if (beginning == std::string::npos) return true; beginning = logdwSignature.find(' ', beginning + 1); @@ -144,7 +144,7 @@ static bool isLogdwActive() { end = logdwSignature.find(' ', end + 1); if (end == std::string::npos) return true; std::string allLogdwEndpoints = popenToString( - "grep ' 00000002" + logdwSignature.substr(beginning, end - beginning) + + "grep -a ' 00000002" + logdwSignature.substr(beginning, end - beginning) + " ' /proc/net/unix | " + "sed -n 's/.* \\([0-9][0-9]*\\)$/ -> socket:[\\1]/p'"); if (allLogdwEndpoints.length() == 0) return true;