From 784550e563b3b1f620be4bf0480b5ec3eab78c69 Mon Sep 17 00:00:00 2001 From: jiawenhao Date: Fri, 18 Apr 2025 12:26:12 +0800 Subject: [PATCH] test: Fix test expectation based on kernel config https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/keyutils.git/commit/?id=c076dff259e99d84d3822b4d2ad7f3f66532f411 Signed-off-by: jiawenhao --- ...t-expectation-based-on-kernel-config.patch | 74 +++++++++++++++++++ keyutils.spec | 6 +- 2 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 backport-fix-test-expectation-based-on-kernel-config.patch diff --git a/backport-fix-test-expectation-based-on-kernel-config.patch b/backport-fix-test-expectation-based-on-kernel-config.patch new file mode 100644 index 0000000..26a09eb --- /dev/null +++ b/backport-fix-test-expectation-based-on-kernel-config.patch @@ -0,0 +1,74 @@ +From 78612517fb54d1e104556e43a65f0111caac7834 Mon Sep 17 00:00:00 2001 +From: jiawenhao +Date: Thu, 17 Apr 2025 19:33:12 +0800 +Subject: [PATCH] fix-test-expectation-based-on-kernel-config + +--- + tests/features/builtin_trusted/runtest.sh | 12 ++++++++++-- + tests/prepare.inc.sh | 20 ++++++++++++++++++++ + 2 files changed, 30 insertions(+), 2 deletions(-) + +diff --git a/tests/features/builtin_trusted/runtest.sh b/tests/features/builtin_trusted/runtest.sh +index 27910b5..6bd073b 100644 +--- a/tests/features/builtin_trusted/runtest.sh ++++ b/tests/features/builtin_trusted/runtest.sh +@@ -33,7 +33,11 @@ expect_error EACCES + create_key --fail user a a $stk + expect_error EOPNOTSUPP + create_key --fail user a a $blk +-expect_error EACCES ++if has_kernel_config "CONFIG_SYSTEM_BLACKLIST_AUTH_UPDATE"; then ++ expect_error EOPNOTSUPP ++else ++ expect_error EACCES ++fi + + # Try adding a key to the keyrings + marker "TRY ADDING ASYMMETRIC KEYS" +@@ -89,7 +93,11 @@ expect_error EACCES + create_key --fail -x asymmetric "" "$x509" $stk + expect_error ENOKEY + create_key --fail -x asymmetric "" "$x509" $blk +-expect_error EACCES ++if has_kernel_config "CONFIG_SYSTEM_BLACKLIST_AUTH_UPDATE"; then ++ expect_error EOPNOTSUPP ++else ++ expect_error EACCES ++fi + + echo "++++ FINISHED TEST: $result" >>$OUTPUTFILE + +diff --git a/tests/prepare.inc.sh b/tests/prepare.inc.sh +index 0b66237..4033d69 100644 +--- a/tests/prepare.inc.sh ++++ b/tests/prepare.inc.sh +@@ -4,6 +4,26 @@ + includes=${BASH_SOURCE[0]} + includes=${includes%/*}/ + ++# Check if currently running kernel has option set ++function has_kernel_config() ++{ ++ local option=$1 ++ local uname=$(uname -r) ++ local config_list="$KCONFIG_PATH ++ /lib/modules/$uname/build/.config ++ /boot/config-$uname ++ /lib/kernel/config-$uname" ++ ++ for config in $config_list; do ++ [ ! -f $config ] && continue ++ grep -qE "^${option}=[my]" $config ++ return ++ done ++ ++ echo "Failed to find kernel configuration file" ++ return false ++} ++ + # --- need to run in own session keyring + watch_fd=0 + if [ "$1" != "--inside-test-session" ] +-- +2.27.0 + diff --git a/keyutils.spec b/keyutils.spec index dd5740e..4412b9e 100644 --- a/keyutils.spec +++ b/keyutils.spec @@ -1,6 +1,6 @@ Name: keyutils Version: 1.6.3 -Release: 8 +Release: 9 Summary: Utilities of Linux Key Management License: GPLv2+ and LGPLv2+ @@ -11,6 +11,7 @@ Patch9000: bugfix-fix-argv-string-out-of-bounds.patch Patch9001: backport-fix-a-formatting-on-the-keyctl.1-man-page.patch Patch9002: backport-fix-format-specifier-for-pointer-subtraction.patch Patch9003: backport-provide-a-pkgconfig-file-with-libkeyutils.a.patch +Patch9004: backport-fix-test-expectation-based-on-kernel-config.patch BuildRequires: gcc gcc-c++ BuildRequires: glibc-kernheaders >= 2.4-9.1.92 @@ -99,6 +100,9 @@ make \ %{_mandir}/man*/* %changelog +* Fri Apr 18 2025 jiawenhao - 1.6.3-9 +- DESC: Fix test expectation based on kernel config + * Fri Apr 18 2025 jiawenhao - 1.6.3-8 - DESC: Provide a pkgconfig file with libkeyutils.a