tests: Add skips for testing of unsupported features
David Howells
maintainerPATCH 1/1 tests: Add skips for testing of unsupported features
Hi Jarkko,
Here's a patch I'm proposing to add to the keyutils testsuite so that I can use it with some older OS versions.
David
---
tests: Add skips for testing of unsupported features
Add skips for features that are either unsupported by the kernel or by the keyutils package.
Signed-off-by David Howells <[email protected]>
--- tests/features/limits/runtest.sh | 6 +++++ tests/hex2bin.pl | 21 +++++++++++++++++++ tests/keyctl/id/bad-args/runtest.sh | 6 +++++ tests/keyctl/id/noargs/runtest.sh | 6 +++++ tests/keyctl/id/valid/runtest.sh | 6 +++++ tests/keyctl/move/bad-args/runtest.sh | 6 +++++ tests/keyctl/move/noargs/runtest.sh | 6 +++++ tests/keyctl/move/recursion/runtest.sh | 6 +++++ tests/keyctl/move/valid/runtest.sh | 6 +++++ tests/keyctl/session/valid2/runtest.sh | 6 +++++ tests/keyctl/supports/bad-args/runtest.sh | 6 +++++ tests/keyctl/supports/valid/runtest.sh | 6 +++++ tests/prepare.inc.sh | 23 ++++++++++++++++++++ tests/toolbox.inc.sh | 33 ++++++++++++++++++++++++------ 14 files changed, 136 insertions(+), 7 deletions(-)
tests/features/limits/runtest.sh +6 -0
@@ -9,6 +9,12 @@ result=PASS echo "++++ BEGINNING TEST" >$OUTPUTFILE +if ! keyutils_at_or_later_than 1.6.2 +then + toolbox_skip_test $TEST "SKIPPING DUE TO LACK OF 'keyctl --test'" + exit 0 +fi + # This doesn't work on MIPS earler than 3.19 because of a kernel bug kver=`uname -r` kmch=`uname -m`
tests/hex2bin.pl new file +21 -0
@@ -0,0 +1,21 @@ +#!/usr/bin/perl -w +use strict; + +die "Format:\n\t$0 <hex> [<hex>]*\n\t$0 -\n" unless (@ARGV); + +my $str = ""; + +if ($ARGV[0] eq "-") { + shift(@ARGV); + $str .= $_ while (<STDIN>); +} else { + $str = join("", @ARGV); +} + +$str =~ s/[ \t\n]//g; +die "odd length string\n" if (length($str) & 1); + +for (; $str; $str = substr($str, 2)) { + my $pair = hex(substr($str, 0, 2)); + print pack("C", $pair); +}
tests/keyctl/id/bad-args/runtest.sh +6 -0
@@ -6,6 +6,12 @@ # ---- do the actual testing ---- +if [ $have_id_command = 0 ] +then + toolbox_skip_test $TEST "SKIPPING DUE TO LACK OF 'keyctl id'" + exit 0 +fi + result=PASS echo "++++ BEGINNING TEST" >$OUTPUTFILE
tests/keyctl/id/noargs/runtest.sh +6 -0
@@ -6,6 +6,12 @@ # ---- do the actual testing ---- +if [ $have_id_command = 0 ] +then + toolbox_skip_test $TEST "SKIPPING DUE TO LACK OF 'keyctl id'" + exit 0 +fi + result=PASS echo "++++ BEGINNING TEST" >$OUTPUTFILE
tests/keyctl/id/valid/runtest.sh +6 -0
@@ -6,6 +6,12 @@ # ---- do the actual testing ---- +if [ $have_id_command = 0 ] +then + toolbox_skip_test $TEST "SKIPPING DUE TO LACK OF 'keyctl id'" + exit 0 +fi + result=PASS echo "++++ BEGINNING TEST" >$OUTPUTFILE
tests/keyctl/move/bad-args/runtest.sh +6 -0
@@ -6,6 +6,12 @@ # ---- do the actual testing ---- +if [ $have_move_key = 0 ] +then + toolbox_skip_test $TEST "SKIPPING DUE TO LACK OF 'keyctl move'" + exit 0 +fi + result=PASS echo "++++ BEGINNING TEST" >$OUTPUTFILE
tests/keyctl/move/noargs/runtest.sh +6 -0
@@ -6,6 +6,12 @@ # ---- do the actual testing ---- +if [ $have_move_key = 0 ] +then + toolbox_skip_test $TEST "SKIPPING DUE TO LACK OF 'keyctl move'" + exit 0 +fi + result=PASS echo "++++ BEGINNING TEST" >$OUTPUTFILE
tests/keyctl/move/recursion/runtest.sh +6 -0
@@ -6,6 +6,12 @@ # ---- do the actual testing ---- +if [ $have_move_key = 0 ] +then + toolbox_skip_test $TEST "SKIPPING DUE TO LACK OF 'keyctl move'" + exit 0 +fi + result=PASS echo "++++ BEGINNING TEST" >$OUTPUTFILE
tests/keyctl/move/valid/runtest.sh +6 -0
@@ -6,6 +6,12 @@ # ---- do the actual testing ---- +if [ $have_move_key = 0 ] +then + toolbox_skip_test $TEST "SKIPPING DUE TO LACK OF 'keyctl move'" + exit 0 +fi + result=PASS echo "++++ BEGINNING TEST" >$OUTPUTFILE
tests/keyctl/session/valid2/runtest.sh +6 -0
@@ -6,6 +6,12 @@ # ---- do the actual testing ---- +if [ $have_id_command = 0 ] +then + toolbox_skip_test $TEST "SKIPPING DUE TO LACK OF 'keyctl id'" + exit 0 +fi + result=PASS echo "++++ BEGINNING TEST" >$OUTPUTFILE
tests/keyctl/supports/bad-args/runtest.sh +6 -0
@@ -6,6 +6,12 @@ # ---- do the actual testing ---- +if [ $have_capabilities = 0 ] +then + toolbox_skip_test $TEST "SKIPPING DUE TO LACK OF 'keyctl supports'" + exit 0 +fi + result=PASS echo "++++ BEGINNING TEST" >$OUTPUTFILE
tests/keyctl/supports/valid/runtest.sh +6 -0
@@ -6,6 +6,12 @@ # ---- do the actual testing ---- +if [ $have_capabilities = 0 ] +then + toolbox_skip_test $TEST "SKIPPING DUE TO LACK OF 'keyctl supports'" + exit 0 +fi + result=PASS echo "++++ BEGINNING TEST" >$OUTPUTFILE
tests/prepare.inc.sh +22 -1
@@ -112,11 +112,14 @@ then esac fi +have_capabilities=0 have_key_invalidate=0 have_big_key_type=0 have_dh_compute=0 -have_restrict_keyring=0 +have_move_key=0 have_notify=0 +have_public_key=0 +have_restrict_keyring=0 if keyctl supports capabilities >&/dev/null then
@@ -179,3 +182,21 @@ if [ "$SKIPINSTALLREQ" = "yes" ] then skip_install_required=1 fi + +# +# Check if "keyctl id" is supported +# +have_id_command=0 +if keyutils_at_or_later_than 1.6.2 +then + have_id_command=1 +fi + +# +# Check if "keyctl pkey_*" are supported +# +have_pkey_commands=0 +if keyutils_at_or_later_than 1.6 +then + have_pkey_commands=1 +fi
tests/toolbox.inc.sh +27 -6
@@ -613,8 +613,15 @@ function create_key () my_keyring=$4 fi - echo keyctl add "$@" >>$OUTPUTFILE - keyctl add "$@" >>$OUTPUTFILE 2>&1 + if [ "$1" = "-x" ] && version_less_than $OSRELEASE 9 + then + shift + echo perl ../../../hex2bin.pl "$3" "|" keyctl padd "$1 $2 $4" >>$OUTPUTFILE + perl ../../../hex2bin.pl "$3" | keyctl padd "$1" "$2" "$4" >>$OUTPUTFILE + else + echo keyctl add "$@" >>$OUTPUTFILE + keyctl add "$@" >>$OUTPUTFILE 2>&1 + fi e=$? if [ $e == $my_exitval ] then
@@ -682,8 +689,15 @@ function pcreate_key () my_keyring=$3 fi - echo echo -n $data \| keyctl padd "$@" >>$OUTPUTFILE - echo -n $data | keyctl padd "$@" >>$OUTPUTFILE 2>&1 + if [ "$1" = "-x" ] && version_less_than $OSRELEASE 9 + then + shift + echo echo -n $data \| perl ../../../hex2bin.pl "|" keyctl padd "$@" >>$OUTPUTFILE + echo -n $data | perl ../../../hex2bin.pl - | keyctl padd "$@" >>$OUTPUTFILE + else + echo echo -n $data \| keyctl padd "$@" >>$OUTPUTFILE + echo -n $data | keyctl padd "$@" >>$OUTPUTFILE 2>&1 + fi e=$? if [ $e == $my_exitval ] then
@@ -1232,8 +1246,15 @@ function update_key () shift fi - echo keyctl update "$@" >>$OUTPUTFILE - keyctl update "$@" >>$OUTPUTFILE 2>&1 + if [ "x$1" = "x-x" ] && version_less_than $OSRELEASE 9 + then + shift + echo perl ../../../hex2bin.pl "$2" "|" keyctl pupdate "$1" >>$OUTPUTFILE + perl ../../../hex2bin.pl "$2" | keyctl pupdate "$1" >>$OUTPUTFILE + else + echo keyctl update "$@" >>$OUTPUTFILE + keyctl update "$@" >>$OUTPUTFILE 2>&1 + fi e=$? if [ $e == $my_exitval ] then
Quoted 335 lines · David Howells
Hi Jarkko,
Here's a patch I'm proposing to add to the keyutils testsuite so that I can use it with some older OS versions.
David
---
tests: Add skips for testing of unsupported featuresAdd skips for features that are either unsupported by the kernel or by the keyutils package.
Signed-off-by David Howells <[email protected]>--- tests/features/limits/runtest.sh | 6 +++++ tests/hex2bin.pl | 21 +++++++++++++++++++ tests/keyctl/id/bad-args/runtest.sh | 6 +++++ tests/keyctl/id/noargs/runtest.sh | 6 +++++ tests/keyctl/id/valid/runtest.sh | 6 +++++ tests/keyctl/move/bad-args/runtest.sh | 6 +++++ tests/keyctl/move/noargs/runtest.sh | 6 +++++ tests/keyctl/move/recursion/runtest.sh | 6 +++++ tests/keyctl/move/valid/runtest.sh | 6 +++++ tests/keyctl/session/valid2/runtest.sh | 6 +++++ tests/keyctl/supports/bad-args/runtest.sh | 6 +++++ tests/keyctl/supports/valid/runtest.sh | 6 +++++ tests/prepare.inc.sh | 23 ++++++++++++++++++++ tests/toolbox.inc.sh | 33 ++++++++++++++++++++++++------ 14 files changed, 136 insertions(+), 7 deletions(-)tests/features/limits/runtest.sh +6
-0@@ -9,6 +9,12 @@ result=PASS echo "++++ BEGINNING TEST" >$OUTPUTFILE +if ! keyutils_at_or_later_than 1.6.2 +then + toolbox_skip_test $TEST "SKIPPING DUE TO LACK OF 'keyctl --test'" + exit 0 +fi + # This doesn't work on MIPS earler than 3.19 because of a kernel bug kver=`uname -r` kmch=`uname -m`tests/hex2bin.pl new file +21
-0@@ -0,0 +1,21 @@ +#!/usr/bin/perl -w +use strict; + +die "Format:\n\t$0 <hex> [<hex>]*\n\t$0 -\n" unless (@ARGV); + +my $str = ""; + +if ($ARGV[0] eq "-") { + shift(@ARGV); + $str .= $_ while (<STDIN>); +} else { + $str = join("", @ARGV); +} + +$str =~ s/[ \t\n]//g; +die "odd length string\n" if (length($str) & 1); + +for (; $str; $str = substr($str, 2)) { + my $pair = hex(substr($str, 0, 2)); + print pack("C", $pair); +}tests/keyctl/id/bad-args/runtest.sh +6
-0@@ -6,6 +6,12 @@ # ---- do the actual testing ---- +if [ $have_id_command = 0 ] +then + toolbox_skip_test $TEST "SKIPPING DUE TO LACK OF 'keyctl id'" + exit 0 +fi + result=PASS echo "++++ BEGINNING TEST" >$OUTPUTFILEtests/keyctl/id/noargs/runtest.sh +6
-0@@ -6,6 +6,12 @@ # ---- do the actual testing ---- +if [ $have_id_command = 0 ] +then + toolbox_skip_test $TEST "SKIPPING DUE TO LACK OF 'keyctl id'" + exit 0 +fi + result=PASS echo "++++ BEGINNING TEST" >$OUTPUTFILEtests/keyctl/id/valid/runtest.sh +6
-0@@ -6,6 +6,12 @@ # ---- do the actual testing ---- +if [ $have_id_command = 0 ] +then + toolbox_skip_test $TEST "SKIPPING DUE TO LACK OF 'keyctl id'" + exit 0 +fi + result=PASS echo "++++ BEGINNING TEST" >$OUTPUTFILEtests/keyctl/move/bad-args/runtest.sh +6
-0@@ -6,6 +6,12 @@ # ---- do the actual testing ---- +if [ $have_move_key = 0 ] +then + toolbox_skip_test $TEST "SKIPPING DUE TO LACK OF 'keyctl move'" + exit 0 +fi + result=PASS echo "++++ BEGINNING TEST" >$OUTPUTFILEtests/keyctl/move/noargs/runtest.sh +6
-0@@ -6,6 +6,12 @@ # ---- do the actual testing ---- +if [ $have_move_key = 0 ] +then + toolbox_skip_test $TEST "SKIPPING DUE TO LACK OF 'keyctl move'" + exit 0 +fi + result=PASS echo "++++ BEGINNING TEST" >$OUTPUTFILEtests/keyctl/move/recursion/runtest.sh +6
-0@@ -6,6 +6,12 @@ # ---- do the actual testing ---- +if [ $have_move_key = 0 ] +then + toolbox_skip_test $TEST "SKIPPING DUE TO LACK OF 'keyctl move'" + exit 0 +fi + result=PASS echo "++++ BEGINNING TEST" >$OUTPUTFILEtests/keyctl/move/valid/runtest.sh +6
-0@@ -6,6 +6,12 @@ # ---- do the actual testing ---- +if [ $have_move_key = 0 ] +then + toolbox_skip_test $TEST "SKIPPING DUE TO LACK OF 'keyctl move'" + exit 0 +fi + result=PASS echo "++++ BEGINNING TEST" >$OUTPUTFILEtests/keyctl/session/valid2/runtest.sh +6
-0@@ -6,6 +6,12 @@ # ---- do the actual testing ---- +if [ $have_id_command = 0 ] +then + toolbox_skip_test $TEST "SKIPPING DUE TO LACK OF 'keyctl id'" + exit 0 +fi + result=PASS echo "++++ BEGINNING TEST" >$OUTPUTFILEtests/keyctl/supports/bad-args/runtest.sh +6
-0@@ -6,6 +6,12 @@ # ---- do the actual testing ---- +if [ $have_capabilities = 0 ] +then + toolbox_skip_test $TEST "SKIPPING DUE TO LACK OF 'keyctl supports'" + exit 0 +fi + result=PASS echo "++++ BEGINNING TEST" >$OUTPUTFILEtests/keyctl/supports/valid/runtest.sh +6
-0@@ -6,6 +6,12 @@ # ---- do the actual testing ---- +if [ $have_capabilities = 0 ] +then + toolbox_skip_test $TEST "SKIPPING DUE TO LACK OF 'keyctl supports'" + exit 0 +fi + result=PASS echo "++++ BEGINNING TEST" >$OUTPUTFILEtests/prepare.inc.sh +22
-1@@ -112,11 +112,14 @@ then esac fi +have_capabilities=0 have_key_invalidate=0 have_big_key_type=0 have_dh_compute=0 -have_restrict_keyring=0 +have_move_key=0 have_notify=0 +have_public_key=0 +have_restrict_keyring=0 if keyctl supports capabilities >&/dev/null then@@ -179,3 +182,21 @@ if [ "$SKIPINSTALLREQ" = "yes" ] then skip_install_required=1 fi + +# +# Check if "keyctl id" is supported +# +have_id_command=0 +if keyutils_at_or_later_than 1.6.2 +then + have_id_command=1 +fi + +# +# Check if "keyctl pkey_*" are supported +# +have_pkey_commands=0 +if keyutils_at_or_later_than 1.6 +then + have_pkey_commands=1 +fitests/toolbox.inc.sh +20
-6@@ -613,8 +613,15 @@ function create_key () my_keyring=$4 fi - echo keyctl add "$@" >>$OUTPUTFILE - keyctl add "$@" >>$OUTPUTFILE 2>&1 + if [ "$1" = "-x" ] && version_less_than $OSRELEASE 9 + then + shift + echo perl ../../../hex2bin.pl "$3" "|" keyctl padd "$1 $2 $4" >>$OUTPUTFILE + perl ../../../hex2bin.pl "$3" | keyctl padd "$1" "$2" "$4" >>$OUTPUTFILE + else + echo keyctl add "$@" >>$OUTPUTFILE + keyctl add "$@" >>$OUTPUTFILE 2>&1 + fi e=$? if [ $e == $my_exitval ] then@@ -682,8 +689,15 @@ function pcreate_key () my_keyring=$3 fi - echo echo -n $data \| keyctl padd "$@" >>$OUTPUTFILE - echo -n $data | keyctl padd "$@" >>$OUTPUTFILE 2>&1 + if [ "$1" = "-x" ] && version_less_than $OSRELEASE 9 + then + shift + echo echo -n $data \| perl ../../../hex2bin.pl "|" keyctl padd "$@" >>$OUTPUTFILE + echo -n $data | perl ../../../hex2bin.pl - | keyctl padd "$@" >>$OUTPUTFILE + else + echo echo -n $data \| keyctl padd "$@" >>$OUTPUTFILE + echo -n $data | keyctl padd "$@" >>$OUTPUTFILE 2>&1 + fi e=$? if [ $e == $my_exitval ] then@@ -1232,8 +1246,15 @@ function update_key () shift fi - echo keyctl update "$@" >>$OUTPUTFILE - keyctl update "$@" >>$OUTPUTFILE 2>&1 + if [ "x$1" = "x-x" ] && version_less_than $OSRELEASE 9 + then
tests/toolbox.inc.sh function update_key () · line 1260
Quoted 10 lines
tests/toolbox.inc.sh +7
-0+ shift + echo perl ../../../hex2bin.pl "$2" "|" keyctl pupdate "$1" >>$OUTPUTFILE + perl ../../../hex2bin.pl "$2" | keyctl pupdate "$1" >>$OUTPUTFILE + else + echo keyctl update "$@" >>$OUTPUTFILE + keyctl update "$@" >>$OUTPUTFILE 2>&1 + fi e=$? if [ $e == $my_exitval ] then
LGTM
Reviewed-by Jarkko Sakkinen <[email protected]>
BR, Jarkko