From ba2449b6ca2c47d8cb1a63d8b14a39a042d949c9 Mon Sep 17 00:00:00 2001 From: Mark Salyzyn Date: Thu, 13 Feb 2020 13:42:55 -0800 Subject: [PATCH 1/2] fs_mgr: remount: add -v option By default print only ERROR message, or messages without a source (eg: [fs_mgr]) library. Print all messages to stderr if the -v option is added. Always log all messages to the Android logger. Signed-off-by: Mark Salyzyn Test: adb-remount-test.sh Change-Id: I131315d4bae6ed29991043033811cf22e6032f8b --- fs_mgr/fs_mgr_remount.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/fs_mgr/fs_mgr_remount.cpp b/fs_mgr/fs_mgr_remount.cpp index 93bba686a..24cbad7c9 100644 --- a/fs_mgr/fs_mgr_remount.cpp +++ b/fs_mgr/fs_mgr_remount.cpp @@ -80,9 +80,13 @@ const android::fs_mgr::FstabEntry* is_wrapped(const android::fs_mgr::Fstab& over return &(*it); } +auto verbose = false; + void MyLogger(android::base::LogId id, android::base::LogSeverity severity, const char* tag, const char* file, unsigned int line, const char* message) { - fprintf(stderr, "%s\n", message); + if (verbose || severity == android::base::ERROR || message[0] != '[') { + fprintf(stderr, "%s\n", message); + } static auto logd = android::base::LogdLogger(); logd(id, severity, tag, file, line, message); } @@ -131,10 +135,14 @@ static int do_remount(int argc, char* argv[]) { {"fstab", required_argument, nullptr, 'T'}, {"help", no_argument, nullptr, 'h'}, {"reboot", no_argument, nullptr, 'R'}, + {"verbose", no_argument, nullptr, 'v'}, {0, 0, nullptr, 0}, }; - for (int opt; (opt = ::getopt_long(argc, argv, "hRT:", longopts, nullptr)) != -1;) { + for (int opt; (opt = ::getopt_long(argc, argv, "hRT:v", longopts, nullptr)) != -1;) { switch (opt) { + case 'h': + usage(SUCCESS); + break; case 'R': can_reboot = true; break; @@ -145,13 +153,13 @@ static int do_remount(int argc, char* argv[]) { } fstab_file = optarg; break; + case 'v': + verbose = true; + break; default: LOG(ERROR) << "Bad Argument -" << char(opt); usage(BADARG); break; - case 'h': - usage(SUCCESS); - break; } } From f7aa5403c50ce86584641a96ba96d61b5e5c2194 Mon Sep 17 00:00:00 2001 From: Mark Salyzyn Date: Thu, 13 Feb 2020 08:53:25 -0800 Subject: [PATCH 2/2] fs_mgr: overlayfs: test: if wait_for_screen times out, skip later To improve the test period for adb-remount-test.sh, if the device fails to get to the launcher on the first try when wait_for_screen, then print a warning to skip all later wait_for_screen conditions. The wait_for_screen testing is really there to deal with first confirming that the device is capable of getting to the launcher, and that later tests that influence corners of adb remount behavior do not result in a failure to get to the launcher screen. The developer should look into ways to fix the failure to get to the launcher on the first try, but failure to do so should have no bearing on the remaining tests, so dropping the wait_for_screen functionality is not an issue. Signed-off-by: Mark Salyzyn Test: adb-remount-test.sh Bug: 148881519 Change-Id: I5b4a87d6e1f545a304eb74f2114aadd1128f25b3 --- fs_mgr/tests/adb-remount-test.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fs_mgr/tests/adb-remount-test.sh b/fs_mgr/tests/adb-remount-test.sh index e364436ae..cf324fe8f 100755 --- a/fs_mgr/tests/adb-remount-test.sh +++ b/fs_mgr/tests/adb-remount-test.sh @@ -902,7 +902,11 @@ adb_sh ls -l /dev/block/by-name/ /dev/block/mapper/ /dev/null | done # If reboot too soon after fresh flash, could trip device update failure logic -wait_for_screen +if ! wait_for_screen && ${screen_wait}; then + screen_wait=false + echo "${ORANGE}[ WARNING ]${NORMAL} not healthy, no launcher, skipping wait for screen" >&2 +fi + # Can we test remount -R command? OVERLAYFS_BACKING="cache mnt/scratch" overlayfs_supported=true