From 0bef410319d3a2d32d9f85254796b828f363ed51 Mon Sep 17 00:00:00 2001 From: Roland Levillain Date: Thu, 28 Feb 2019 20:49:11 +0000 Subject: Refactor unit test for Android Runtime (Boot) device configuration flags. This is in preparation of checking other device configuration flags. Test: core/jni/runtime_native_boot-flags-test.sh Bug: 72446017 Bug: 120794191 Bug: 123754583 Bug: 119800099 Change-Id: I14d6defe5f7e9fcf2f3dd27a4d0fae81f2aec596 --- core/jni/runtime_native_boot-flags-test.sh | 53 ++++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 13 deletions(-) diff --git a/core/jni/runtime_native_boot-flags-test.sh b/core/jni/runtime_native_boot-flags-test.sh index 01f37f07e5ca..a39078f61039 100755 --- a/core/jni/runtime_native_boot-flags-test.sh +++ b/core/jni/runtime_native_boot-flags-test.sh @@ -172,14 +172,16 @@ function check_no_zygote_gc_runtime_option { done } -# test_android_runtime_flag FLAG VALUE GC_RUNTIME_OPTION -# ------------------------------------------------------ -# Test device configuration FLAG with VALUE. Check that GC_RUNTIME_OPTION is -# passed as GC Runtime option by the zygote. +# test_android_runtime_flag FLAG VALUE CHECK_EFFECT CHECK_NO_EFFECT +# ----------------------------------------------------------------- +# Test device configuration FLAG with VALUE. CHECK_EFFECT and CHECK_NO_EFFECT +# are functions that are passed a context as sole argument and that respectively +# check the effect or the absence of effect of the flag. function test_android_runtime_flag { local flag=$1 local value=$2 - local gc_runtime_option=$3 + local check_effect=$3 + local check_no_effect=$4 # Persistent system property (set after a reboot) associated with the device # configuration flag. @@ -193,26 +195,26 @@ function test_android_runtime_flag { sleep 3 # Check that both the device configuration flag and the associated system - # property are set, but that the zygote hasn't had the flag passed to it as a - # GC runtime option (as we haven't rebooted yet). + # property are set, but that flag has not produced an effect on the system (as + # we haven't rebooted yet). local context="Flag set, before reboot" check_device_config_flag "$context" "$flag" "$value" check_system_property "$context" "$prop" "$value" - check_no_zygote_gc_runtime_option "$context" "$gc_runtime_option" + $check_no_effect "$context" # Reboot device for the flag value to take effect. reboot_and_wait_for_device context="Flag set, after 1st reboot" check_device_config_flag "$context" "$flag" "$value" check_system_property "$context" "$prop" "$value" - check_zygote_gc_runtime_option "$context" "$gc_runtime_option" + $check_effect "$context" # Reboot device a second time and check that the state has persisted. reboot_and_wait_for_device context="Flag set, after 2nd reboot" check_device_config_flag "$context" "$flag" "$value" check_system_property "$context" "$prop" "$value" - check_zygote_gc_runtime_option "$context" "$gc_runtime_option" + $check_effect "$context" say "Unsetting device configuration flag..." adb shell device_config delete "$namespace" "$flag" >/dev/null @@ -224,9 +226,13 @@ function test_android_runtime_flag { context="Flag unset, after 3rd reboot" check_no_device_config_flag "$context" "$flag" check_no_system_property "$context" "$prop" - check_no_zygote_gc_runtime_option "$context" "$gc_runtime_option" + $check_no_effect "$context" } + +# Pre-test actions. +# ================= + # Enumerate Zygote processes. case $(adb shell getprop ro.zygote) in (zygote32) zygotes="zygote";; @@ -235,8 +241,29 @@ case $(adb shell getprop ro.zygote) in esac # Test "enable_generational_cc" flag values. -test_android_runtime_flag enable_generational_cc false nogenerational_cc -test_android_runtime_flag enable_generational_cc true generational_cc +# ========================================== + +function check_nogenerational_cc { + check_zygote_gc_runtime_option "$1" nogenerational_cc +} +function check_no_nogenerational_cc { + check_no_zygote_gc_runtime_option "$1" nogenerational_cc +} + +function check_generational_cc { + check_zygote_gc_runtime_option "$1" generational_cc +} +function check_no_generational_cc { + check_no_zygote_gc_runtime_option "$1" generational_cc +} + +test_android_runtime_flag \ + enable_generational_cc false check_nogenerational_cc check_no_nogenerational_cc +test_android_runtime_flag \ + enable_generational_cc true check_generational_cc check_no_generational_cc + +# Post-test actions. +# ================== if [[ "$exit_status" -eq 0 ]]; then banner "All tests passed." -- cgit v1.2.3-59-g8ed1b From b7bb0a134cbe35b92b42acfd73f1d9a97750c5b7 Mon Sep 17 00:00:00 2001 From: Roland Levillain Date: Thu, 28 Feb 2019 20:52:41 +0000 Subject: Check Android Runtime (Boot) device configuration flag `enable_apex_image`. Test: core/jni/runtime_native_boot-flags-test.sh Bug: 119800099 Change-Id: I10c6ed68eceebef14207bc38cab4e96fb2f75939 --- core/jni/runtime_native_boot-flags-test.sh | 50 ++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/core/jni/runtime_native_boot-flags-test.sh b/core/jni/runtime_native_boot-flags-test.sh index a39078f61039..a5d7a5a9ca61 100755 --- a/core/jni/runtime_native_boot-flags-test.sh +++ b/core/jni/runtime_native_boot-flags-test.sh @@ -172,6 +172,32 @@ function check_no_zygote_gc_runtime_option { done } +# check_android_runtime_message CONTEXT MESSAGE +# --------------------------------------------- +# Return whether AndroidRuntime generated MESSAGE in logcat. Use CONTEXT in +# logging. +function check_android_runtime_message { + local context=$1 + local message=$2 + + say "[$context] Check that AndroidRuntime generated expected message in logcat..." + adb logcat -d -s AndroidRuntime | grep -F -q "$message" \ + || fail "Found no message \"$message\" generated by AndroidRuntime" +} + +# check_no_android_runtime_message CONTEXT MESSAGE +# ------------------------------------------------ +# Return whether AndroidRuntime did not generate MESSAGE in logcat. Use CONTEXT +# in logging. +function check_no_android_runtime_message { + local context=$1 + local message=$2 + + say "[$context] Check that AndroidRuntime did not generate unexpected message in logcat..." + adb logcat -d -s AndroidRuntime | grep -F -q -v "$message" \ + || fail "Found message \"$message\" generated by AndroidRuntime" +} + # test_android_runtime_flag FLAG VALUE CHECK_EFFECT CHECK_NO_EFFECT # ----------------------------------------------------------------- # Test device configuration FLAG with VALUE. CHECK_EFFECT and CHECK_NO_EFFECT @@ -262,6 +288,30 @@ test_android_runtime_flag \ test_android_runtime_flag \ enable_generational_cc true check_generational_cc check_no_generational_cc +# Test "enable_apex_image" flag values. +# ===================================== + +default_boot_image_message="Using default boot image" +function check_default_boot_image { + check_android_runtime_message "$1" "$default_boot_image_message" +} +function check_no_default_boot_image { + check_no_android_runtime_message "$1" "$default_boot_image_message" +} + +apex_boot_image_message="Using Apex boot image: '-Ximage:/system/framework/apex.art'" +function check_apex_boot_image { + check_android_runtime_message "$1" "$apex_boot_image_message" +} +function check_no_apex_boot_image { + check_no_android_runtime_message "$1" "$apex_boot_image_message" +} + +test_android_runtime_flag \ + enable_apex_image false check_default_boot_image check_no_default_boot_image +test_android_runtime_flag \ + enable_apex_image true check_apex_boot_image check_no_apex_boot_image + # Post-test actions. # ================== -- cgit v1.2.3-59-g8ed1b