diff options
| author | 2018-05-31 16:43:41 +0000 | |
|---|---|---|
| committer | 2018-05-31 16:43:41 +0000 | |
| commit | 3ebdf7495ead52b76afdccd91c3b89264e4bf250 (patch) | |
| tree | b3a15b18110fdaa06316027dd997a20ac37ca9a4 | |
| parent | 03f16e4de1e3289414888fe0a5104205a781bd2f (diff) | |
| parent | e2e5e66a9cec84f83c2a47a815bae28f9c849d8d (diff) | |
Merge "Improve diagnostics in ART script tools/teardown-buildbot-device.sh."
| -rwxr-xr-x | tools/teardown-buildbot-device.sh | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/tools/teardown-buildbot-device.sh b/tools/teardown-buildbot-device.sh index be2cb274fc..bf14ca4f9f 100755 --- a/tools/teardown-buildbot-device.sh +++ b/tools/teardown-buildbot-device.sh @@ -25,6 +25,27 @@ adb root adb wait-for-device if [[ -n "$ART_TEST_CHROOT" ]]; then + + # remove_filesystem_from_chroot DIR-IN-CHROOT FSTYPE REMOVE-DIR-IN-CHROOT + # ----------------------------------------------------------------------- + # Unmount filesystem with type FSTYPE mounted in directory DIR-IN-CHROOT + # under the chroot directory. + # Remove DIR-IN-CHROOT under the chroot if REMOVE-DIR-IN-CHROOT is + # true. + remove_filesystem_from_chroot() { + local dir_in_chroot=$1 + local fstype=$2 + local remove_dir=$3 + local dir="$ART_TEST_CHROOT/$dir_in_chroot" + adb shell test -d "$dir" \ + && adb shell mount | grep -q "^$fstype on $dir type $fstype " \ + && if adb shell umount "$dir"; then + $remove_dir && adb shell rmdir "$dir" + else + adb shell lsof "$dir" + fi + } + # Tear down the chroot dir. echo -e "${green}Tear down the chroot dir in $ART_TEST_CHROOT${nc}" @@ -32,22 +53,17 @@ if [[ -n "$ART_TEST_CHROOT" ]]; then [[ "x$ART_TEST_CHROOT" = x/* ]] || { echo "$ART_TEST_CHROOT is not an absolute path"; exit 1; } # Remove /dev from chroot. - adb shell mount | grep -q "^tmpfs on $ART_TEST_CHROOT/dev type tmpfs " \ - && adb shell umount "$ART_TEST_CHROOT/dev" \ - && adb shell rmdir "$ART_TEST_CHROOT/dev" + remove_filesystem_from_chroot dev tmpfs true # Remove /sys/kernel/debug from chroot. - adb shell mount | grep -q "^debugfs on $ART_TEST_CHROOT/sys/kernel/debug type debugfs " \ - && adb shell umount "$ART_TEST_CHROOT/sys/kernel/debug" + # The /sys/kernel/debug directory under the chroot dir cannot be + # deleted, as it is part of the host device's /sys filesystem. + remove_filesystem_from_chroot sys/kernel/debug debugfs false # Remove /sys from chroot. - adb shell mount | grep -q "^sysfs on $ART_TEST_CHROOT/sys type sysfs " \ - && adb shell umount "$ART_TEST_CHROOT/sys" \ - && adb shell rmdir "$ART_TEST_CHROOT/sys" + remove_filesystem_from_chroot sys sysfs true # Remove /proc from chroot. - adb shell mount | grep -q "^proc on $ART_TEST_CHROOT/proc type proc " \ - && adb shell umount "$ART_TEST_CHROOT/proc" \ - && adb shell rmdir "$ART_TEST_CHROOT/proc" + remove_filesystem_from_chroot proc proc true # Remove /etc from chroot. adb shell rm -f "$ART_TEST_CHROOT/etc" |