1#!/bin/bash 2 3set -e 4 5skip_build= 6skip_host= 7skip_target= 8skip_cleanup= 9for arg; do 10 case "$arg" in 11 --skip-build) skip_build=true ;; 12 --skip-host) skip_host=true ;; 13 --skip-target) skip_target=true ;; 14 --skip-cleanup) skip_cleanup=true ;; 15 *) break ;; 16 esac 17 shift 18done 19 20echo_and_run() { 21 echo "$@" 22 eval "$@" 23} 24 25device_test_root=/data/local/tmp/libnativebridge-test 26 27vars="$(build/soong/soong_ui.bash --dumpvars-mode --vars='HOST_OUT PRODUCT_OUT TARGET_ARCH')" 28# Assign to a variable and eval that, since bash ignores any error status 29# from the command substitution if it's directly on the eval line. 30eval $vars 31 32if [ -z "$skip_build" ]; then 33 rm -rf $HOST_OUT/nativetest{,64} $PRODUCT_OUT/data/nativetest{,64}/art/$TARGET_ARCH 34 echo_and_run build/soong/soong_ui.bash --make-mode MODULES-IN-art-libnativebridge-tests 35fi 36 37if [ -z "$skip_host" ]; then 38 for build_dir in $HOST_OUT/nativetest{,64}/ ; do 39 if [ ! -d $build_dir ]; then 40 echo "Skipping missing $build_dir" 41 else 42 for test_path in $build_dir/*/* ; do 43 test_rel_path=${test_path#${build_dir}/} 44 echo_and_run \( cd $build_dir \; $test_rel_path $* \) 45 done 46 fi 47 done 48fi 49 50if [ -z "$skip_target" ]; then 51 adb root 52 adb wait-for-device 53 54 for build_dir in $PRODUCT_OUT/data/nativetest{,64}/art/$TARGET_ARCH ; do 55 if [ ! -d $build_dir ]; then 56 echo "Skipping missing $build_dir" 57 else 58 test_dir=$device_test_root/$TARGET_ARCH 59 60 echo_and_run adb shell rm -rf $test_dir 61 echo_and_run adb push $build_dir $test_dir 62 63 for test_path in $build_dir/*/* ; do 64 test_rel_path=${test_path#${build_dir}/} 65 echo_and_run adb shell cd $test_dir '\;' LD_LIBRARY_PATH=. $test_rel_path $* 66 done 67 fi 68 done 69 70 if [ -z "$skip_cleanup" ]; then 71 echo_and_run adb shell rm -rf $device_test_root 72 fi 73fi 74 75echo "No errors" 76