summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDan Streetman <ddstreet@canonical.com>2020-11-18 07:30:11 -0500
committerDan Streetman <ddstreet@canonical.com>2021-01-26 17:36:53 -0500
commitb3e43406646bee75a2c0d36fb7abe7e33a1139f8 (patch)
tree181d3d16c4b78de71540ebfef0f48162bad7bd7f /test
parent232add5c47a8486623c98158ed3a9a19f422b5d8 (diff)
downloadsystemd-b3e43406646bee75a2c0d36fb7abe7e33a1139f8.tar.gz
test/run-integration-tests.sh: adjust arg processing
The script currently parses either 'clean' or 'clean-again' as wanting to clean both before and after running tests. This fixes that to split the action up; clean runs before tests, clean-again after; and also verifies the parameter(s) before passing them to make.
Diffstat (limited to 'test')
-rwxr-xr-xtest/run-integration-tests.sh82
1 files changed, 54 insertions, 28 deletions
diff --git a/test/run-integration-tests.sh b/test/run-integration-tests.sh
index 34fa4f56a2..036c075eef 100755
--- a/test/run-integration-tests.sh
+++ b/test/run-integration-tests.sh
@@ -11,12 +11,36 @@ else
fi
if [ $# -gt 0 ]; then
- args="$@"
+ args="$*"
else
args="setup run clean-again"
fi
-args_no_clean=$(sed -r 's/\bclean.*\b//g' <<<$args)
-do_clean=$( [ "$args" = "$args_no_clean" ]; echo $? )
+
+VALID_TARGETS="all setup run clean clean-again"
+
+is_valid_target() {
+ for target in $VALID_TARGETS; do
+ [ "$1" = "$target" ] && return 0
+ done
+ return 1
+}
+
+# reject invalid make targets in $args
+for arg in $args; do
+ if ! is_valid_target "$arg"; then
+ echo "Invalid target: $arg" >&2
+ exit 1
+ fi
+done
+
+CLEAN=0
+CLEANAGAIN=0
+
+# separate 'clean' and 'clean-again' operations
+[[ "$args" =~ "clean-again" ]] && CLEANAGAIN=1
+args=${args/clean-again}
+[[ "$args" =~ "clean" ]] && CLEAN=1
+args=${args/clean}
declare -A results
declare -A times
@@ -26,16 +50,6 @@ FAILURES=0
cd "$(dirname "$0")"
-# Let's always do the cleaning operation first, because it destroys the image
-# cache.
-if [ $do_clean = 1 ]; then
- for TEST in TEST-??-* ; do
- ( set -x ; make -C "$TEST" clean )
- done
-
- [ -n "$args_no_clean" ] || exit 0
-fi
-
pass_deny_list() {
for marker in $DENY_LIST_MARKERS $BLACKLIST_MARKERS; do
if [ -f "$1/$marker" ]; then
@@ -46,26 +60,38 @@ pass_deny_list() {
return 0
}
-for TEST in TEST-??-* ; do
- COUNT=$(($COUNT+1))
+# Let's always do the cleaning operation first, because it destroys the image
+# cache.
+if [ $CLEAN = 1 ]; then
+ for TEST in TEST-??-* ; do
+ ( set -x ; make -C "$TEST" clean )
+ done
+fi
- pass_deny_list $TEST || continue
- start=$(date +%s)
+# Run actual tests (if requested)
+if [[ $args =~ [a-z] ]]; then
+ for TEST in TEST-??-* ; do
+ COUNT=$(($COUNT+1))
- echo -e "\n--x-- Running $TEST --x--"
- set +e
- ( set -x ; make -C "$TEST" $args_no_clean )
- RESULT=$?
- set -e
- echo "--x-- Result of $TEST: $RESULT --x--"
+ pass_deny_list $TEST || continue
+ start=$(date +%s)
- results["$TEST"]="$RESULT"
- times["$TEST"]=$(( $(date +%s) - $start ))
+ echo -e "\n--x-- Running $TEST --x--"
+ set +e
+ ( set -x ; make -C "$TEST" $args )
+ RESULT=$?
+ set -e
+ echo "--x-- Result of $TEST: $RESULT --x--"
- [ "$RESULT" -ne "0" ] && FAILURES=$(($FAILURES+1))
-done
+ results["$TEST"]="$RESULT"
+ times["$TEST"]=$(( $(date +%s) - $start ))
+
+ [ "$RESULT" -ne "0" ] && FAILURES=$(($FAILURES+1))
+ done
+fi
-if [ $FAILURES -eq 0 -a $do_clean = 1 ]; then
+# Run clean-again, if requested, and if no tests failed
+if [ $FAILURES -eq 0 -a $CLEANAGAIN = 1 ]; then
for TEST in ${!results[@]}; do
( set -x ; make -C "$TEST" clean-again )
done