From 8383d28b4407f86da60b08cae71322b1e07d96ae Mon Sep 17 00:00:00 2001 From: Antonio Ospite Date: Fri, 20 Jun 2025 13:33:11 +0200 Subject: [PATCH] ci/android: test that all available modules ran in android-cts-runner.sh If an Android CTS module does not even start the amount of `FAILED` tests in the invocation summary could still show up as 0, passing the sanity check on the completion status, and `cts-tradefed` would not reflect the module-level failure in the return value either. So explicitly check that all included modules completed and, in case they didn't, propagate this kind of failure to `EXIT_CODE`. Part-of: --- .gitlab-ci/android-cts-runner.sh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci/android-cts-runner.sh b/.gitlab-ci/android-cts-runner.sh index 30f51efe01e..51a62adc181 100755 --- a/.gitlab-ci/android-cts-runner.sh +++ b/.gitlab-ci/android-cts-runner.sh @@ -32,7 +32,19 @@ eval "/android-cts/tools/cts-tradefed" run commandAndExit cts-dev \ $INCLUDE_FILTERS \ $EXCLUDE_FILTERS -[ "$(grep "^FAILED" /android-cts/results/latest/invocation_summary.txt | tr -d ' ' | cut -d ':' -f 2)" = "0" ] +SUMMARY_FILE=/android-cts/results/latest/invocation_summary.txt + +# Parse a line like `x/y modules completed` to check that all modules completed +COMPLETED_MODULES=$(sed -n -e '/modules completed/s/^\([0-9]\+\)\/\([0-9]\+\) .*$/\1/p' "$SUMMARY_FILE") +AVAILABLE_MODULES=$(sed -n -e '/modules completed/s/^\([0-9]\+\)\/\([0-9]\+\) .*$/\2/p' "$SUMMARY_FILE") +[ "$COMPLETED_MODULES" = "$AVAILABLE_MODULES" ] +MODULES_FAILED=$? + +# Parse a line like `FAILED : x` to check that no tests failed +[ "$(grep "^FAILED" "$SUMMARY_FILE" | tr -d ' ' | cut -d ':' -f 2)" = "0" ] +TESTS_FAILED=$? + +[ "$MODULES_FAILED" = "0" ] && [ "$TESTS_FAILED" = "0" ] # shellcheck disable=SC2034 # EXIT_CODE is used by the script that sources this one EXIT_CODE=$?