Mark Salyzyn | b304f6d | 2017-08-04 13:35:51 -0700 | [diff] [blame] | 1 | #! /bin/bash |
| 2 | # |
| 3 | # Bootstat boot reason tests |
| 4 | # |
| 5 | # throughout testing: |
| 6 | # - manual tests can only run on eng/userdebug builds |
| 7 | # - watch adb logcat -b all -d -s bootstat |
| 8 | # - watch adb logcat -b all -d | audit2allow |
| 9 | # - wait until screen is up, boot has completed, can mean wait for |
| 10 | # sys.boot_completed=1 and sys.logbootcomplete=1 to be true |
| 11 | # |
| 12 | # All test frames, and nothing else, must be function names prefixed and |
| 13 | # specifiged with the pattern 'test_<test>() {' as this is also how the |
| 14 | # script discovers the full list of tests by inspecting its own code. |
| 15 | # |
| 16 | |
| 17 | # Helper variables |
| 18 | |
| 19 | SPACE=" " |
| 20 | ESCAPE="" |
| 21 | TAB=" " |
| 22 | GREEN="${ESCAPE}[38;5;40m" |
| 23 | RED="${ESCAPE}[38;5;196m" |
| 24 | NORMAL="${ESCAPE}[0m" |
| 25 | |
| 26 | # Helper functions |
| 27 | |
| 28 | [ "USAGE: inFastboot |
| 29 | |
| 30 | Returns: true if device is in fastboot mode" ] |
| 31 | inFastboot() { |
| 32 | fastboot devices | grep "^${ANDROID_SERIAL}[${SPACE}${TAB}]" > /dev/null |
| 33 | } |
| 34 | |
Mark Salyzyn | 6290982 | 2017-10-09 09:27:16 -0700 | [diff] [blame^] | 35 | [ "USAGE: inAdb |
| 36 | |
| 37 | Returns: true if device is in adb mode" ] |
| 38 | inAdb() { |
| 39 | adb devices | grep -v 'List of devices attached' | grep "^${ANDROID_SERIAL}[${SPACE}${TAB}]" > /dev/null |
| 40 | } |
| 41 | |
| 42 | [ "USAGE: hasPstore |
| 43 | |
| 44 | Returns: true if device (likely) has pstore data" ] |
| 45 | hasPstore() { |
| 46 | if inAdb && [ 0 -eq `adb shell su root ls /sys/fs/pstore | wc -l` ]; then |
| 47 | false |
| 48 | fi |
| 49 | } |
| 50 | |
| 51 | [ "USAGE: isDebuggable |
| 52 | |
| 53 | Returns: true if device is (likely) a debug build" ] |
| 54 | isDebuggable() { |
| 55 | if inAdb && [ 1 -ne `adb shell getprop ro.debuggable` ]; then |
| 56 | false |
| 57 | fi |
| 58 | } |
| 59 | |
| 60 | [ "USAGE: checkDebugBuild |
| 61 | |
| 62 | Returns: true if device is a userdebug or eng release" ] |
| 63 | checkDebugBuild() { |
| 64 | if isDebuggable; then |
| 65 | echo "INFO: '${TEST}' test requires userdebug build" |
| 66 | else |
| 67 | echo "ERROR: '${TEST}' test requires userdebug build, skipping FAILURE" |
| 68 | false |
| 69 | fi >&2 |
| 70 | } |
| 71 | |
| 72 | [ "USAGE: enterPstore |
| 73 | |
| 74 | Prints a warning string requiring functional pstore |
| 75 | |
| 76 | Returns: pstore_ok variable set to true or false" ] |
| 77 | enterPstore() { |
| 78 | if hasPstore; then |
| 79 | echo "INFO: '${TEST}' test requires functional and reliable pstore" |
| 80 | pstore_ok=true |
| 81 | else |
| 82 | echo "WARNING: '${TEST}' test requires functional pstore" |
| 83 | pstore_ok=false |
| 84 | fi >&2 |
| 85 | ${pstore_ok} |
| 86 | } |
| 87 | |
| 88 | [ "USAGE: exitPstore |
| 89 | |
| 90 | Prints an error string requiring functional pstore |
| 91 | |
| 92 | Returns: clears error if pstore dysfunctional" ] |
| 93 | exitPstore() { |
| 94 | save_ret=${?} |
| 95 | if [ ${save_ret} != 0 ]; then |
| 96 | if hasPstore; then |
| 97 | return ${save_ret} |
| 98 | fi |
| 99 | if [ true = ${pstore_ok} ]; then |
| 100 | echo "WARNING: '${TEST}' test requires functional pstore" |
| 101 | return ${save_ret} |
| 102 | fi |
| 103 | echo "ERROR: '${TEST}' test requires functional pstore, skipping FAILURE" |
| 104 | fi >&2 |
| 105 | } |
| 106 | |
Mark Salyzyn | b304f6d | 2017-08-04 13:35:51 -0700 | [diff] [blame] | 107 | [ "USAGE: format_duration <seconds> |
| 108 | |
| 109 | human readable output whole seconds, whole minutes or mm:ss" ] |
| 110 | format_duration() { |
| 111 | if [ -z "${1}" ]; then |
| 112 | echo unknown |
| 113 | return |
| 114 | fi |
| 115 | seconds=`expr ${1} % 60` |
| 116 | minutes=`expr ${1} / 60` |
| 117 | if [ 0 -eq ${minutes} ]; then |
| 118 | if [ 1 -eq ${1} ]; then |
| 119 | echo 1 second |
| 120 | return |
| 121 | fi |
| 122 | echo ${1} seconds |
| 123 | return |
| 124 | elif [ 60 -eq ${1} ]; then |
| 125 | echo 1 minute |
| 126 | return |
| 127 | elif [ 0 -eq ${seconds} ]; then |
| 128 | echo ${minutes} minutes |
| 129 | return |
| 130 | fi |
| 131 | echo ${minutes}:`expr ${seconds} / 10``expr ${seconds} % 10` |
| 132 | } |
| 133 | |
| 134 | wait_for_screen_timeout=900 |
| 135 | [ "USAGE: wait_for_screen [-n] [TIMEOUT] |
| 136 | |
| 137 | -n - echo newline at exit |
| 138 | TIMEOUT - default `format_duration ${wait_for_screen_timeout}`" ] |
| 139 | wait_for_screen() { |
| 140 | exit_function=true |
| 141 | if [ X"-n" = X"${1}" ]; then |
| 142 | exit_function=echo |
| 143 | shift |
| 144 | fi |
| 145 | timeout=${wait_for_screen_timeout} |
| 146 | if [ ${#} -gt 0 ]; then |
| 147 | timeout=${1} |
| 148 | shift |
| 149 | fi |
| 150 | counter=0 |
| 151 | while true; do |
Mark Salyzyn | 6290982 | 2017-10-09 09:27:16 -0700 | [diff] [blame^] | 152 | if inFastboot; then |
| 153 | fastboot reboot |
| 154 | elif inAdb; then |
| 155 | if [ 0 != ${counter} ]; then |
| 156 | adb wait-for-device </dev/null >/dev/null 2>/dev/null |
| 157 | fi |
| 158 | if [ -n "`adb shell getprop sys.boot.reason </dev/null 2>/dev/null`" ] |
| 159 | then |
| 160 | vals=`adb shell getprop </dev/null 2>/dev/null | |
| 161 | sed -n 's/[[]sys[.]\(boot_completed\|logbootcomplete\)[]]: [[]\([01]\)[]]$/\1=\2/p'` |
| 162 | if [ "${vals}" = "`echo boot_completed=1 ; echo logbootcomplete=1`" ] |
| 163 | then |
| 164 | break |
| 165 | fi |
| 166 | if [ "${vals}" = "`echo logbootcomplete=1 ; echo boot_completed=1`" ] |
| 167 | then |
| 168 | break |
| 169 | fi |
| 170 | fi |
Mark Salyzyn | b304f6d | 2017-08-04 13:35:51 -0700 | [diff] [blame] | 171 | fi |
| 172 | counter=`expr ${counter} + 1` |
| 173 | if [ ${counter} -gt ${timeout} ]; then |
| 174 | ${exit_function} |
| 175 | echo "ERROR: wait_for_screen() timed out (`format_duration ${timeout}`)" >&2 |
| 176 | return 1 |
| 177 | fi |
Mark Salyzyn | 6290982 | 2017-10-09 09:27:16 -0700 | [diff] [blame^] | 178 | sleep 1 |
Mark Salyzyn | b304f6d | 2017-08-04 13:35:51 -0700 | [diff] [blame] | 179 | done |
| 180 | ${exit_function} |
| 181 | } |
| 182 | |
| 183 | [ "USAGE: EXPECT_EQ <lval> <rval> [message] |
| 184 | |
| 185 | Returns true if (regex) lval matches rval" ] |
| 186 | EXPECT_EQ() { |
| 187 | lval="${1}" |
| 188 | rval="${2}" |
| 189 | shift 2 |
| 190 | if ! ( echo X"${rval}" | grep '^X'"${lval}"'$' >/dev/null 2>/dev/null ); then |
| 191 | echo "ERROR: expected \"${lval}\" got \"${rval}\"" >&2 |
| 192 | if [ -n "${*}" ] ; then |
| 193 | echo " ${*}" >&2 |
| 194 | fi |
| 195 | return 1 |
| 196 | fi |
| 197 | if [ -n "${*}" ] ; then |
| 198 | if [ X"${lval}" != X"${rval}" ]; then |
| 199 | echo "INFO: ok \"${lval}\"(=\"${rval}\") ${*}" >&2 |
| 200 | else |
| 201 | echo "INFO: ok \"${lval}\" ${*}" >&2 |
| 202 | fi |
| 203 | fi |
| 204 | return 0 |
| 205 | } |
| 206 | |
| 207 | [ "USAGE: EXPECT_PROPERTY <prop> <value> |
| 208 | |
| 209 | Returns true if current return (regex) value is true and the result matches" ] |
| 210 | EXPECT_PROPERTY() { |
| 211 | save_ret=${?} |
| 212 | property="${1}" |
| 213 | value="${2}" |
| 214 | shift 2 |
| 215 | val=`adb shell getprop ${property} 2>&1` |
| 216 | EXPECT_EQ "${value}" "${val}" for Android property ${property} || |
| 217 | save_ret=${?} |
| 218 | return ${save_ret} |
| 219 | } |
| 220 | |
| 221 | [ "USAGE: report_bootstat_logs <expected> ... |
| 222 | |
| 223 | if not prefixed with a minus (-), <expected> will become a series of expected |
| 224 | matches: |
| 225 | |
| 226 | bootstat: Canonical boot reason: <expected_property_value> |
| 227 | |
| 228 | If prefixed with a minus, <expected> will look for an exact match after |
| 229 | removing the minux prefix. All expected content is _dropped_ from the output |
| 230 | and in essence forms a known blacklist, unexpected content will show. |
| 231 | |
| 232 | Report any logs, minus a known blacklist, preserve the current exit status" ] |
| 233 | report_bootstat_logs() { |
| 234 | save_ret=${?} |
| 235 | match= |
Mark Salyzyn | 6290982 | 2017-10-09 09:27:16 -0700 | [diff] [blame^] | 236 | for i in "${@}"; do |
Mark Salyzyn | b304f6d | 2017-08-04 13:35:51 -0700 | [diff] [blame] | 237 | if [ X"${i}" != X"${i#-}" ] ; then |
| 238 | match="${match} |
| 239 | ${i#-}" |
| 240 | else |
| 241 | match="${match} |
| 242 | bootstat: Canonical boot reason: ${i}" |
| 243 | fi |
| 244 | done |
| 245 | adb logcat -b all -d | |
Mark Salyzyn | 08b0256 | 2017-09-18 10:07:07 -0700 | [diff] [blame] | 246 | grep bootstat[^e] | |
Mark Salyzyn | b304f6d | 2017-08-04 13:35:51 -0700 | [diff] [blame] | 247 | grep -v -F "bootstat: Service started: /system/bin/bootstat --record_boot_complete${match} |
| 248 | bootstat: Failed to read /data/misc/bootstat/post_decrypt_time_elapsed: No such file or directory |
| 249 | bootstat: Failed to parse boot time record: /data/misc/bootstat/post_decrypt_time_elapsed |
| 250 | bootstat: Service started: /system/bin/bootstat --record_boot_reason |
| 251 | bootstat: Service started: /system/bin/bootstat --record_time_since_factory_reset |
| 252 | bootstat: Service started: /system/bin/bootstat -l |
| 253 | bootstat: Battery level at shutdown 100% |
| 254 | bootstat: Battery level at startup 100% |
| 255 | init : Parsing file /system/etc/init/bootstat.rc... |
| 256 | init : processing action (post-fs-data) from (/system/etc/init/bootstat.rc |
| 257 | init : processing action (boot) from (/system/etc/init/bootstat.rc |
| 258 | init : processing action (ro.boot.bootreason=*) from (/system/etc/init/bootstat.rc |
| 259 | init : processing action (sys.boot_completed=1 && sys.logbootcomplete=1) from (/system/etc/init/bootstat.rc |
Mark Salyzyn | 557a9d4 | 2017-09-15 13:02:19 -0700 | [diff] [blame] | 260 | (/system/bin/bootstat --record_boot_complete --record_boot_reason --record_time_since_factory_reset -l)' |
| 261 | (/system/bin/bootstat -r post_decrypt_time_elapsed)' |
Mark Salyzyn | b304f6d | 2017-08-04 13:35:51 -0700 | [diff] [blame] | 262 | init : Command 'exec - system log -- /system/bin/bootstat --record_boot_complete' action=sys.boot_completed=1 && sys.logbootcomplete=1 (/system/etc/init/bootstat.rc: |
| 263 | init : Command 'exec - system log -- /system/bin/bootstat --record_boot_reason' action=sys.boot_completed=1 && sys.logbootcomplete=1 (/system/etc/init/bootstat.rc: |
| 264 | init : Command 'exec - system log -- /system/bin/bootstat --record_time_since_factory_reset' action=sys.boot_completed=1 && sys.logbootcomplete=1 (/system/etc/init/bootstat.rc: |
| 265 | (/system/bin/bootstat --record_boot_complete)'... |
| 266 | (/system/bin/bootstat --record_boot_complete)' (pid${SPACE} |
| 267 | (/system/bin/bootstat --record_boot_reason)'... |
| 268 | (/system/bin/bootstat --record_boot_reason)' (pid${SPACE} |
| 269 | (/system/bin/bootstat --record_time_since_factory_reset)'... |
| 270 | (/system/bin/bootstat --record_time_since_factory_reset)' (pid${SPACE} |
| 271 | (/system/bin/bootstat -l)'... |
| 272 | (/system/bin/bootstat -l)' (pid " | |
| 273 | grep -v 'bootstat: Unknown boot reason: $' # Hikey Special |
| 274 | return ${save_ret} |
| 275 | } |
| 276 | |
| 277 | [ "USAGE: start_test [message] |
| 278 | |
| 279 | Record start of test, preserve exit status" ] |
| 280 | start_test() { |
| 281 | save_ret=${?} |
| 282 | START=`date +%s` |
| 283 | echo "${GREEN}[ RUN ]${NORMAL} ${TEST} ${*}" |
| 284 | return ${save_ret} |
| 285 | } |
| 286 | |
| 287 | [ "USAGE: end_test [message] |
| 288 | |
| 289 | Document duration and success of test, preserve exit status" ] |
| 290 | end_test() { |
| 291 | save_ret=${?} |
| 292 | END=`date +%s` |
| 293 | duration=`expr ${END} - ${START} 2>/dev/null` |
| 294 | [ 0 = ${duration} ] || |
Mark Salyzyn | 6290982 | 2017-10-09 09:27:16 -0700 | [diff] [blame^] | 295 | echo "INFO: '${TEST}' test duration `format_duration ${duration}`" >&2 |
Mark Salyzyn | b304f6d | 2017-08-04 13:35:51 -0700 | [diff] [blame] | 296 | if [ ${save_ret} = 0 ]; then |
| 297 | echo "${GREEN}[ OK ]${NORMAL} ${TEST} ${*}" |
| 298 | else |
| 299 | echo "${RED}[ FAILED ]${NORMAL} ${TEST} ${*}" |
| 300 | fi |
| 301 | return ${save_ret} |
| 302 | } |
| 303 | |
| 304 | [ "USAGE: wrap_test <test> [message] |
| 305 | |
| 306 | All tests below are wrapped with this helper" ] |
| 307 | wrap_test() { |
| 308 | if [ -z "${1}" -o X"nothing" = X"${1}" ]; then |
| 309 | return |
| 310 | fi |
| 311 | TEST=${1} |
| 312 | shift |
| 313 | start_test ${1} |
| 314 | eval test_${TEST} |
| 315 | end_test ${2} |
| 316 | } |
| 317 | |
| 318 | [ "USAGE: validate_property <property> |
| 319 | |
| 320 | Check property for CTS compliance with our expectations. Return a cleansed |
| 321 | string representing what is acceptable. |
| 322 | |
| 323 | NB: must roughly match heuristics in system/core/bootstat/bootstat.cpp" ] |
| 324 | validate_property() { |
| 325 | var=`adb shell getprop ${1} 2>&1` |
| 326 | var=`echo -n ${var} | |
| 327 | tr '[A-Z]' '[a-z]' | |
| 328 | tr ' \f\t\r\n' '_____'` |
| 329 | case ${var} in |
| 330 | watchdog) ;; |
| 331 | watchdog,?*) ;; |
| 332 | kernel_panic) ;; |
| 333 | kernel_panic,?*) ;; |
| 334 | recovery) ;; |
| 335 | recovery,?*) ;; |
| 336 | bootloader) ;; |
| 337 | bootloader,?*) ;; |
| 338 | cold) ;; |
| 339 | cold,?*) ;; |
| 340 | hard) ;; |
| 341 | hard,?*) ;; |
| 342 | warm) ;; |
| 343 | warm,?*) ;; |
| 344 | shutdown) ;; |
| 345 | shutdown,?*) ;; |
| 346 | reboot) ;; |
| 347 | reboot,?*) ;; |
| 348 | # Aliases |
| 349 | *wdog* | *watchdog* ) var="watchdog" ;; |
| 350 | *powerkey* ) var="cold,powerkey" ;; |
| 351 | *panic* | *kernel_panic*) var="kernel_panic" ;; |
| 352 | *thermal*) var="shutdown,thermal" ;; |
| 353 | *s3_wakeup*) var="warm,s3_wakeup" ;; |
| 354 | *hw_reset*) var="hard,hw_reset" ;; |
| 355 | *bootloader*) var="bootloader" ;; |
| 356 | ?*) var="reboot,${var}" ;; |
| 357 | *) var="reboot" ;; |
| 358 | esac |
| 359 | echo ${var} |
| 360 | } |
| 361 | |
| 362 | # |
| 363 | # Actual test frames |
| 364 | # |
| 365 | |
| 366 | [ "USAGE: test_properties |
| 367 | |
| 368 | properties test |
| 369 | - (wait until screen is up, boot has completed) |
| 370 | - adb shell getprop ro.boot.bootreason (bootloader reason) |
| 371 | - adb shell getprop persist.sys.boot.reason (last reason) |
| 372 | - adb shell getprop sys.boot.reason (system reason) |
| 373 | - NB: all should have a value that is compliant with our known set." ] |
| 374 | test_properties() { |
| 375 | wait_for_screen |
| 376 | retval=0 |
| 377 | check_set="ro.boot.bootreason persist.sys.boot.reason sys.boot.reason" |
| 378 | bootloader="" |
| 379 | # NB: this test could fail if performed _after_ optional_factory_reset test |
| 380 | # and will report |
| 381 | # ERROR: expected "reboot" got "" |
| 382 | # for Android property persist.sys.boot.reason |
| 383 | # following is mitigation for the persist.sys.boot.reason, skip it |
| 384 | if [ "reboot,factory_reset" = `validate_property ro.boot_bootreason` ]; then |
| 385 | check_set="ro.boot.bootreason sys.boot.reason" |
| 386 | bootloader="bootloader" |
| 387 | fi |
| 388 | for prop in ${check_set}; do |
| 389 | reason=`validate_property ${prop}` |
| 390 | EXPECT_PROPERTY ${prop} ${reason} || retval=${?} |
| 391 | done |
| 392 | # sys.boot.reason is last for a reason |
| 393 | report_bootstat_logs ${reason} ${bootloader} |
| 394 | return ${retval} |
| 395 | } |
| 396 | |
| 397 | [ "USAGE: test_ota |
| 398 | |
| 399 | ota test |
| 400 | - rm out/.kati_stamp-* out/build_date.txt out/build_number.txt |
| 401 | - rm out/target/product/*/*/*.prop |
| 402 | - rm -r out/target/product/*/obj/ETC/system_build_prop_intermediates |
| 403 | - m |
| 404 | - NB: ro.build.date.utc should update |
| 405 | - fastboot flashall |
| 406 | - (wait until screen is up, boot has completed) |
| 407 | - adb shell getprop sys.boot.reason |
| 408 | - NB: should report ota |
| 409 | |
| 410 | Decision to change the build itself rather than trick bootstat by |
| 411 | rummaging through its data files was made." ] |
| 412 | test_ota() { |
Mark Salyzyn | 6290982 | 2017-10-09 09:27:16 -0700 | [diff] [blame^] | 413 | echo "INFO: expected duration of '${TEST}' test >`format_duration 300`" >&2 |
Mark Salyzyn | b304f6d | 2017-08-04 13:35:51 -0700 | [diff] [blame] | 414 | echo " extended by build and flashing times" >&2 |
| 415 | if [ -z "${TARGET_PRODUCT}" -o \ |
| 416 | -z "${ANDROID_PRODUCT_OUT}" -o \ |
| 417 | -z "${ANDROID_BUILD_TOP}" -o \ |
| 418 | -z "${TARGET_BUILD_VARIANT}" ]; then |
| 419 | echo "ERROR: Missing envsetup.sh and lunch" >&2 |
| 420 | return 1 |
| 421 | fi |
| 422 | rm ${ANDROID_PRODUCT_OUT%/out/*}/out/.kati_stamp-* || |
| 423 | true |
| 424 | rm ${ANDROID_PRODUCT_OUT%/out/*}/out/build_date.txt || |
| 425 | true |
| 426 | rm ${ANDROID_PRODUCT_OUT%/out/*}/out/build_number.txt || |
| 427 | true |
| 428 | rm ${ANDROID_PRODUCT_OUT}/*/*.prop || |
| 429 | true |
| 430 | rm -r ${ANDROID_PRODUCT_OUT}/obj/ETC/system_build_prop_intermediates || |
| 431 | true |
| 432 | pushd ${ANDROID_BUILD_TOP} >&2 |
| 433 | make -j50 >&2 |
| 434 | if [ ${?} != 0 ]; then |
| 435 | popd >&2 |
| 436 | return 1 |
| 437 | fi |
| 438 | if ! inFastboot; then |
| 439 | adb reboot-bootloader >&2 |
| 440 | fi |
| 441 | fastboot flashall >&2 |
| 442 | popd >&2 |
| 443 | wait_for_screen |
| 444 | EXPECT_PROPERTY sys.boot.reason "\(reboot,ota\|bootloader\)" |
Mark Salyzyn | 6290982 | 2017-10-09 09:27:16 -0700 | [diff] [blame^] | 445 | EXPECT_PROPERTY persist.sys.boot.reason bootloader |
Mark Salyzyn | b304f6d | 2017-08-04 13:35:51 -0700 | [diff] [blame] | 446 | report_bootstat_logs reboot,ota bootloader |
| 447 | } |
| 448 | |
| 449 | [ "USAGE: test_optional_ota |
| 450 | |
| 451 | fast and fake (touch build_date on device to make it different)" ] |
| 452 | test_optional_ota() { |
Mark Salyzyn | 6290982 | 2017-10-09 09:27:16 -0700 | [diff] [blame^] | 453 | checkDebugBuild || return |
| 454 | echo "INFO: expected duration of '${TEST}' test ~`format_duration 45`" >&2 |
Mark Salyzyn | b304f6d | 2017-08-04 13:35:51 -0700 | [diff] [blame] | 455 | adb shell su root touch /data/misc/bootstat/build_date >&2 |
| 456 | adb reboot ota |
| 457 | wait_for_screen |
| 458 | EXPECT_PROPERTY sys.boot.reason reboot,ota |
| 459 | EXPECT_PROPERTY persist.sys.boot.reason reboot,ota |
| 460 | report_bootstat_logs reboot,ota |
| 461 | } |
| 462 | |
Mark Salyzyn | 6290982 | 2017-10-09 09:27:16 -0700 | [diff] [blame^] | 463 | [ "USAGE: [TEST=<test>] blind_reboot_test |
Mark Salyzyn | b304f6d | 2017-08-04 13:35:51 -0700 | [diff] [blame] | 464 | |
| 465 | Simple tests helper |
| 466 | - adb reboot <test> |
| 467 | - (wait until screen is up, boot has completed) |
| 468 | - adb shell getprop sys.boot.reason |
Mark Salyzyn | 6290982 | 2017-10-09 09:27:16 -0700 | [diff] [blame^] | 469 | - NB: should report <test>, or reboot,<test> depending on canonical rules |
Mark Salyzyn | b304f6d | 2017-08-04 13:35:51 -0700 | [diff] [blame] | 470 | |
| 471 | We interleave the simple reboot tests between the hard/complex ones |
| 472 | as a means of checking sanity and any persistent side effect of the |
| 473 | other tests." ] |
| 474 | blind_reboot_test() { |
Mark Salyzyn | 6290982 | 2017-10-09 09:27:16 -0700 | [diff] [blame^] | 475 | case ${TEST} in |
| 476 | bootloader | recovery | cold | hard | warm ) reason=${TEST} ;; |
| 477 | *) reason=reboot,${TEST} ;; |
| 478 | esac |
| 479 | echo "INFO: expected duration of '${TEST}' test ~`format_duration 45`" >&2 |
Mark Salyzyn | b304f6d | 2017-08-04 13:35:51 -0700 | [diff] [blame] | 480 | adb reboot ${TEST} |
| 481 | wait_for_screen |
Mark Salyzyn | 6290982 | 2017-10-09 09:27:16 -0700 | [diff] [blame^] | 482 | EXPECT_PROPERTY sys.boot.reason ${reason} |
| 483 | EXPECT_PROPERTY persist.sys.boot.reason ${reason} |
| 484 | report_bootstat_logs ${reason} |
Mark Salyzyn | b304f6d | 2017-08-04 13:35:51 -0700 | [diff] [blame] | 485 | } |
| 486 | |
| 487 | [ "USAGE: test_cold |
| 488 | |
| 489 | cold test |
| 490 | - adb reboot cold |
| 491 | - (wait until screen is up, boot has completed) |
| 492 | - adb shell getprop sys.boot.reason |
| 493 | - NB: should report cold" ] |
| 494 | test_cold() { |
| 495 | blind_reboot_test |
| 496 | } |
| 497 | |
| 498 | [ "USAGE: test_factory_reset |
| 499 | |
| 500 | factory_reset test |
| 501 | - adb shell su root rm /data/misc/bootstat/build_date |
| 502 | - adb reboot |
| 503 | - (wait until screen is up, boot has completed) |
| 504 | - adb shell getprop sys.boot.reason |
| 505 | - NB: should report factory_reset |
| 506 | |
| 507 | Decision to rummage through bootstat data files was made as |
| 508 | a _real_ factory_reset is too destructive to the device." ] |
| 509 | test_factory_reset() { |
Mark Salyzyn | 6290982 | 2017-10-09 09:27:16 -0700 | [diff] [blame^] | 510 | checkDebugBuild || return |
| 511 | echo "INFO: expected duration of '${TEST}' test ~`format_duration 45`" >&2 |
Mark Salyzyn | b304f6d | 2017-08-04 13:35:51 -0700 | [diff] [blame] | 512 | adb shell su root rm /data/misc/bootstat/build_date >&2 |
| 513 | adb reboot >&2 |
| 514 | wait_for_screen |
| 515 | EXPECT_PROPERTY sys.boot.reason reboot,factory_reset |
Mark Salyzyn | 277eca1 | 2017-09-11 15:22:57 -0700 | [diff] [blame] | 516 | EXPECT_PROPERTY persist.sys.boot.reason "reboot,.*" |
| 517 | report_bootstat_logs reboot,factory_reset reboot, reboot,adb \ |
Mark Salyzyn | b304f6d | 2017-08-04 13:35:51 -0700 | [diff] [blame] | 518 | "-bootstat: Failed to read /data/misc/bootstat/build_date: No such file or directory" \ |
| 519 | "-bootstat: Failed to parse boot time record: /data/misc/bootstat/build_date" |
| 520 | } |
| 521 | |
| 522 | [ "USAGE: test_optional_factory_reset |
| 523 | |
| 524 | factory_reset test |
| 525 | - adb reboot-bootloader |
| 526 | - fastboot format userdata |
| 527 | - fastboot reboot |
| 528 | - (wait until screen is up, boot has completed) |
| 529 | - adb shell getprop sys.boot.reason |
| 530 | - NB: should report factory_reset |
| 531 | |
| 532 | For realz, and disruptive" ] |
| 533 | test_optional_factory_reset() { |
Mark Salyzyn | 6290982 | 2017-10-09 09:27:16 -0700 | [diff] [blame^] | 534 | echo "INFO: expected duration of '${TEST}' test ~`format_duration 60`" >&2 |
Mark Salyzyn | b304f6d | 2017-08-04 13:35:51 -0700 | [diff] [blame] | 535 | if ! inFastboot; then |
| 536 | adb reboot-bootloader |
| 537 | fi |
| 538 | fastboot format userdata >&2 |
| 539 | fastboot reboot >&2 |
| 540 | wait_for_screen |
| 541 | EXPECT_PROPERTY sys.boot.reason reboot,factory_reset |
| 542 | EXPECT_PROPERTY persist.sys.boot.reason "" |
| 543 | report_bootstat_logs reboot,factory_reset bootloader \ |
| 544 | "-bootstat: Failed to read /data/misc/bootstat/last_boot_time_utc: No such file or directory" \ |
| 545 | "-bootstat: Failed to parse boot time record: /data/misc/bootstat/last_boot_time_utc" \ |
| 546 | "-bootstat: Failed to read /data/misc/bootstat/build_date: No such file or directory" \ |
| 547 | "-bootstat: Failed to parse boot time record: /data/misc/bootstat/build_date" \ |
| 548 | "-bootstat: Failed to read /data/misc/bootstat/factory_reset: No such file or directory" \ |
| 549 | "-bootstat: Failed to parse boot time record: /data/misc/bootstat/factory_reset" |
| 550 | } |
| 551 | |
| 552 | [ "USAGE: test_hard |
| 553 | |
| 554 | hard test: |
| 555 | - adb reboot hard |
| 556 | - (wait until screen is up, boot has completed) |
| 557 | - adb shell getprop sys.boot.reason |
| 558 | - NB: should report hard" ] |
| 559 | test_hard() { |
| 560 | blind_reboot_test |
| 561 | } |
| 562 | |
| 563 | [ "USAGE: test_battery |
| 564 | |
| 565 | battery test (trick): |
Mark Salyzyn | a16e437 | 2017-09-20 08:36:12 -0700 | [diff] [blame] | 566 | - echo healthd: battery l=2<space> | adb shell su root tee /dev/kmsg |
| 567 | - adb reboot cold |
Mark Salyzyn | b304f6d | 2017-08-04 13:35:51 -0700 | [diff] [blame] | 568 | - (wait until screen is up, boot has completed) |
| 569 | - adb shell getprop sys.boot.reason |
| 570 | - NB: should report reboot,battery, unless healthd managed to log |
| 571 | before reboot in above trick. |
| 572 | |
| 573 | - Bonus points (manual extras) |
| 574 | - Make sure the following is added to the /init.rc file in post-fs |
| 575 | section before logd is started: |
| 576 | + setprop logd.kernel false |
| 577 | + rm /sys/fs/pstore/console-ramoops |
| 578 | + rm /sys/fs/pstore/console-ramoops-0 |
Mark Salyzyn | a16e437 | 2017-09-20 08:36:12 -0700 | [diff] [blame] | 579 | + write /dev/kmsg \"healthd: battery l=2${SPACE} |
Mark Salyzyn | b304f6d | 2017-08-04 13:35:51 -0700 | [diff] [blame] | 580 | +\" |
| 581 | - adb reboot fs |
| 582 | - (wait until screen is up, boot has completed) |
| 583 | - adb shell getprop sys.boot.reason |
| 584 | - NB: should report reboot,battery |
| 585 | - (replace set logd.kernel true to the above, and retry test)" ] |
| 586 | test_battery() { |
Mark Salyzyn | 6290982 | 2017-10-09 09:27:16 -0700 | [diff] [blame^] | 587 | checkDebugBuild || return |
| 588 | echo "INFO: expected duration of '${TEST}' test ~`format_duration 120`" >&2 |
| 589 | enterPstore |
Mark Salyzyn | 8a30fca | 2017-09-18 10:48:39 -0700 | [diff] [blame] | 590 | # Send it _many_ times to combat devices with flakey pstore |
| 591 | for i in a b c d e f g h i j k l m n o p q r s t u v w x y z; do |
Mark Salyzyn | a16e437 | 2017-09-20 08:36:12 -0700 | [diff] [blame] | 592 | echo 'healthd: battery l=2 ' | adb shell su root tee /dev/kmsg >/dev/null |
Mark Salyzyn | 8a30fca | 2017-09-18 10:48:39 -0700 | [diff] [blame] | 593 | done |
| 594 | adb reboot cold >&2 |
| 595 | adb wait-for-device |
Mark Salyzyn | b304f6d | 2017-08-04 13:35:51 -0700 | [diff] [blame] | 596 | wait_for_screen |
| 597 | adb shell su root \ |
| 598 | cat /proc/fs/pstore/console-ramoops \ |
| 599 | /proc/fs/pstore/console-ramoops-0 2>/dev/null | |
| 600 | grep 'healthd: battery l=' | |
| 601 | tail -1 | |
Mark Salyzyn | a16e437 | 2017-09-20 08:36:12 -0700 | [diff] [blame] | 602 | grep 'healthd: battery l=2 ' >/dev/null || ( |
Mark Salyzyn | b304f6d | 2017-08-04 13:35:51 -0700 | [diff] [blame] | 603 | if ! EXPECT_PROPERTY sys.boot.reason reboot,battery >/dev/null 2>/dev/null; then |
| 604 | # retry |
Mark Salyzyn | 8a30fca | 2017-09-18 10:48:39 -0700 | [diff] [blame] | 605 | for i in a b c d e f g h i j k l m n o p q r s t u v w x y z; do |
Mark Salyzyn | a16e437 | 2017-09-20 08:36:12 -0700 | [diff] [blame] | 606 | echo 'healthd: battery l=2 ' | adb shell su root tee /dev/kmsg >/dev/null |
Mark Salyzyn | 8a30fca | 2017-09-18 10:48:39 -0700 | [diff] [blame] | 607 | done |
| 608 | adb reboot cold >&2 |
| 609 | adb wait-for-device |
Mark Salyzyn | b304f6d | 2017-08-04 13:35:51 -0700 | [diff] [blame] | 610 | wait_for_screen |
| 611 | fi |
| 612 | ) |
| 613 | |
| 614 | EXPECT_PROPERTY sys.boot.reason shutdown,battery |
Mark Salyzyn | 6290982 | 2017-10-09 09:27:16 -0700 | [diff] [blame^] | 615 | EXPECT_PROPERTY persist.sys.boot.reason cold |
Mark Salyzyn | b304f6d | 2017-08-04 13:35:51 -0700 | [diff] [blame] | 616 | report_bootstat_logs shutdown,battery "-bootstat: Battery level at shutdown 2%" |
Mark Salyzyn | 6290982 | 2017-10-09 09:27:16 -0700 | [diff] [blame^] | 617 | exitPstore |
| 618 | } |
| 619 | |
| 620 | [ "USAGE: test_optional_battery |
| 621 | |
| 622 | battery shutdown test: |
| 623 | - adb shell setprop sys.powerctl shutdown,battery |
| 624 | - (power up the device) |
| 625 | - (wait until screen is up, boot has completed) |
| 626 | - adb shell getprop sys.boot.reason |
| 627 | - NB: should report shutdown,battery" ] |
| 628 | test_optional_battery() { |
| 629 | echo "INFO: expected duration of '${TEST}' test >`format_duration 60`" >&2 |
| 630 | echo " power on request" >&2 |
| 631 | adb shell setprop sys.powerctl shutdown,battery |
| 632 | sleep 5 |
| 633 | echo -n "WARNING: Please power device back up, waiting ... " >&2 |
| 634 | wait_for_screen -n >&2 |
| 635 | EXPECT_PROPERTY sys.boot.reason shutdown,battery |
| 636 | EXPECT_PROPERTY persist.sys.boot.reason shutdown,battery |
| 637 | report_bootstat_logs shutdown,battery |
| 638 | } |
| 639 | |
| 640 | [ "USAGE: test_optional_battery_thermal |
| 641 | |
| 642 | battery thermal shutdown test: |
| 643 | - adb shell setprop sys.powerctl shutdown,thermal,battery |
| 644 | - (power up the device) |
| 645 | - (wait until screen is up, boot has completed) |
| 646 | - adb shell getprop sys.boot.reason |
| 647 | - NB: should report shutdown,thermal,battery" ] |
| 648 | test_optional_battery_thermal() { |
| 649 | echo "INFO: expected duration of '${TEST}' test >`format_duration 60`" >&2 |
| 650 | echo " power on request" >&2 |
| 651 | adb shell setprop sys.powerctl shutdown,thermal,battery |
| 652 | sleep 5 |
| 653 | echo -n "WARNING: Please power device back up, waiting ... " >&2 |
| 654 | wait_for_screen -n >&2 |
| 655 | EXPECT_PROPERTY sys.boot.reason shutdown,thermal,battery |
| 656 | EXPECT_PROPERTY persist.sys.boot.reason shutdown,thermal,battery |
| 657 | report_bootstat_logs shutdown,thermal,battery |
Mark Salyzyn | b304f6d | 2017-08-04 13:35:51 -0700 | [diff] [blame] | 658 | } |
| 659 | |
| 660 | [ "USAGE: test_unknown |
| 661 | |
| 662 | unknown test |
| 663 | - adb reboot unknown |
| 664 | - (wait until screen is up, boot has completed) |
| 665 | - adb shell getprop sys.boot.reason |
| 666 | - NB: should report reboot,unknown |
| 667 | - NB: expect log \"... I bootstat: Unknown boot reason: reboot,unknown\"" ] |
| 668 | test_unknown() { |
Mark Salyzyn | 6290982 | 2017-10-09 09:27:16 -0700 | [diff] [blame^] | 669 | blind_reboot_test |
Mark Salyzyn | b304f6d | 2017-08-04 13:35:51 -0700 | [diff] [blame] | 670 | } |
| 671 | |
| 672 | [ "USAGE: test_kernel_panic |
| 673 | |
| 674 | kernel_panic test: |
| 675 | - echo c | adb shell su root tee /proc/sysrq-trigger |
| 676 | - (wait until screen is up, boot has completed) |
| 677 | - adb shell getprop sys.boot.reason |
| 678 | - NB: should report kernel_panic,sysrq" ] |
| 679 | test_kernel_panic() { |
Mark Salyzyn | 6290982 | 2017-10-09 09:27:16 -0700 | [diff] [blame^] | 680 | checkDebugBuild || return |
| 681 | echo "INFO: expected duration of '${TEST}' test >`format_duration 120`" >&2 |
| 682 | panic_msg="kernel_panic,sysrq" |
| 683 | enterPstore || panic_msg="\(kernel_panic,sysrq\|kernel_panic\)" |
Mark Salyzyn | b304f6d | 2017-08-04 13:35:51 -0700 | [diff] [blame] | 684 | echo c | adb shell su root tee /proc/sysrq-trigger >/dev/null |
| 685 | wait_for_screen |
Mark Salyzyn | 6290982 | 2017-10-09 09:27:16 -0700 | [diff] [blame^] | 686 | EXPECT_PROPERTY sys.boot.reason ${panic_msg} |
| 687 | EXPECT_PROPERTY persist.sys.boot.reason ${panic_msg} |
Mark Salyzyn | b304f6d | 2017-08-04 13:35:51 -0700 | [diff] [blame] | 688 | report_bootstat_logs kernel_panic,sysrq |
Mark Salyzyn | 6290982 | 2017-10-09 09:27:16 -0700 | [diff] [blame^] | 689 | exitPstore |
Mark Salyzyn | b304f6d | 2017-08-04 13:35:51 -0700 | [diff] [blame] | 690 | } |
| 691 | |
| 692 | [ "USAGE: test_warm |
| 693 | |
| 694 | warm test |
| 695 | - adb reboot warm |
| 696 | - (wait until screen is up, boot has completed) |
| 697 | - adb shell getprop sys.boot.reason |
| 698 | - NB: should report warm" ] |
| 699 | test_warm() { |
| 700 | blind_reboot_test |
| 701 | } |
| 702 | |
| 703 | [ "USAGE: test_thermal_shutdown |
| 704 | |
| 705 | thermal shutdown test: |
| 706 | - adb shell setprop sys.powerctl shutdown,thermal |
| 707 | - (power up the device) |
| 708 | - (wait until screen is up, boot has completed) |
| 709 | - adb shell getprop sys.boot.reason |
| 710 | - NB: should report shutdown,thermal" ] |
| 711 | test_thermal_shutdown() { |
Mark Salyzyn | 6290982 | 2017-10-09 09:27:16 -0700 | [diff] [blame^] | 712 | echo "INFO: expected duration of '${TEST}' test >`format_duration 60`" >&2 |
Mark Salyzyn | b304f6d | 2017-08-04 13:35:51 -0700 | [diff] [blame] | 713 | echo " power on request" >&2 |
| 714 | adb shell setprop sys.powerctl shutdown,thermal |
| 715 | sleep 5 |
| 716 | echo -n "WARNING: Please power device back up, waiting ... " >&2 |
| 717 | wait_for_screen -n >&2 |
| 718 | EXPECT_PROPERTY sys.boot.reason shutdown,thermal |
| 719 | EXPECT_PROPERTY persist.sys.boot.reason shutdown,thermal |
| 720 | report_bootstat_logs shutdown,thermal |
| 721 | } |
| 722 | |
| 723 | [ "USAGE: test_userrequested_shutdown |
| 724 | |
| 725 | userrequested shutdown test: |
| 726 | - adb shell setprop sys.powerctl shutdown,userrequested |
| 727 | - (power up the device) |
| 728 | - (wait until screen is up, boot has completed) |
| 729 | - adb shell getprop sys.boot.reason |
| 730 | - NB: should report shutdown,userrequested" ] |
| 731 | test_userrequested_shutdown() { |
Mark Salyzyn | 6290982 | 2017-10-09 09:27:16 -0700 | [diff] [blame^] | 732 | echo "INFO: expected duration of '${TEST}' test >`format_duration 60`" >&2 |
Mark Salyzyn | b304f6d | 2017-08-04 13:35:51 -0700 | [diff] [blame] | 733 | echo " power on request" >&2 |
| 734 | adb shell setprop sys.powerctl shutdown,userrequested |
| 735 | sleep 5 |
| 736 | echo -n "WARNING: Please power device back up, waiting ... " >&2 |
| 737 | wait_for_screen -n >&2 |
| 738 | EXPECT_PROPERTY sys.boot.reason shutdown,userrequested |
| 739 | EXPECT_PROPERTY persist.sys.boot.reason shutdown,userrequested |
| 740 | report_bootstat_logs shutdown,userrequested |
| 741 | } |
| 742 | |
Mark Salyzyn | 277eca1 | 2017-09-11 15:22:57 -0700 | [diff] [blame] | 743 | [ "USAGE: test_shell_reboot |
| 744 | |
| 745 | shell reboot test: |
| 746 | - adb shell reboot |
| 747 | - (wait until screen is up, boot has completed) |
| 748 | - adb shell getprop sys.boot.reason |
| 749 | - NB: should report reboot,shell" ] |
| 750 | test_shell_reboot() { |
Mark Salyzyn | 6290982 | 2017-10-09 09:27:16 -0700 | [diff] [blame^] | 751 | echo "INFO: expected duration of '${TEST}' test ~`format_duration 45`" >&2 |
Mark Salyzyn | 277eca1 | 2017-09-11 15:22:57 -0700 | [diff] [blame] | 752 | adb shell reboot |
| 753 | wait_for_screen |
| 754 | EXPECT_PROPERTY sys.boot.reason reboot,shell |
| 755 | EXPECT_PROPERTY persist.sys.boot.reason reboot,shell |
| 756 | report_bootstat_logs reboot,shell |
| 757 | } |
| 758 | |
| 759 | [ "USAGE: test_adb_reboot |
| 760 | |
| 761 | adb reboot test: |
| 762 | - adb reboot |
| 763 | - (wait until screen is up, boot has completed) |
| 764 | - adb shell getprop sys.boot.reason |
| 765 | - NB: should report reboot,adb" ] |
| 766 | test_adb_reboot() { |
Mark Salyzyn | 6290982 | 2017-10-09 09:27:16 -0700 | [diff] [blame^] | 767 | echo "INFO: expected duration of '${TEST}' test ~`format_duration 45`" >&2 |
Mark Salyzyn | 277eca1 | 2017-09-11 15:22:57 -0700 | [diff] [blame] | 768 | adb reboot |
| 769 | wait_for_screen |
| 770 | EXPECT_PROPERTY sys.boot.reason reboot,adb |
| 771 | EXPECT_PROPERTY persist.sys.boot.reason reboot,adb |
| 772 | report_bootstat_logs reboot,adb |
| 773 | } |
| 774 | |
Mark Salyzyn | a16e437 | 2017-09-20 08:36:12 -0700 | [diff] [blame] | 775 | [ "USAGE: test_Its_Just_So_Hard_reboot |
| 776 | |
| 777 | Its Just So Hard reboot test: |
| 778 | - adb shell reboot 'Its Just So Hard' |
| 779 | - (wait until screen is up, boot has completed) |
| 780 | - adb shell getprop sys.boot.reason |
| 781 | - NB: should report reboot,its_just_so_hard |
| 782 | - NB: expect log \"... I bootstat: Unknown boot reason: reboot,its_just_so_hard\"" ] |
| 783 | test_Its_Just_So_Hard_reboot() { |
Mark Salyzyn | 6290982 | 2017-10-09 09:27:16 -0700 | [diff] [blame^] | 784 | checkDebugBuild || return |
| 785 | echo "INFO: expected duration of '${TEST}' test ~`format_duration 45`" >&2 |
Mark Salyzyn | a16e437 | 2017-09-20 08:36:12 -0700 | [diff] [blame] | 786 | adb shell 'reboot "Its Just So Hard"' |
| 787 | wait_for_screen |
| 788 | EXPECT_PROPERTY sys.boot.reason reboot,its_just_so_hard |
| 789 | EXPECT_PROPERTY persist.sys.boot.reason "reboot,Its Just So Hard" |
| 790 | adb shell su root setprop persist.sys.boot.reason reboot,its_just_so_hard |
| 791 | EXPECT_PROPERTY persist.sys.boot.reason reboot,its_just_so_hard |
| 792 | report_bootstat_logs reboot,its_just_so_hard |
| 793 | } |
| 794 | |
Mark Salyzyn | b304f6d | 2017-08-04 13:35:51 -0700 | [diff] [blame] | 795 | [ "USAGE: ${0##*/} [-s SERIAL] [tests] |
| 796 | |
| 797 | Mainline executive to run the above tests" ] |
| 798 | |
| 799 | # Rudimentary argument parsing |
| 800 | |
| 801 | if [ ${#} -ge 2 -a X"-s" = X"${1}" ]; then |
| 802 | export ANDROID_SERIAL="${2}" |
| 803 | shift 2 |
| 804 | fi |
| 805 | |
| 806 | if [ X"--help" = X"${1}" -o X"-h" = X"${1}" -o X"-?" = X"${1}" ]; then |
| 807 | echo "USAGE: ${0##*/} [-s SERIAL] [tests]" |
| 808 | echo tests - `sed -n 's/^test_\([^ ()]*\)() {/\1/p' $0 </dev/null` |
| 809 | exit 0 |
| 810 | fi |
| 811 | |
| 812 | # Check if all conditions for the script are sane |
| 813 | |
| 814 | if [ -z "${ANDROID_SERIAL}" ]; then |
| 815 | ndev=`( |
| 816 | adb devices | grep -v 'List of devices attached' |
| 817 | fastboot devices |
| 818 | ) | |
| 819 | grep -v "^[${SPACE}${TAB}]*\$" | |
| 820 | wc -l` |
| 821 | if [ ${ndev} -gt 1 ]; then |
| 822 | echo "ERROR: no target device specified, ${ndev} connected" >&2 |
| 823 | echo "${RED}[ FAILED ]${NORMAL}" |
| 824 | exit 1 |
| 825 | fi |
| 826 | echo "WARNING: no target device specified" >&2 |
| 827 | fi |
| 828 | |
| 829 | ret=0 |
| 830 | |
| 831 | # Test Series |
| 832 | if [ X"all" = X"${*}" ]; then |
| 833 | # automagically pick up all test_<function>s. |
| 834 | eval set nothing `sed -n 's/^test_\([^ ()]*\)() {/\1/p' $0 </dev/null` |
| 835 | if [ X"nothing" = X"${1}" ]; then |
| 836 | shift 1 |
| 837 | fi |
| 838 | fi |
| 839 | if [ -z "$*" ]; then |
| 840 | # automagically pick up all test_<function>, except test_optional_<function>. |
| 841 | eval set nothing `sed -n 's/^test_\([^ ()]*\)() {/\1/p' $0 </dev/null | |
| 842 | grep -v '^optional_'` |
| 843 | if [ -z "${2}" ]; then |
| 844 | # Hard coded should shell fail to find them above (search/permission issues) |
| 845 | eval set ota cold factory_reset hard battery unknown kernel_panic warm \ |
Mark Salyzyn | 277eca1 | 2017-09-11 15:22:57 -0700 | [diff] [blame] | 846 | thermal_shutdown userrequested_shutdown shell_reboot adb_reboot |
Mark Salyzyn | b304f6d | 2017-08-04 13:35:51 -0700 | [diff] [blame] | 847 | fi |
| 848 | if [ X"nothing" = X"${1}" ]; then |
| 849 | shift 1 |
| 850 | fi |
| 851 | fi |
| 852 | echo "INFO: selected test(s): ${@}" >&2 |
| 853 | echo |
| 854 | failures= |
| 855 | successes= |
| 856 | for t in "${@}"; do |
| 857 | wrap_test ${t} |
| 858 | retval=${?} |
| 859 | if [ 0 = ${retval} ]; then |
| 860 | if [ -z "${successes}" ]; then |
| 861 | successes=${t} |
| 862 | else |
| 863 | successes="${successes} ${t}" |
| 864 | fi |
| 865 | else |
| 866 | ret=${retval} |
| 867 | if [ -z "${failures}" ]; then |
| 868 | failures=${t} |
| 869 | else |
| 870 | failures="${failures} ${t}" |
| 871 | fi |
| 872 | fi |
| 873 | echo |
| 874 | done |
| 875 | |
| 876 | if [ -n "${successes}" ]; then |
| 877 | echo "${GREEN}[ PASSED ]${NORMAL} ${successes}" |
| 878 | fi |
| 879 | if [ -n "${failures}" ]; then |
| 880 | echo "${RED}[ FAILED ]${NORMAL} ${failures}" |
| 881 | fi |
| 882 | exit ${ret} |