Roland Levillain | e4f1c51 | 2017-10-30 13:28:28 +0000 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
| 3 | # Copyright (C) 2017 The Android Open Source Project |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | |
Ulya Trafimovich | 9597748 | 2021-11-09 14:05:14 +0000 | [diff] [blame] | 17 | . "$(dirname $0)/buildbot-utils.sh" |
Roland Levillain | e4f1c51 | 2017-10-30 13:28:28 +0000 | [diff] [blame] | 18 | |
Ulya Trafimovich | 513801a | 2023-01-19 18:26:43 +0000 | [diff] [blame] | 19 | # Testing on a Linux VM requires special cleanup. |
| 20 | if [[ -n "$ART_TEST_ON_VM" ]]; then |
| 21 | [[ -d "$ART_TEST_VM_DIR" ]] || { msgfatal "no VM found in $ART_TEST_VM_DIR"; } |
| 22 | $ART_SSH_CMD "true" || { msgfatal "VM not responding (tried \"$ART_SSH_CMD true\""; } |
| 23 | $ART_SSH_CMD " |
| 24 | sudo umount $ART_TEST_CHROOT/proc |
| 25 | sudo umount $ART_TEST_CHROOT/sys |
| 26 | sudo umount $ART_TEST_CHROOT/dev |
| 27 | sudo umount $ART_TEST_CHROOT/bin |
| 28 | sudo umount $ART_TEST_CHROOT/lib |
| 29 | rm -rf $ART_TEST_CHROOT |
| 30 | " |
| 31 | exit 0 |
| 32 | fi |
| 33 | |
| 34 | # Regular Android device. Setup as root, as device cleanup requires it. |
Roland Levillain | e4f1c51 | 2017-10-30 13:28:28 +0000 | [diff] [blame] | 35 | adb root |
| 36 | adb wait-for-device |
| 37 | |
| 38 | if [[ -n "$ART_TEST_CHROOT" ]]; then |
| 39 | # Check that ART_TEST_CHROOT is correctly defined. |
| 40 | if [[ "x$ART_TEST_CHROOT" != x/* ]]; then |
| 41 | echo "$ART_TEST_CHROOT is not an absolute path" |
| 42 | exit 1 |
| 43 | fi |
| 44 | |
Roland Levillain | 917c80f | 2018-06-08 16:27:23 +0100 | [diff] [blame] | 45 | if adb shell test -d "$ART_TEST_CHROOT"; then |
Ulya Trafimovich | 5298bcd | 2021-11-09 14:46:22 +0000 | [diff] [blame] | 46 | msginfo "Remove entire /linkerconfig directory from chroot directory" |
Roland Levillain | 15ff34d | 2020-02-05 19:55:34 +0000 | [diff] [blame] | 47 | adb shell rm -rf "$ART_TEST_CHROOT/linkerconfig" |
| 48 | |
Ulya Trafimovich | 5298bcd | 2021-11-09 14:46:22 +0000 | [diff] [blame] | 49 | msginfo "Remove entire /system directory from chroot directory" |
Roland Levillain | 917c80f | 2018-06-08 16:27:23 +0100 | [diff] [blame] | 50 | adb shell rm -rf "$ART_TEST_CHROOT/system" |
Roland Levillain | e4f1c51 | 2017-10-30 13:28:28 +0000 | [diff] [blame] | 51 | |
Ulya Trafimovich | 5298bcd | 2021-11-09 14:46:22 +0000 | [diff] [blame] | 52 | msginfo "Remove entire /data directory from chroot directory" |
Roland Levillain | 917c80f | 2018-06-08 16:27:23 +0100 | [diff] [blame] | 53 | adb shell rm -rf "$ART_TEST_CHROOT/data" |
| 54 | |
Ulya Trafimovich | 5298bcd | 2021-11-09 14:46:22 +0000 | [diff] [blame] | 55 | msginfo "Remove entire chroot directory" |
Roland Levillain | 917c80f | 2018-06-08 16:27:23 +0100 | [diff] [blame] | 56 | adb shell rmdir "$ART_TEST_CHROOT" || adb shell ls -la "$ART_TEST_CHROOT" |
| 57 | fi |
Roland Levillain | e4f1c51 | 2017-10-30 13:28:28 +0000 | [diff] [blame] | 58 | else |
| 59 | adb shell rm -rf \ |
| 60 | /data/local/tmp /data/art-test /data/nativetest /data/nativetest64 '/data/misc/trace/*' |
| 61 | fi |