diff options
author | 2020-01-22 15:34:33 +0000 | |
---|---|---|
committer | 2020-01-30 12:53:06 +0000 | |
commit | 1c5b1ea14b3bf799eeaa27f583a72c5856771142 (patch) | |
tree | e072dda41f23d28b2edbf718af0e5b466d21cf44 | |
parent | 516745bd33ca4f919faf1b971c19c53677e6f788 (diff) |
Unify naming of buildbot commands
Rename buildbot scripts so they all begin with the prefix "buildbot-"
as this lets autocomplete make life easy for you when working with
device tests from the command line.
Temporarily add symlinks for keep other infra working until that is
updated too.
Test: manual
Change-Id: I5c14448ca4ce36eff7fa3ee149cee7f822e0ca86
-rw-r--r-- | test/README.chroot.md | 8 | ||||
-rwxr-xr-x | tools/buildbot-cleanup-device.sh | 47 | ||||
-rwxr-xr-x | tools/buildbot-setup-device.sh | 176 | ||||
-rwxr-xr-x | tools/buildbot-symbolize-crashes.sh | 27 | ||||
-rwxr-xr-x | tools/buildbot-teardown-device.sh | 147 | ||||
l---------[-rwxr-xr-x] | tools/cleanup-buildbot-device.sh | 48 | ||||
l---------[-rwxr-xr-x] | tools/setup-buildbot-device.sh | 177 | ||||
l---------[-rwxr-xr-x] | tools/symbolize-buildbot-crashes.sh | 28 | ||||
l---------[-rwxr-xr-x] | tools/teardown-buildbot-device.sh | 148 |
9 files changed, 405 insertions, 401 deletions
diff --git a/test/README.chroot.md b/test/README.chroot.md index 438a9add39..7c3fa8f11f 100644 --- a/test/README.chroot.md +++ b/test/README.chroot.md @@ -70,11 +70,11 @@ Note that using this chroot-based approach requires root access to the device ``` 4. Clean up the device: ```bash - art/tools/cleanup-buildbot-device.sh + art/tools/buildbot-cleanup-device.sh ``` 5. Setup the device (including setting up mount points and files in the chroot directory): ```bash - art/tools/setup-buildbot-device.sh + art/tools/buildbot-setup-device.sh ``` 6. Populate the chroot tree on the device (including "activating" APEX packages in the chroot environment): @@ -122,9 +122,9 @@ Note that using this chroot-based approach requires root access to the device ``` 11. Tear down device setup: ```bash - art/tools/teardown-buildbot-device.sh + art/tools/buildbot-teardown-device.sh ``` 12. Clean up the device: ```bash - art/tools/cleanup-buildbot-device.sh + art/tools/buildbot-cleanup-device.sh ``` diff --git a/tools/buildbot-cleanup-device.sh b/tools/buildbot-cleanup-device.sh new file mode 100755 index 0000000000..ebd61639bd --- /dev/null +++ b/tools/buildbot-cleanup-device.sh @@ -0,0 +1,47 @@ +#!/bin/bash +# +# Copyright (C) 2017 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +if [ -t 1 ]; then + # Color sequences if terminal is a tty. + green='\033[0;32m' + nc='\033[0m' +fi + +# Setup as root, as device cleanup requires it. +adb root +adb wait-for-device + +if [[ -n "$ART_TEST_CHROOT" ]]; then + # Check that ART_TEST_CHROOT is correctly defined. + if [[ "x$ART_TEST_CHROOT" != x/* ]]; then + echo "$ART_TEST_CHROOT is not an absolute path" + exit 1 + fi + + if adb shell test -d "$ART_TEST_CHROOT"; then + echo -e "${green}Remove entire /system directory from chroot directory${nc}" + adb shell rm -rf "$ART_TEST_CHROOT/system" + + echo -e "${green}Remove entire /data directory from chroot directory${nc}" + adb shell rm -rf "$ART_TEST_CHROOT/data" + + echo -e "${green}Remove entire chroot directory${nc}" + adb shell rmdir "$ART_TEST_CHROOT" || adb shell ls -la "$ART_TEST_CHROOT" + fi +else + adb shell rm -rf \ + /data/local/tmp /data/art-test /data/nativetest /data/nativetest64 '/data/misc/trace/*' +fi diff --git a/tools/buildbot-setup-device.sh b/tools/buildbot-setup-device.sh new file mode 100755 index 0000000000..f2bf3299fb --- /dev/null +++ b/tools/buildbot-setup-device.sh @@ -0,0 +1,176 @@ +#!/bin/bash +# +# Copyright (C) 2015 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# The work does by this script is (mostly) undone by tools/buildbot-teardown-device.sh. +# Make sure to keep these files in sync. + +if [ -t 1 ]; then + # Color sequences if terminal is a tty. + red='\033[0;31m' + green='\033[0;32m' + yellow='\033[0;33m' + nc='\033[0m' +fi + +if [ "$1" = --verbose ]; then + verbose=true +else + verbose=false +fi + +# Setup as root, as some actions performed here require it. +adb root +adb wait-for-device + +echo -e "${green}Date on host${nc}" +date + +echo -e "${green}Date on device${nc}" +adb shell date + +host_seconds_since_epoch=$(date -u +%s) +device_seconds_since_epoch=$(adb shell date -u +%s) + +abs_time_difference_in_seconds=$(expr $host_seconds_since_epoch - $device_seconds_since_epoch) +if [ $abs_time_difference_in_seconds -lt 0 ]; then + abs_time_difference_in_seconds=$(expr 0 - $abs_time_difference_in_seconds) +fi + +seconds_per_hour=3600 + +# Kill logd first, so that when we set the adb buffer size later in this file, +# it is brought up again. +echo -e "${green}Killing logd, seen leaking on fugu/N${nc}" +adb shell pkill -9 -U logd logd && echo -e "${green}...logd killed${nc}" + +# Update date on device if the difference with host is more than one hour. +if [ $abs_time_difference_in_seconds -gt $seconds_per_hour ]; then + echo -e "${green}Update date on device${nc}" + adb shell date -u @$host_seconds_since_epoch +fi + +echo -e "${green}Turn off selinux${nc}" +adb shell setenforce 0 +$verbose && adb shell getenforce + +echo -e "${green}Setting local loopback${nc}" +adb shell ifconfig lo up +$verbose && adb shell ifconfig + +if $verbose; then + echo -e "${green}List properties${nc}" + adb shell getprop + + echo -e "${green}Uptime${nc}" + adb shell uptime + + echo -e "${green}Battery info${nc}" + adb shell dumpsys battery +fi + +# Fugu only handles buffer size up to 16MB. +product_name=$(adb shell getprop ro.build.product) + +if [ "x$product_name" = xfugu ]; then + buffer_size=16MB +else + buffer_size=32MB +fi + +echo -e "${green}Setting adb buffer size to ${buffer_size}${nc}" +adb logcat -G ${buffer_size} +$verbose && adb logcat -g + +echo -e "${green}Removing adb spam filter${nc}" +adb logcat -P "" +$verbose && adb logcat -p + +echo -e "${green}Kill stalled dalvikvm processes${nc}" +# 'ps' on M can sometimes hang. +timeout 2s adb shell "ps" >/dev/null +if [ $? = 124 ]; then + echo -e "${green}Rebooting device to fix 'ps'${nc}" + adb reboot + adb wait-for-device root +else + processes=$(adb shell "ps" | grep dalvikvm | awk '{print $2}') + for i in $processes; do adb shell kill -9 $i; done +fi + +echo -e "${green}Set sys.linker.use_generated_config to false if file is absent" +adb shell "test -f /linkerconfig/ld.config.txt || setprop sys.linker.use_generated_config false" + +# Chroot environment. +# =================== + +if [[ -n "$ART_TEST_CHROOT" ]]; then + # Prepare the chroot dir. + echo -e "${green}Prepare the chroot dir in $ART_TEST_CHROOT${nc}" + + # Check that ART_TEST_CHROOT is correctly defined. + [[ "x$ART_TEST_CHROOT" = x/* ]] || { echo "$ART_TEST_CHROOT is not an absolute path"; exit 1; } + + # Create chroot. + adb shell mkdir -p "$ART_TEST_CHROOT" + + # Provide property_contexts file(s) in chroot. + # This is required to have Android system properties work from the chroot. + # Notes: + # - In Android N, only '/property_contexts' is expected. + # - In Android O+, property_context files are expected under /system and /vendor. + # (See bionic/libc/bionic/system_properties.cpp or + # bionic/libc/system_properties/contexts_split.cpp for more information.) + property_context_files="/property_contexts \ + /system/etc/selinux/plat_property_contexts \ + /vendor/etc/selinux/nonplat_property_context \ + /plat_property_contexts \ + /nonplat_property_contexts" + for f in $property_context_files; do + adb shell test -f "$f" \ + "&&" mkdir -p "$ART_TEST_CHROOT$(dirname $f)" \ + "&&" cp -f "$f" "$ART_TEST_CHROOT$f" + done + + # Create directories required for ART testing in chroot. + adb shell mkdir -p "$ART_TEST_CHROOT/tmp" + adb shell mkdir -p "$ART_TEST_CHROOT/data/dalvik-cache" + adb shell mkdir -p "$ART_TEST_CHROOT/data/local/tmp" + + # Populate /etc in chroot with required files. + adb shell mkdir -p "$ART_TEST_CHROOT/system/etc" + adb shell "cd $ART_TEST_CHROOT && ln -sf system/etc etc" + + # Provide /proc in chroot. + adb shell mkdir -p "$ART_TEST_CHROOT/proc" + adb shell mount | grep -q "^proc on $ART_TEST_CHROOT/proc type proc " \ + || adb shell mount -t proc proc "$ART_TEST_CHROOT/proc" + + # Provide /sys in chroot. + adb shell mkdir -p "$ART_TEST_CHROOT/sys" + adb shell mount | grep -q "^sysfs on $ART_TEST_CHROOT/sys type sysfs " \ + || adb shell mount -t sysfs sysfs "$ART_TEST_CHROOT/sys" + # Provide /sys/kernel/debug in chroot. + adb shell mount | grep -q "^debugfs on $ART_TEST_CHROOT/sys/kernel/debug type debugfs " \ + || adb shell mount -t debugfs debugfs "$ART_TEST_CHROOT/sys/kernel/debug" + + # Provide /dev in chroot. + adb shell mkdir -p "$ART_TEST_CHROOT/dev" + adb shell mount | grep -q "^tmpfs on $ART_TEST_CHROOT/dev type tmpfs " \ + || adb shell mount -o bind /dev "$ART_TEST_CHROOT/dev" + + # Create /apex directory in chroot. + adb shell mkdir -p "$ART_TEST_CHROOT/apex" +fi diff --git a/tools/buildbot-symbolize-crashes.sh b/tools/buildbot-symbolize-crashes.sh new file mode 100755 index 0000000000..0200346fa0 --- /dev/null +++ b/tools/buildbot-symbolize-crashes.sh @@ -0,0 +1,27 @@ +#!/bin/bash +# +# Copyright (C) 2016 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# We push art and its dependencies to '/data/local/tmp', but the 'stack' +# script expect things to be in '/'. So we just remove the +# '/data/local/tmp' prefix. +if [[ -n "$1" ]]; then + cat $1 +else + adb logcat -d +fi | sed 's,/data/local/tmp,,g' | development/scripts/stack + +# Always return 0 to avoid having the buildbot complain about wrong stacks. +exit 0 diff --git a/tools/buildbot-teardown-device.sh b/tools/buildbot-teardown-device.sh new file mode 100755 index 0000000000..e067a701c3 --- /dev/null +++ b/tools/buildbot-teardown-device.sh @@ -0,0 +1,147 @@ +#!/bin/bash +# +# Copyright (C) 2018 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# This script undoes (most of) the work done by tools/buildbot-setup-device.sh. +# Make sure to keep these files in sync. + +if [ -t 1 ]; then + # Color sequences if terminal is a tty. + green='\033[0;32m' + nc='\033[0m' +fi + +# Setup as root, as some actions performed here require it. +adb root +adb wait-for-device + +if [[ -n "$ART_TEST_CHROOT" ]]; then + # Check that ART_TEST_CHROOT is correctly defined. + [[ "x$ART_TEST_CHROOT" = x/* ]] || { echo "$ART_TEST_CHROOT is not an absolute path"; exit 1; } + + if adb shell test -d "$ART_TEST_CHROOT"; then + # Display users of the chroot dir. + + echo -e "${green}List open files under chroot dir $ART_TEST_CHROOT${nc}" + adb shell lsof | grep "$ART_TEST_CHROOT" + + # for_all_chroot_process ACTION + # ----------------------------- + # Execute ACTION on all processes running from binaries located + # under the chroot directory. ACTION is passed two arguments: the + # PID of the process, and a string containing the command line + # that started this process. + for_all_chroot_process() { + local action=$1 + adb shell ls -ld "/proc/*/root" \ + | sed -n -e "s,^.* \\(/proc/.*/root\\) -> $ART_TEST_CHROOT\$,\\1,p" \ + | while read link; do + local dir=$(dirname "$link") + local pid=$(basename "$dir") + local cmdline=$(adb shell cat "$dir"/cmdline | tr '\000' ' ') + $action "$pid" "$cmdline" + done + } + + # display_process PID CMDLINE + # --------------------------- + # Display information about process with given PID, that was started with CMDLINE. + display_process() { + local pid=$1 + local cmdline=$2 + echo "$cmdline (PID: $pid)" + } + + echo -e "${green}List processes running from binaries under chroot dir $ART_TEST_CHROOT${nc}" + for_all_chroot_process display_process + + # Tear down the chroot dir. + + echo -e "${green}Tear down the chroot set up in $ART_TEST_CHROOT${nc}" + + # 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 + echo "Files still open in $dir:" + adb shell lsof | grep "$dir" + fi + } + + # Remove /apex from chroot. + adb shell rm -rf "$ART_TEST_CHROOT/apex" + + # Remove /dev from chroot. + remove_filesystem_from_chroot dev tmpfs true + + # Remove /sys/kernel/debug from chroot. + # 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. + remove_filesystem_from_chroot sys sysfs true + + # Remove /proc from chroot. + remove_filesystem_from_chroot proc proc true + + # Remove /etc from chroot. + adb shell rm -f "$ART_TEST_CHROOT/etc" + adb shell rm -rf "$ART_TEST_CHROOT/system/etc" + + # Remove directories used for ART testing in chroot. + adb shell rm -rf "$ART_TEST_CHROOT/data/local/tmp" + adb shell rm -rf "$ART_TEST_CHROOT/data/dalvik-cache" + adb shell rm -rf "$ART_TEST_CHROOT/tmp" + + # Remove property_contexts file(s) from chroot. + property_context_files="/property_contexts \ + /system/etc/selinux/plat_property_contexts \ + /vendor/etc/selinux/nonplat_property_context \ + /plat_property_contexts \ + /nonplat_property_contexts" + for f in $property_context_files; do + adb shell rm -f "$ART_TEST_CHROOT$f" + done + + + # Kill processes still running in the chroot. + + # kill_process PID CMDLINE + # ------------------------ + # Kill process with given PID, that was started with CMDLINE. + kill_process() { + local pid=$1 + local cmdline=$2 + echo "Killing $cmdline (PID: $pid)" + adb shell kill -9 "$pid" + } + + echo -e "${green}Kill processes still running from binaries under" \ + "chroot dir $ART_TEST_CHROOT (if any)${nc} " + for_all_chroot_process kill_process + fi +fi diff --git a/tools/cleanup-buildbot-device.sh b/tools/cleanup-buildbot-device.sh index ebd61639bd..8389975b90 100755..120000 --- a/tools/cleanup-buildbot-device.sh +++ b/tools/cleanup-buildbot-device.sh @@ -1,47 +1 @@ -#!/bin/bash -# -# Copyright (C) 2017 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -if [ -t 1 ]; then - # Color sequences if terminal is a tty. - green='\033[0;32m' - nc='\033[0m' -fi - -# Setup as root, as device cleanup requires it. -adb root -adb wait-for-device - -if [[ -n "$ART_TEST_CHROOT" ]]; then - # Check that ART_TEST_CHROOT is correctly defined. - if [[ "x$ART_TEST_CHROOT" != x/* ]]; then - echo "$ART_TEST_CHROOT is not an absolute path" - exit 1 - fi - - if adb shell test -d "$ART_TEST_CHROOT"; then - echo -e "${green}Remove entire /system directory from chroot directory${nc}" - adb shell rm -rf "$ART_TEST_CHROOT/system" - - echo -e "${green}Remove entire /data directory from chroot directory${nc}" - adb shell rm -rf "$ART_TEST_CHROOT/data" - - echo -e "${green}Remove entire chroot directory${nc}" - adb shell rmdir "$ART_TEST_CHROOT" || adb shell ls -la "$ART_TEST_CHROOT" - fi -else - adb shell rm -rf \ - /data/local/tmp /data/art-test /data/nativetest /data/nativetest64 '/data/misc/trace/*' -fi +buildbot-cleanup-device.sh
\ No newline at end of file diff --git a/tools/setup-buildbot-device.sh b/tools/setup-buildbot-device.sh index 46969c8246..6cdd17e689 100755..120000 --- a/tools/setup-buildbot-device.sh +++ b/tools/setup-buildbot-device.sh @@ -1,176 +1 @@ -#!/bin/bash -# -# Copyright (C) 2015 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# The work does by this script is (mostly) undone by tools/teardown-buildbot-device.sh. -# Make sure to keep these files in sync. - -if [ -t 1 ]; then - # Color sequences if terminal is a tty. - red='\033[0;31m' - green='\033[0;32m' - yellow='\033[0;33m' - nc='\033[0m' -fi - -if [ "$1" = --verbose ]; then - verbose=true -else - verbose=false -fi - -# Setup as root, as some actions performed here require it. -adb root -adb wait-for-device - -echo -e "${green}Date on host${nc}" -date - -echo -e "${green}Date on device${nc}" -adb shell date - -host_seconds_since_epoch=$(date -u +%s) -device_seconds_since_epoch=$(adb shell date -u +%s) - -abs_time_difference_in_seconds=$(expr $host_seconds_since_epoch - $device_seconds_since_epoch) -if [ $abs_time_difference_in_seconds -lt 0 ]; then - abs_time_difference_in_seconds=$(expr 0 - $abs_time_difference_in_seconds) -fi - -seconds_per_hour=3600 - -# Kill logd first, so that when we set the adb buffer size later in this file, -# it is brought up again. -echo -e "${green}Killing logd, seen leaking on fugu/N${nc}" -adb shell pkill -9 -U logd logd && echo -e "${green}...logd killed${nc}" - -# Update date on device if the difference with host is more than one hour. -if [ $abs_time_difference_in_seconds -gt $seconds_per_hour ]; then - echo -e "${green}Update date on device${nc}" - adb shell date -u @$host_seconds_since_epoch -fi - -echo -e "${green}Turn off selinux${nc}" -adb shell setenforce 0 -$verbose && adb shell getenforce - -echo -e "${green}Setting local loopback${nc}" -adb shell ifconfig lo up -$verbose && adb shell ifconfig - -if $verbose; then - echo -e "${green}List properties${nc}" - adb shell getprop - - echo -e "${green}Uptime${nc}" - adb shell uptime - - echo -e "${green}Battery info${nc}" - adb shell dumpsys battery -fi - -# Fugu only handles buffer size up to 16MB. -product_name=$(adb shell getprop ro.build.product) - -if [ "x$product_name" = xfugu ]; then - buffer_size=16MB -else - buffer_size=32MB -fi - -echo -e "${green}Setting adb buffer size to ${buffer_size}${nc}" -adb logcat -G ${buffer_size} -$verbose && adb logcat -g - -echo -e "${green}Removing adb spam filter${nc}" -adb logcat -P "" -$verbose && adb logcat -p - -echo -e "${green}Kill stalled dalvikvm processes${nc}" -# 'ps' on M can sometimes hang. -timeout 2s adb shell "ps" >/dev/null -if [ $? = 124 ]; then - echo -e "${green}Rebooting device to fix 'ps'${nc}" - adb reboot - adb wait-for-device root -else - processes=$(adb shell "ps" | grep dalvikvm | awk '{print $2}') - for i in $processes; do adb shell kill -9 $i; done -fi - -echo -e "${green}Set sys.linker.use_generated_config to false if file is absent" -adb shell "test -f /linkerconfig/ld.config.txt || setprop sys.linker.use_generated_config false" - -# Chroot environment. -# =================== - -if [[ -n "$ART_TEST_CHROOT" ]]; then - # Prepare the chroot dir. - echo -e "${green}Prepare the chroot dir in $ART_TEST_CHROOT${nc}" - - # Check that ART_TEST_CHROOT is correctly defined. - [[ "x$ART_TEST_CHROOT" = x/* ]] || { echo "$ART_TEST_CHROOT is not an absolute path"; exit 1; } - - # Create chroot. - adb shell mkdir -p "$ART_TEST_CHROOT" - - # Provide property_contexts file(s) in chroot. - # This is required to have Android system properties work from the chroot. - # Notes: - # - In Android N, only '/property_contexts' is expected. - # - In Android O+, property_context files are expected under /system and /vendor. - # (See bionic/libc/bionic/system_properties.cpp or - # bionic/libc/system_properties/contexts_split.cpp for more information.) - property_context_files="/property_contexts \ - /system/etc/selinux/plat_property_contexts \ - /vendor/etc/selinux/nonplat_property_context \ - /plat_property_contexts \ - /nonplat_property_contexts" - for f in $property_context_files; do - adb shell test -f "$f" \ - "&&" mkdir -p "$ART_TEST_CHROOT$(dirname $f)" \ - "&&" cp -f "$f" "$ART_TEST_CHROOT$f" - done - - # Create directories required for ART testing in chroot. - adb shell mkdir -p "$ART_TEST_CHROOT/tmp" - adb shell mkdir -p "$ART_TEST_CHROOT/data/dalvik-cache" - adb shell mkdir -p "$ART_TEST_CHROOT/data/local/tmp" - - # Populate /etc in chroot with required files. - adb shell mkdir -p "$ART_TEST_CHROOT/system/etc" - adb shell "cd $ART_TEST_CHROOT && ln -sf system/etc etc" - - # Provide /proc in chroot. - adb shell mkdir -p "$ART_TEST_CHROOT/proc" - adb shell mount | grep -q "^proc on $ART_TEST_CHROOT/proc type proc " \ - || adb shell mount -t proc proc "$ART_TEST_CHROOT/proc" - - # Provide /sys in chroot. - adb shell mkdir -p "$ART_TEST_CHROOT/sys" - adb shell mount | grep -q "^sysfs on $ART_TEST_CHROOT/sys type sysfs " \ - || adb shell mount -t sysfs sysfs "$ART_TEST_CHROOT/sys" - # Provide /sys/kernel/debug in chroot. - adb shell mount | grep -q "^debugfs on $ART_TEST_CHROOT/sys/kernel/debug type debugfs " \ - || adb shell mount -t debugfs debugfs "$ART_TEST_CHROOT/sys/kernel/debug" - - # Provide /dev in chroot. - adb shell mkdir -p "$ART_TEST_CHROOT/dev" - adb shell mount | grep -q "^tmpfs on $ART_TEST_CHROOT/dev type tmpfs " \ - || adb shell mount -o bind /dev "$ART_TEST_CHROOT/dev" - - # Create /apex directory in chroot. - adb shell mkdir -p "$ART_TEST_CHROOT/apex" -fi +buildbot-setup-device.sh
\ No newline at end of file diff --git a/tools/symbolize-buildbot-crashes.sh b/tools/symbolize-buildbot-crashes.sh index 0200346fa0..ed04b65dfc 100755..120000 --- a/tools/symbolize-buildbot-crashes.sh +++ b/tools/symbolize-buildbot-crashes.sh @@ -1,27 +1 @@ -#!/bin/bash -# -# Copyright (C) 2016 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# We push art and its dependencies to '/data/local/tmp', but the 'stack' -# script expect things to be in '/'. So we just remove the -# '/data/local/tmp' prefix. -if [[ -n "$1" ]]; then - cat $1 -else - adb logcat -d -fi | sed 's,/data/local/tmp,,g' | development/scripts/stack - -# Always return 0 to avoid having the buildbot complain about wrong stacks. -exit 0 +buildbot-symbolize-crashes.sh
\ No newline at end of file diff --git a/tools/teardown-buildbot-device.sh b/tools/teardown-buildbot-device.sh index 1ea4cf0da4..0112bca212 100755..120000 --- a/tools/teardown-buildbot-device.sh +++ b/tools/teardown-buildbot-device.sh @@ -1,147 +1 @@ -#!/bin/bash -# -# Copyright (C) 2018 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# This script undoes (most of) the work done by tools/setup-buildbot-device.sh. -# Make sure to keep these files in sync. - -if [ -t 1 ]; then - # Color sequences if terminal is a tty. - green='\033[0;32m' - nc='\033[0m' -fi - -# Setup as root, as some actions performed here require it. -adb root -adb wait-for-device - -if [[ -n "$ART_TEST_CHROOT" ]]; then - # Check that ART_TEST_CHROOT is correctly defined. - [[ "x$ART_TEST_CHROOT" = x/* ]] || { echo "$ART_TEST_CHROOT is not an absolute path"; exit 1; } - - if adb shell test -d "$ART_TEST_CHROOT"; then - # Display users of the chroot dir. - - echo -e "${green}List open files under chroot dir $ART_TEST_CHROOT${nc}" - adb shell lsof | grep "$ART_TEST_CHROOT" - - # for_all_chroot_process ACTION - # ----------------------------- - # Execute ACTION on all processes running from binaries located - # under the chroot directory. ACTION is passed two arguments: the - # PID of the process, and a string containing the command line - # that started this process. - for_all_chroot_process() { - local action=$1 - adb shell ls -ld "/proc/*/root" \ - | sed -n -e "s,^.* \\(/proc/.*/root\\) -> $ART_TEST_CHROOT\$,\\1,p" \ - | while read link; do - local dir=$(dirname "$link") - local pid=$(basename "$dir") - local cmdline=$(adb shell cat "$dir"/cmdline | tr '\000' ' ') - $action "$pid" "$cmdline" - done - } - - # display_process PID CMDLINE - # --------------------------- - # Display information about process with given PID, that was started with CMDLINE. - display_process() { - local pid=$1 - local cmdline=$2 - echo "$cmdline (PID: $pid)" - } - - echo -e "${green}List processes running from binaries under chroot dir $ART_TEST_CHROOT${nc}" - for_all_chroot_process display_process - - # Tear down the chroot dir. - - echo -e "${green}Tear down the chroot set up in $ART_TEST_CHROOT${nc}" - - # 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 - echo "Files still open in $dir:" - adb shell lsof | grep "$dir" - fi - } - - # Remove /apex from chroot. - adb shell rm -rf "$ART_TEST_CHROOT/apex" - - # Remove /dev from chroot. - remove_filesystem_from_chroot dev tmpfs true - - # Remove /sys/kernel/debug from chroot. - # 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. - remove_filesystem_from_chroot sys sysfs true - - # Remove /proc from chroot. - remove_filesystem_from_chroot proc proc true - - # Remove /etc from chroot. - adb shell rm -f "$ART_TEST_CHROOT/etc" - adb shell rm -rf "$ART_TEST_CHROOT/system/etc" - - # Remove directories used for ART testing in chroot. - adb shell rm -rf "$ART_TEST_CHROOT/data/local/tmp" - adb shell rm -rf "$ART_TEST_CHROOT/data/dalvik-cache" - adb shell rm -rf "$ART_TEST_CHROOT/tmp" - - # Remove property_contexts file(s) from chroot. - property_context_files="/property_contexts \ - /system/etc/selinux/plat_property_contexts \ - /vendor/etc/selinux/nonplat_property_context \ - /plat_property_contexts \ - /nonplat_property_contexts" - for f in $property_context_files; do - adb shell rm -f "$ART_TEST_CHROOT$f" - done - - - # Kill processes still running in the chroot. - - # kill_process PID CMDLINE - # ------------------------ - # Kill process with given PID, that was started with CMDLINE. - kill_process() { - local pid=$1 - local cmdline=$2 - echo "Killing $cmdline (PID: $pid)" - adb shell kill -9 "$pid" - } - - echo -e "${green}Kill processes still running from binaries under" \ - "chroot dir $ART_TEST_CHROOT (if any)${nc} " - for_all_chroot_process kill_process - fi -fi +buildbot-teardown-device.sh
\ No newline at end of file |