diff options
author | Artem Serov <artem.serov@linaro.org> | 2016-08-31 19:25:10 +0100 |
---|---|---|
committer | Artem Serov <artem.serov@linaro.org> | 2016-09-09 13:43:02 +0100 |
commit | c591c7d28bd1fd0ca8f12fe3d8a988916e504b98 (patch) | |
tree | ba25e95c7f13c575be81ac1b54da73366cca8ab4 | |
parent | 37ca7af17d04adad2dfa7a094becb0bfd5a609a4 (diff) | |
download | art-build-scripts-c591c7d28bd1fd0ca8f12fe3d8a988916e504b98.tar.gz |
Support a single test mode.
Change-Id: I2ced11d72985dc259daa627cdfd8ec3a4acb5853
-rwxr-xr-x | tests/test_art_target.sh | 79 |
1 files changed, 64 insertions, 15 deletions
diff --git a/tests/test_art_target.sh b/tests/test_art_target.sh index 5bf7a26a..d5029602 100755 --- a/tests/test_art_target.sh +++ b/tests/test_art_target.sh @@ -30,6 +30,7 @@ init_options() { options["libcore"]="false" options["optimizing"]="false" options["valgrind"]="false" + options["single_test"]="" } set_default_options() { @@ -58,7 +59,8 @@ validate_options() { # Check that at least one test has been selected. if ! ${options["gtests"]} && ! ${options["optimizing"]} \ && ! ${options["interpreter"]} && ! ${options["jit"]} \ - && ! ${options["libcore"]} && ! ${options["jdwp"]}; then + && ! ${options["libcore"]} && ! ${options["jdwp"]} \ + && [[ -z ${options["single_test"]} ]]; then log E "Please select at least one of the \"Tests\" to be run or use --default." log E "See the options ( -h | --help ) for more info." exit 1 @@ -73,6 +75,15 @@ validate_options() { fi } +set_single_test() { + if [[ $# -eq 0 || ! "$1" =~ ^test ]]; then + log E "Please provide a correct test for single_test mode." + log E "See the options ( -h | --help ) for more info." + exit 1 + fi + + set_option_string "single_test" "$1" +} set_option() { local current_option=${1#"--"} @@ -87,6 +98,19 @@ set_option() { fi } +set_option_string() { + local current_option=${1#"--"} + # shellcheck disable=SC2144 + # shellcheck disable=SC2102 + if [[ -v options[${current_option}] ]]; then + options[${current_option}]="$2" + else + # There might be something wrong with the option parser since this option + # does not have a default. + abort + fi +} + dump_options() { log I "Running tests with the following configuration:" for key in "${!options[@]}"; do @@ -116,12 +140,13 @@ usage() { log I " --keep_failures - keep failing tests around (useful for debugging)." log I "-------------------------------------------" log I "Tests:" - log I " --gtests - run gtest tests." - log I " --optimizing - run optimizing tests." - log I " --interpreter - run interpreter tests." - log I " --jit - run jit tests." - log I " --libcore - run libcore tests." - log I " --jdwp - run jdwp tests." + log I " --gtests - run gtest tests." + log I " --optimizing - run optimizing tests." + log I " --interpreter - run interpreter tests." + log I " --jit - run jit tests." + log I " --libcore - run libcore tests." + log I " --jdwp - run jdwp tests." + log I " --single_test <test> - run specified test only" log I "-------------------------------------------" log I "Default Configuration (also used by Jenkins):" log I " --default - default test configuration, also used by jenkins." @@ -156,6 +181,11 @@ arguments_parser() { --default) set_default_options ;; + # Single test: + --single_test) + shift + set_single_test "$@" + ;; *) log E "Invalid option: $1" exit 1 @@ -184,6 +214,20 @@ set_environment() { fi } +run_test_unwrapped() { + # Get the No. of CPUs. + local target_cpu_count=$(safe adb_shell_strip grep -c "^processor" /proc/cpuinfo) + + # Android scripts don't play nice with nounset (error out on expansion of unset variables). + disable_error_on_unset_expansion + + # Adding dist will filter out time sensitive tests such as 055-enum-performance. + make "-j${target_cpu_count}" "$1" "dist" + local -r return_code=$? + enable_error_on_unset_expansion + return ${return_code} +} + # Build (run) a test target using the Android build system. # If a test failed, add it to the list of failed tests. # Arguments: @@ -200,15 +244,8 @@ run_test() { return fi - # Get the No. of CPUs. - local target_cpu_count=$(safe adb_shell_strip grep -c "^processor" /proc/cpuinfo) - - # Android scripts don't play nice with nounset (error out on expansion of unset variables). - disable_error_on_unset_expansion - # Adding dist will filter out time sensitive tests such as 055-enum-performance. - make "-j${target_cpu_count}" "$1" "dist" + run_test_unwrapped "$1" local -r return_code=$? - enable_error_on_unset_expansion end_adb_section "$2_$3" "${return_code}" if ! ${options["keep_going"]} && [[ ${return_code} -ne 0 ]]; then @@ -218,6 +255,13 @@ run_test() { fi } +test_single() { + start_adb_section "TEST_SINGLE_$1" + + run_test_unwrapped "$2" + end_adb_section "TEST_SINGLE_$1" "$?" +} + test_gtest() { local test_target="" @@ -306,6 +350,11 @@ main() { sync_target "${bits}" # Start testing. + if [[ -n ${options["single_test"]} ]]; then + test_single "${bits}" "${options["single_test"]}" + continue + fi + test_gtest "${bits}" test_optimizing "${bits}" test_interpreter "${bits}" |