All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH keyutils] tests: Add skips for testing of unsupported features
@ 2025-04-24 10:44 David Howells
  2025-04-30 16:05 ` Jarkko Sakkinen
  0 siblings, 1 reply; 2+ messages in thread
From: David Howells @ 2025-04-24 10:44 UTC (permalink / raw)
  To: Jarkko Sakkinen; +Cc: dhowells, keyrings

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 <dhowells@redhat.com>
---
 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(-)

diff --git a/tests/features/limits/runtest.sh b/tests/features/limits/runtest.sh
index 3af2f5a..7642071 100644
--- a/tests/features/limits/runtest.sh
+++ b/tests/features/limits/runtest.sh
@@ -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`
diff --git a/tests/hex2bin.pl b/tests/hex2bin.pl
new file mode 100644
index 0000000..4f0f27a
--- /dev/null
+++ b/tests/hex2bin.pl
@@ -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);
+}
diff --git a/tests/keyctl/id/bad-args/runtest.sh b/tests/keyctl/id/bad-args/runtest.sh
index 957d1a5..bba62c6 100644
--- a/tests/keyctl/id/bad-args/runtest.sh
+++ b/tests/keyctl/id/bad-args/runtest.sh
@@ -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
 
diff --git a/tests/keyctl/id/noargs/runtest.sh b/tests/keyctl/id/noargs/runtest.sh
index aff9de6..b95c596 100644
--- a/tests/keyctl/id/noargs/runtest.sh
+++ b/tests/keyctl/id/noargs/runtest.sh
@@ -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
 
diff --git a/tests/keyctl/id/valid/runtest.sh b/tests/keyctl/id/valid/runtest.sh
index ffed995..2c06b3d 100644
--- a/tests/keyctl/id/valid/runtest.sh
+++ b/tests/keyctl/id/valid/runtest.sh
@@ -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
 
diff --git a/tests/keyctl/move/bad-args/runtest.sh b/tests/keyctl/move/bad-args/runtest.sh
index b1c7e66..9410941 100644
--- a/tests/keyctl/move/bad-args/runtest.sh
+++ b/tests/keyctl/move/bad-args/runtest.sh
@@ -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
 
diff --git a/tests/keyctl/move/noargs/runtest.sh b/tests/keyctl/move/noargs/runtest.sh
index 29a91f1..8ad91e9 100644
--- a/tests/keyctl/move/noargs/runtest.sh
+++ b/tests/keyctl/move/noargs/runtest.sh
@@ -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
 
diff --git a/tests/keyctl/move/recursion/runtest.sh b/tests/keyctl/move/recursion/runtest.sh
index 36cd5cb..8b90be8 100644
--- a/tests/keyctl/move/recursion/runtest.sh
+++ b/tests/keyctl/move/recursion/runtest.sh
@@ -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
 
diff --git a/tests/keyctl/move/valid/runtest.sh b/tests/keyctl/move/valid/runtest.sh
index 31b51d7..20ccff2 100644
--- a/tests/keyctl/move/valid/runtest.sh
+++ b/tests/keyctl/move/valid/runtest.sh
@@ -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
 
diff --git a/tests/keyctl/session/valid2/runtest.sh b/tests/keyctl/session/valid2/runtest.sh
index 12ad234..1642395 100644
--- a/tests/keyctl/session/valid2/runtest.sh
+++ b/tests/keyctl/session/valid2/runtest.sh
@@ -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
 
diff --git a/tests/keyctl/supports/bad-args/runtest.sh b/tests/keyctl/supports/bad-args/runtest.sh
index 05581a4..f87f517 100644
--- a/tests/keyctl/supports/bad-args/runtest.sh
+++ b/tests/keyctl/supports/bad-args/runtest.sh
@@ -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
 
diff --git a/tests/keyctl/supports/valid/runtest.sh b/tests/keyctl/supports/valid/runtest.sh
index 2c62ef2..4e41200 100644
--- a/tests/keyctl/supports/valid/runtest.sh
+++ b/tests/keyctl/supports/valid/runtest.sh
@@ -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
 
diff --git a/tests/prepare.inc.sh b/tests/prepare.inc.sh
index 4033d69..be134da 100644
--- a/tests/prepare.inc.sh
+++ b/tests/prepare.inc.sh
@@ -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
diff --git a/tests/toolbox.inc.sh b/tests/toolbox.inc.sh
index 6f4fb18..212b353 100644
--- a/tests/toolbox.inc.sh
+++ b/tests/toolbox.inc.sh
@@ -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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH keyutils] tests: Add skips for testing of unsupported features
  2025-04-24 10:44 [PATCH keyutils] tests: Add skips for testing of unsupported features David Howells
