[PATCH v2] ktest: Check kernelrelease return in get_version
From: Ricardo B. Marliere
Date: Thu Dec 05 2024 - 15:50:55 EST
In the case of a test that uses the special option ${KERNEL_VERSION} in one
of its settings but has no configuration available in ${OUTPUT_DIR}, for
example if it's a new empty directory, then the `make kernelrelease` call
will fail and the subroutine will chomp an empty string, silently. Fix that
by adding an empty configuration and retrying.
Signed-off-by: Ricardo B. Marliere <rbm@xxxxxxxx>
---
Changes in v2:
- Fixed the if statement to use length()
- Link to v1: https://lore.kernel.org/r/20241205-ktest_kver_fallback-v1-1-8029b9189527@xxxxxxxx
---
tools/testing/ktest/ktest.pl | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl
index dacad94e2be42a86f9680fcb50b65d1f3a78afb5..171262915636b6287e6639e95be5420b5bc8e0df 100755
--- a/tools/testing/ktest/ktest.pl
+++ b/tools/testing/ktest/ktest.pl
@@ -2419,6 +2419,11 @@ sub get_version {
return if ($have_version);
doprint "$make kernelrelease ... ";
$version = `$make -s kernelrelease | tail -1`;
+ if (!length($version)) {
+ run_command "$make allnoconfig" or return 0;
+ doprint "$make kernelrelease ... ";
+ $version = `$make -s kernelrelease | tail -1`;
+ }
chomp($version);
doprint "$version\n";
$have_version = 1;
---
base-commit: 9d6a414ad31e8eb296cd6f2c1834b2c6994960a0
change-id: 20241205-ktest_kver_fallback-d42e62fb8d88
Best regards,
--
Ricardo B. Marliere <rbm@xxxxxxxx>