diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-14 19:33:34 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-14 19:33:34 +0000 |
commit | 1272be04be0cb803eec87f602edb2e3e6f111aea (patch) | |
tree | bce17f6478cdd9f3c4ec3d751135dc42786d6a56 /tests/functions.sh | |
parent | Releasing progress-linux version 2.39.3-11~progress7.99u1. (diff) | |
download | util-linux-1272be04be0cb803eec87f602edb2e3e6f111aea.tar.xz util-linux-1272be04be0cb803eec87f602edb2e3e6f111aea.zip |
Merging upstream version 2.40.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/functions.sh')
-rw-r--r-- | tests/functions.sh | 53 |
1 files changed, 33 insertions, 20 deletions
diff --git a/tests/functions.sh b/tests/functions.sh index 5a562a3..5fe5ba0 100644 --- a/tests/functions.sh +++ b/tests/functions.sh @@ -163,6 +163,18 @@ function ts_skip_nonroot { fi } +# Specify the capability needed in your test case like: +# +# ts_skip_capability cap_wake_alarm +# +function ts_skip_capability { + ts_check_prog "$TS_HELPER_CAP" + + if ! "$TS_HELPER_CAP" "$1"; then + ts_skip "no capability: $1" + fi +} + function ts_skip_qemu_user { if [ "$QEMU_USER" == "1" ]; then ts_skip "running under qemu-user emulation" @@ -283,10 +295,10 @@ function ts_init_core_subtest_env { TS_EXPECTED_ERR="$TS_TOPDIR/expected/$TS_NS.err" TS_MOUNTPOINT="$TS_OUTDIR/${TS_TESTNAME}-${TS_SUBNAME}-mnt" - rm -f $TS_OUTPUT $TS_ERRLOG $TS_VGDUMP $TS_EXIT_CODE + rm -f "$TS_OUTPUT" "$TS_ERRLOG" "$TS_VGDUMP" "$TS_EXIT_CODE" [ -d "$TS_OUTDIR" ] || mkdir -p "$TS_OUTDIR" - touch $TS_OUTPUT $TS_ERRLOG $TS_EXIT_CODE + touch "$TS_OUTPUT" "$TS_ERRLOG" "$TS_EXIT_CODE" [ -n "$TS_VALGRIND_CMD" ] && touch $TS_VGDUMP } @@ -386,6 +398,7 @@ function ts_init_env { TS_ENABLE_UBSAN="yes" fi + TS_FSTAB="$TS_OUTDIR/${TS_TESTNAME}.fstab" BLKID_FILE="$TS_OUTDIR/${TS_TESTNAME}.blkidtab" declare -a TS_SUID_PROGS @@ -529,19 +542,19 @@ function ts_gen_diff_from { local output="$2" local difffile="$3" - diff -u $expected $output > $difffile + diff -u "$expected" "$output" > "$difffile" - if [ $? -ne 0 ] || [ -s $difffile ]; then + if [ $? -ne 0 ] || [ -s "$difffile" ]; then res=1 if [ "$TS_SHOWDIFF" == "yes" -a "$TS_KNOWN_FAIL" != "yes" ]; then echo echo "diff-{{{" - cat $difffile + cat "$difffile" echo "}}}-diff" echo fi else - rm -f $difffile; + rm -f "$difffile"; fi return $res @@ -556,8 +569,8 @@ function ts_gen_diff { [ -f "$TS_EXPECTED" ] || TS_EXPECTED=/dev/null # remove libtool lt- prefixes - sed --in-place 's/^lt\-\(.*\: \)/\1/g' $TS_OUTPUT - sed --in-place 's/^lt\-\(.*\: \)/\1/g' $TS_ERRLOG + sed --in-place 's/^lt\-\(.*\: \)/\1/g' "$TS_OUTPUT" + sed --in-place 's/^lt\-\(.*\: \)/\1/g' "$TS_ERRLOG" [ -d "$TS_DIFFDIR" ] || mkdir -p "$TS_DIFFDIR" @@ -566,10 +579,10 @@ function ts_gen_diff { [ -f "$TS_ERRLOG" ] || TS_ERRLOG=/dev/null if [ "$TS_COMPONENT" != "fuzzers" ]; then - ts_gen_diff_from $TS_EXPECTED $TS_OUTPUT $TS_DIFF + ts_gen_diff_from "$TS_EXPECTED" "$TS_OUTPUT" "$TS_DIFF" status_out=$? - ts_gen_diff_from $TS_EXPECTED_ERR $TS_ERRLOG $TS_DIFF.err + ts_gen_diff_from "$TS_EXPECTED_ERR" "$TS_ERRLOG" "$TS_DIFF.err" status_err=$? else # TS_EXIT_CODE is empty when tests aren't run with ts_run: https://github.com/util-linux/util-linux/issues/1072 @@ -580,8 +593,8 @@ function ts_gen_diff { fi if [ $exit_code -ne 0 ]; then - ts_gen_diff_from $TS_EXPECTED $TS_OUTPUT $TS_DIFF - ts_gen_diff_from $TS_EXPECTED_ERR $TS_ERRLOG $TS_DIFF.err + ts_gen_diff_from "$TS_EXPECTED" "$TS_OUTPUT" "$TS_DIFF" + ts_gen_diff_from "$TS_EXPECTED_ERR" "$TS_ERRLOG" "$TS_DIFF.err" fi fi @@ -824,12 +837,12 @@ function ts_is_mounted { } function ts_fstab_open { - echo "# <!-- util-linux test entry" >> /etc/fstab + echo "# <!-- util-linux test entry" >> "$TS_FSTAB" } function ts_fstab_close { - echo "# -->" >> /etc/fstab - sync /etc/fstab 2>/dev/null + echo "# -->" >> "$TS_FSTAB" + sync "$TS_FSTAB" 2>/dev/null } function ts_fstab_addline { @@ -838,7 +851,7 @@ function ts_fstab_addline { local FS=${3:-"auto"} local OPT=${4:-"defaults"} - echo "$SPEC $MNT $FS $OPT 0 0" >> /etc/fstab + echo "$SPEC $MNT $FS $OPT 0 0" >> "$TS_FSTAB" } function ts_fstab_lock { @@ -862,9 +875,9 @@ function ts_fstab_clean { ba } s/# <!-- util-linux.*-->//; -/^$/d" /etc/fstab +/^$/d" "$TS_FSTAB" - sync /etc/fstab 2>/dev/null + sync "$TS_FSTAB" 2>/dev/null ts_unlock "fstab" } @@ -1159,8 +1172,8 @@ function ts_is_virt { } function ts_check_enosys_syscalls { - ts_check_test_command "$TS_HELPER_ENOSYS" - "$TS_HELPER_ENOSYS" ${@/#/-s } true 2> /dev/null + ts_check_test_command "$TS_CMD_ENOSYS" + "$TS_CMD_ENOSYS" ${@/#/-s } true 2> /dev/null [ $? -ne 0 ] && ts_skip "test_enosys does not work: $*" } |