@ 2025-04-30 16:05 ` Jarkko Sakkinen
  0 siblings, 0 replies; 2+ messages in thread
From: Jarkko Sakkinen @ 2025-04-30 16:05 UTC (permalink / raw)
  To: David Howells; +Cc: keyrings

On Thu, Apr 24, 2025 at 11:44:40AM +0100, David Howells wrote:
> 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 <dhowells@redhat.com>
> ---
>  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(-)
> 
> diff --git a/tests/features/limits/runtest.sh b/tests/features/limits/runtest.sh
> index 3af2f5a..7642071 100644
> --- a/tests/features/limits/runtest.sh
> +++ b/tests/features/limits/runtest.sh
> @@ -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`
> diff --git a/tests/hex2bin.pl b/tests/hex2bin.pl
> new file mode 100644
> index 0000000..4f0f27a
> --- /dev/null
> +++ b/tests/hex2bin.pl
> @@ -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);
> +}
> diff --git a/tests/keyctl/id/bad-args/runtest.sh b/tests/keyctl/id/bad-args/runtest.sh
> index 957d1a5..bba62c6 100644
> --- a/tests/keyctl/id/bad-args/runtest.sh
> +++ b/tests/keyctl/id/bad-args/runtest.sh
> @@ -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
>  
> diff --git a/tests/keyctl/id/noargs/runtest.sh b/tests/keyctl/id/noargs/runtest.sh
> index aff9de6..b95c596 100644
> --- a/tests/keyctl/id/noargs/runtest.sh
> +++ b/tests/keyctl/id/noargs/runtest.sh
> @@ -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
>  
> diff --git a/tests/keyctl/id/valid/runtest.sh b/tests/keyctl/id/valid/runtest.sh
> index ffed995..2c06b3d 100644
> --- a/tests/keyctl/id/valid/runtest.sh
> +++ b/tests/keyctl/id/valid/runtest.sh
> @@ -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
>  
> diff --git a/tests/keyctl/move/bad-args/runtest.sh b/tests/keyctl/move/bad-args/runtest.sh
> index b1c7e66..9410941 100644
> --- a/tests/keyctl/move/bad-args/runtest.sh
> +++ b/tests/keyctl/move/bad-args/runtest.sh
> @@ -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
>  
> diff --git a/tests/keyctl/move/noargs/runtest.sh b/tests/keyctl/move/noargs/runtest.sh
> index 29a91f1..8ad91e9 100644
> --- a/tests/keyctl/move/noargs/runtest.sh
> +++ b/tests/keyctl/move/noargs/runtest.sh
> @@ -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
>  
> diff --git a/tests/keyctl/move/recursion/runtest.sh b/tests/keyctl/move/recursion/runtest.sh
> index 36cd5cb..8b90be8 100644
> --- a/tests/keyctl/move/recursion/runtest.sh
> +++ b/tests/keyctl/move/recursion/runtest.sh
> @@ -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
>  
> diff --git a/tests/keyctl/move/valid/runtest.sh b/tests/keyctl/move/valid/runtest.sh
> index 31b51d7..20ccff2 100644
> --- a/tests/keyctl/move/valid/runtest.sh
> +++ b/tests/keyctl/move/valid/runtest.sh
> @@ -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
>  
> diff --git a/tests/keyctl/session/valid2/runtest.sh b/tests/keyctl/session/valid2/runtest.sh
> index 12ad234..1642395 100644
> --- a/tests/keyctl/session/valid2/runtest.sh
> +++ b/tests/keyctl/session/valid2/runtest.sh
> @@ -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
>  
> diff --git a/tests/keyctl/supports/bad-args/runtest.sh b/tests/keyctl/supports/bad-args/runtest.sh
> index 05581a4..f87f517 100644
> --- a/tests/keyctl/supports/bad-args/runtest.sh
> +++ b/tests/keyctl/supports/bad-args/runtest.sh
> @@ -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
>  
> diff --git a/tests/keyctl/supports/valid/runtest.sh b/tests/keyctl/supports/valid/runtest.sh
> index 2c62ef2..4e41200 100644
> --- a/tests/keyctl/supports/valid/runtest.sh
> +++ b/tests/keyctl/supports/valid/runtest.sh
> @@ -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
>  
> diff --git a/tests/prepare.inc.sh b/tests/prepare.inc.sh
> index 4033d69..be134da 100644
> --- a/tests/prepare.inc.sh
> +++ b/tests/prepare.inc.sh
> @@ -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
> diff --git a/tests/toolbox.inc.sh b/tests/toolbox.inc.sh
> index 6f4fb18..212b353 100644
> --- a/tests/toolbox.inc.sh
> +++ b/tests/toolbox.inc.sh
> @@ -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
> 

LGTM

Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>

BR, Jarkko

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-04-30 16:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-24 10:44 [PATCH keyutils] tests: Add skips for testing of unsupported features David Howells
2025-04-30 16:05 ` Jarkko Sakkinen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.