From: Masatake YAMATO Date: Sun, 4 Jun 2023 07:55:00 +0000 (+0900) Subject: tests: add ts_skip_capability X-Git-Tag: v2.40-rc1~403^2~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=63feafbae8f0fa898e439846d8ba88a19497b0e1;p=thirdparty%2Futil-linux.git tests: add ts_skip_capability Signed-off-by: Masatake YAMATO --- diff --git a/tests/functions.sh b/tests/functions.sh index c27aac09c4..b953edc94e 100644 --- a/tests/functions.sh +++ b/tests/functions.sh @@ -163,6 +163,29 @@ function ts_skip_nonroot { fi } +# Specify the capability needed in your test case like: +# +# ts_skip_capability cap_wake_alarm +# +function ts_skip_capability { + local self=$$ + local cap=$1 + + # On Fedora, libcap package provides getpcaps command. + ts_check_prog "getpcaps" + + local caps=$(getpcaps "$self") + if [[ "$caps" == "${self}: =ep" ]]; then + return 0 + fi + + if [[ "$caps" =~ .*${cap}.* ]]; then + return 0 + fi + + ts_skip "no capability: ${cap}" +} + function ts_skip_qemu_user { if [ "$QEMU_USER" == "1" ]; then ts_skip "running under qemu-user emulation"