Files
swupd-client/test/functional/check_ids.bash
Otavio Pontes 02d20cc246 test: Improve test to check if IDs are correct
Test wasn't catching all cases of duplicated IDs or missing IDs.
This new version also doesn't require that labels are provided in the test,
so it will work out of the box for new test groups.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-11-13 13:21:07 -08:00

34 lines
753 B
Bash
Executable File

#!/bin/bash
# shellcheck disable=SC1090
# SC1090: Can't follow non-constant source. Use a directive to specify location.
# We already process that file, so it's fine to ignore
SCRIPT_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SCRIPT_PATH/../functional/testlib.bash"
set -e
#Check if there's no dupicated test
list_tests --all| cut -f 1 -d ':'|sort -cu
last_lbl=""
last_num=0
for t in $(list_tests --all| cut -f 1 -d ':'|sort); do
lbl=$(echo "$t" | cut -b 1-3)
num=$(echo "$t" | cut -b 4-6)
if [ "$last_lbl" != "$lbl" ]; then
last_lbl="$lbl"
last_num=0
fi
last_num=$((last_num + 1))
if [ "$last_num" -ne "$num" ]; then
echo "Test $t has an incorrect number"
exit 1
fi
done
echo "All tests have valid IDs."
exit 0