summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Brodsky <kevin.brodsky@linaro.org>2015-12-16 11:05:57 +0000
committerVishal Bhoj <vishal.bhoj@linaro.org>2016-01-04 09:17:30 +0530
commitdc64acc3b35584243e27bdd9bfbf81647509a6e5 (patch)
tree8d41117dc8b4199b4ab6e40b44e62e07acffe1cd
parent7d90c77e19510bb9de2c95215ad966480fcc9096 (diff)
Local mode for running target/host test
setup-android.sh now detects whether the script is being invoked through Jenkins by checking the existence of JENKINS_HOME. In this case, JENKINS_MODE is defined and the behaviour remains the same. Otherwise, the script assumes it is running on a local machine and does not modify the user environment or use sudo. Additionally, default values are provided for variables normally defined by Jenkins, so that it is possible to run the script without additional configuration on any machine that has been set up for building Android (repo is assumed to be in the PATH, for instance). In local mode, setup-android.sh tries to honor the existing environment variables, for instance regarding ccache, instead of always redefining them. Change-Id: I5a91d6385919c06aeb0725101ffc87646479f6bc
-rwxr-xr-xsetup-android.sh95
-rwxr-xr-xtest-art-host-test.sh7
-rwxr-xr-xtest-art-target-test.sh17
3 files changed, 85 insertions, 34 deletions
diff --git a/setup-android.sh b/setup-android.sh
index 29f81c2..9f6775a 100755
--- a/setup-android.sh
+++ b/setup-android.sh
@@ -4,24 +4,54 @@ set -xe
export LANG=C
export PATH=$PWD/tests:$PATH
+# If PAGER is set, repo manifest will display its message using the pager,
+# pausing the script until the pager is closed
+unset PAGER
-git config --global user.email "android-build-bot@fake-email.invalid"
-git config --global user.name "android-build-bot"
-
-mkdir -p $HOME/bin
-curl https://storage.googleapis.com/git-repo-downloads/repo > $HOME/bin/repo
-wget https://git.linaro.org/ci/publishing-api.git/blob_plain/HEAD:/linaro-cp.py -O $HOME/bin/linaro-cp.py
-chmod a+x $HOME/bin/*
-export PATH=$HOME/bin:$PATH
-
-base_dir=$HOME/srv/$JOB_NAME
cpu_count=$(getconf _NPROCESSORS_ONLN)
jcpu_count=$(($cpu_count * 2))
+build_config_dir=android-build-configs
+
+if [[ ${JENKINS_HOME+y} ]]; then
+ # This script has been invoked by Jenkins, this is an automated run
+ JENKINS_MODE=y
+ echo -e "\e[32mJenkins run"
+
+ git config --global user.email "android-build-bot@fake-email.invalid"
+ git config --global user.name "android-build-bot"
+
+ mkdir -p $HOME/bin
+ curl https://storage.googleapis.com/git-repo-downloads/repo > $HOME/bin/repo
+ wget https://git.linaro.org/ci/publishing-api.git/blob_plain/HEAD:/linaro-cp.py -O $HOME/bin/linaro-cp.py
+ chmod a+x $HOME/bin/*
+ export PATH=$HOME/bin:$PATH
+ base_dir=$HOME/srv/$JOB_NAME
+else
+ # Local run
+ unset JENKINS_MODE
+ echo -e "\e[32mLocal run"
+
+ : ${base_dir:=$PWD/test_base_dir}
+
+ # We need to define variables that are normally defined by Jenkins
+ : ${WORKSPACE:=$PWD/workspace}
+ mkdir -p "$WORKSPACE"
+ : ${BUILD_CONFIG_REPO:=git://android.git.linaro.org/android-build-configs.git}
+ : ${BUILD_CONFIG_BRANCH:=master}
+
+ # Choose a default config filename depending on the script that sourced this file
+ case $(basename ${BASH_SOURCE[1]}) in
+ test-art-target-test.sh)
+ : ${BUILD_CONFIG_FILENAME:=linaro-art-tip-aosp_flounder} ;;
+ test-art-host-test.sh)
+ : ${BUILD_CONFIG_FILENAME:=linaro-art-tip-aosp_arm64} ;;
+ esac
+fi
# Move to persistent drive
if [[ ! -d $base_dir ]]; then
mkdir -p "$base_dir"
- chmod 777 "$base_dir"
+ [[ $JENKINS_MODE ]] && chmod 755 "$base_dir"
fi
cd "$base_dir"
@@ -29,11 +59,21 @@ if [[ ! ($BUILD_CONFIG_REPO && $BUILD_CONFIG_BRANCH && $BUILD_CONFIG_FILENAME) ]
echo "ERROR: Please provide the config repository, branch and filename"
exit 1
else
- rm -rf android-build-configs
- git clone $BUILD_CONFIG_REPO -b $BUILD_CONFIG_BRANCH
+ if [[ -d $build_config_dir/.git && ! $JENKINS_MODE ]]; then
+ # Only update the repo to preserve local modifications
+ cd $build_config_dir
+ git pull
+ cd -
+ else
+ rm -rf $build_config_dir
+ git clone $BUILD_CONFIG_REPO -b $BUILD_CONFIG_BRANCH
+ fi
fi
-. android-build-configs/$BUILD_CONFIG_FILENAME
+# Should contain at least: {LOCAL_,}MANIFEST_{URL,BRANCH}
+# Optionally: REPO_SEED_DIR, PATCHSETS
+# And other configuration variables used in the scripts
+. $build_config_dir/$BUILD_CONFIG_FILENAME
: ${MANIFEST_URL:=https://android.googlesource.com/platform/manifest}
@@ -54,11 +94,6 @@ fi
mkdir -p android
cd android/
-# setup tmpfs since we have enough free memory
-# The default is half of the memory (size=50%)
-mkdir -p out/target/product
-sudo mount -t tmpfs tmpfs out/target/product
-
: ${MAKE_TARGETS:=droidcore}
echo "SYNCING CODE"
@@ -117,11 +152,14 @@ fi
repo manifest -r -o "$WORKSPACE/pinned-manifest.xml"
# Configure ccache
-USE_CCACHE=1
-CCACHE_DIR=$base_dir/.ccache
-CCACHE_SLOPPINESS=file_macro,include_file_mtime,time_macros
-export USE_CCACHE CCACHE_DIR CCACHE_SLOPPINESS
-ccache -M 50G
+export USE_CCACHE=1
+export CCACHE_SLOPPINESS=file_macro,include_file_mtime,time_macros
+# In local mode, if a configuration already exists, do not override the ccache
+# path or its configuration
+if [[ $JENKINS_MODE || ! $CCACHE_DIR || ! -f $CCACHE_DIR/ccache.conf ]]; then
+ export CCACHE_DIR=$base_dir/.ccache
+ ccache -M 50G
+fi
if [[ $PATCHSETS ]]; then
for i in $PATCHSETS; do
@@ -150,3 +188,12 @@ echo "BUILDING CODE"
#Clean previous build artifacts
rm -rf out/host/
+
+if [[ $NO_TMPFS_TARGET_PRODUCT ]]; then
+ rm -rf out/target
+else
+ # setup tmpfs since we have enough free memory
+ # The default is half of the memory (size=50%)
+ mkdir -p out/target/product
+ sudo mount -t tmpfs tmpfs out/target/product
+fi
diff --git a/test-art-host-test.sh b/test-art-host-test.sh
index bfaf69e..e94fc68 100755
--- a/test-art-host-test.sh
+++ b/test-art-host-test.sh
@@ -1,8 +1,9 @@
#!/bin/bash
-. $PWD/setup-android.sh
-sudo chmod -R 777 /tmp/
-sudo umount -f out/target/product
+# We do not use a tmpfs out/target/product in this test
+NO_TMPFS_TARGET_PRODUCT=y
+. $PWD/setup-android.sh
+[[ $JENKINS_MODE ]] && sudo chmod 1777 /tmp
: ${TEST_ART_COMMAND:=test-art-target}
TEST_ART_OUTPUT_DIR=$WORKSPACE/$TEST_ART_COMMAND/
diff --git a/test-art-target-test.sh b/test-art-target-test.sh
index 9b3d69c..049716b 100755
--- a/test-art-target-test.sh
+++ b/test-art-target-test.sh
@@ -1,8 +1,9 @@
#!/bin/bash
-. $PWD/setup-android.sh
-sudo chmod -R 777 /tmp/
-sudo umount -f out/target/product
+# We do not use a tmpfs out/target/product in this test
+NO_TMPFS_TARGET_PRODUCT=y
+. $PWD/setup-android.sh
+[[ $JENKINS_MODE ]] && sudo chmod 1777 /tmp
TEST_ART_COMMAND="test-art-target"
TEST_ART_OUTPUT_DIR=$WORKSPACE/$TEST_ART_COMMAND/
@@ -11,9 +12,9 @@ MAKE_TARGETS=$TEST_ART_COMMAND
mkdir -p $WORKSPACE/$TEST_ART_COMMAND/
if [[ ! -e ./art/tools/buildbot-build.sh ]]; then
-wget https://android-git.linaro.org/gitweb/platform/art.git/blob_plain/refs/heads/master:/tools/buildbot-build.sh -O ./art/tools/buildbot-build.sh
-sed -i "s/build-art-target-tests/build-art-target/g" ./art/tools/buildbot-build.sh
-chmod a+x ./art/tools/buildbot-build.sh
+ wget https://android-git.linaro.org/gitweb/platform/art.git/blob_plain/refs/heads/master:/tools/buildbot-build.sh -O ./art/tools/buildbot-build.sh
+ sed -i "s/build-art-target-tests/build-art-target/g" ./art/tools/buildbot-build.sh
+ chmod a+x ./art/tools/buildbot-build.sh
fi
MAKE_START=$(date +%s.%N)
@@ -24,7 +25,9 @@ export CUSTOM_TARGET_LINKER=/data/local/tmp/system/bin/linker64
export ANDROID_PRODUCT_OUT=$PWD/out/target/product/armv8/
export TARGET_PRODUCT=armv8
time ./art/tools/buildbot-build.sh -j12 --target
-sudo out/host/linux-x86/bin/adb start-server
+# Build servers do not necessarily have up to date udev rules, start adb-server
+# as root to avoid the issue
+[[ $JENKINS_MODE ]] && sudo out/host/linux-x86/bin/adb start-server
adb shell rm -rf /data/local/tmp /data/art-test /data/nativetest
./art/tools/setup-buildbot-device.sh