Skip to contentSkip to conversation

selftests: run_kselftest.sh cleanup and fixes

PATCH In review Ricardo B. Marlière 3 participants 28 messages Mar 20 – Apr 17

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover selftests: run_kselftest.sh cleanup and fixes

Hi Shuah,

Please consider merging the following patches. They are mostly small fixes to run_kselftest.sh, plus one feature: adding the option of passing a directory to the "-p --per-test-log" argument.

There is a small corner case spotted in tools/testing/selftests/Makefile regarding failing sub-targets, and also the removal of the default install directory for out of tree builds in the top-level Makefile.

Thank you!

---
Ricardo B. Marlière (6):
selftests/run_kselftest.sh: Remove unused $ROOT selftests/run_kselftest.sh: Add missing quotes selftests/run_kselftest.sh: Resolve BASE_DIR with pwd -P selftests/run_kselftest.sh: Allow choosing per-test log directory
selftests: Preserve subtarget failures in all/install
kbuild: remove kselftest output in mrproper

 Makefile                                    |  1 +
 tools/testing/selftests/Makefile            |  8 ++---
 tools/testing/selftests/kselftest/runner.sh |  3 +-
 tools/testing/selftests/run_kselftest.sh    | 46 +++++++++++++++++++++--------
 4 files changed, 40 insertions(+), 18 deletions(-)

---
base-commit: c612261bedd6bbab7109f798715e449c9d20ff2f
change-id: 20260320-selftests-fixes-dad2b1df50d9

Best regards,

Signature · 1 line
Ricardo B. Marlière <[email protected]>
#1 lore raw

PATCH 1/6 selftests/run_kselftest.sh: Remove unused $ROOT

Fix the following shellcheck warning:

ROOT appears unused. Verify use (or export if used externally). [SC2034]

---
 tools/testing/selftests/run_kselftest.sh | 1 -
 1 file changed, 1 deletion(-)
tools/testing/selftests/run_kselftest.sh +0 -1
index 84d45254675c..9abea79018d7 100755
@@ -21,7 +21,6 @@ else
 fi
 
 . ./kselftest/runner.sh
-ROOT=$PWD
 
 usage()
 {
Signature · 1 line
2.53.0
#2 lore raw

PATCH 2/6 selftests/run_kselftest.sh: Add missing quotes

In reply to Ricardo B. Marlière

Fix the following shellcheck warning:

Double quote to prevent globbing and word splitting. [SC2086]

---
 tools/testing/selftests/run_kselftest.sh | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
tools/testing/selftests/run_kselftest.sh +4 -4
index 9abea79018d7..b782b025d002 100755
@@ -11,7 +11,7 @@ else
         BASE_DIR=$(readlink -f $(dirname $0))
 fi
 
-cd $BASE_DIR
+cd "$BASE_DIR"
 TESTS="$BASE_DIR"/kselftest-list.txt
 if [ ! -r "$TESTS" ] ; then
 	echo "$0: Could not find list of tests to run ($TESTS)" >&2
@@ -38,7 +38,7 @@ Usage: $0 [OPTIONS]
   -h | --help			Show this usage info
   -o | --override-timeout	Number of seconds after which we timeout
 EOF
-	exit $1
+	exit "$1"
 }
 
 COLLECTIONS=""
@@ -51,7 +51,7 @@ while true; do
 	case "$1" in
 		-s | --summary)
 			logfile="$BASE_DIR"/output.log
-			cat /dev/null > $logfile
+			cat /dev/null > "$logfile"
 			shift ;;
 		-p | --per-test-log)
 			per_test_logging=1
@@ -127,7 +127,7 @@ collections=$(echo "$available" | cut -d: -f1 | sort | uniq)
 for collection in $collections ; do
 	[ -w /dev/kmsg ] && echo "kselftest: Running tests in $collection" >> /dev/kmsg
 	tests=$(echo "$available" | grep "^$collection:" | cut -d: -f2)
-	($dryrun cd "$collection" && $dryrun run_many $tests)
+	($dryrun cd "$collection" && $dryrun run_many "$tests")
 done
 
 failures="$(cat "$kselftest_failures_file")"
Signature · 1 line
2.53.0
#3 lore raw

PATCH 3/6 selftests/run_kselftest.sh: Resolve BASE_DIR with pwd -P

In reply to Ricardo B. Marlière

run_kselftest.sh only needs to canonicalize the directory containing the script itself. Use shell-native path resolution for that by changing into the directory and calling pwd -P.

This avoids depending on either realpath or readlink -f while still producing a physical absolute path for BASE_DIR.

---
 tools/testing/selftests/run_kselftest.sh | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
tools/testing/selftests/run_kselftest.sh +1 -6
index b782b025d002..5f7bce9a640b 100755
@@ -4,12 +4,7 @@
 # Run installed kselftest tests.
 #
 
-# Fallback to readlink if realpath is not available
-if which realpath > /dev/null; then
-        BASE_DIR=$(realpath $(dirname $0))
-else
-        BASE_DIR=$(readlink -f $(dirname $0))
-fi
+BASE_DIR=$(cd "$(dirname "$0")" && pwd -P)
 
 cd "$BASE_DIR"
 TESTS="$BASE_DIR"/kselftest-list.txt
Signature · 1 line
2.53.0
#4 lore raw

PATCH 4/6 selftests/run_kselftest.sh: Allow choosing per-test log directory

In reply to Ricardo B. Marlière

The --per-test-log option currently hard-codes /tmp. However, the system under test will most likely have tmpfs mounted there. Since it's not clear which filenames the log files will have, the user should be able to specify a persistent directory to store the logs. Keeping those logs are important because the run_kselftest.sh runner will only yield KTAP output, trimming information that is otherwise available through running individual tests directly.

Allow --per-test-log to take an optional directory argument. Keep the existing behaviour when the option is passed without an argument, but if a directory is provided, create it if needed, reject non-directory paths and non-writable directories, canonicalize it, and have runner.sh write per-test logs there instead of /tmp.

This also makes relative paths safe by resolving them before the runner changes into a collection directory.

---
 tools/testing/selftests/kselftest/runner.sh |  3 ++-
 tools/testing/selftests/run_kselftest.sh    | 30 +++++++++++++++++++++++++++--
 2 files changed, 30 insertions(+), 3 deletions(-)
tools/testing/selftests/kselftest/runner.sh +2 -1
index 3a62039fa621..6e13818fe433 100644
@@ -6,6 +6,7 @@ export skip_rc=4
 export timeout_rc=124
 export logfile=/dev/stdout
 export per_test_logging=
+export per_test_log_dir=/tmp
 export RUN_IN_NETNS=
 
 # Defaults for "settings" file fields:
@@ -189,7 +190,7 @@ run_many()
 		BASENAME_TEST=$(basename $TEST)
 		test_num=$(( test_num + 1 ))
 		if [ -n "$per_test_logging" ]; then
-			logfile="/tmp/$BASENAME_TEST"
+			logfile="$per_test_log_dir/$BASENAME_TEST"
 			cat /dev/null > "$logfile"
 		fi
 		if [ -n "$RUN_IN_NETNS" ]; then
tools/testing/selftests/run_kselftest.sh +28 -2
index 5f7bce9a640b..fdbbe5b8b079 100755
@@ -22,7 +22,7 @@ usage()
 	cat <<EOF
 Usage: $0 [OPTIONS]
   -s | --summary		Print summary with detailed log in output.log (conflict with -p)
-  -p | --per-test-log		Print test log in /tmp with each test name (conflict with -s)
+  -p | --per-test-log [DIR]	Print test log in /tmp or DIR with each test name (conflict with -s)
   -t | --test COLLECTION:TEST	Run TEST from COLLECTION
   -S | --skip COLLECTION:TEST	Skip TEST from COLLECTION
   -c | --collection COLLECTION	Run all tests from COLLECTION
@@ -50,7 +50,33 @@ while true; do
 			shift ;;
 		-p | --per-test-log)
 			per_test_logging=1
-			shift ;;
+			if [ -n "$2" ] && [ "${2#-}" = "$2" ]; then
+				per_test_log_dir="$2"
+				if [ -e "$per_test_log_dir" ] && [ ! -d "$per_test_log_dir" ]; then
+					echo "Per-test log path is not a dir:" \
+					     "$per_test_log_dir" >&2
+					exit 1
+				fi
+				if [ ! -d "$per_test_log_dir" ] && \
+				   ! mkdir -p "$per_test_log_dir"; then
+					echo "Could not create log dir:" \
+					     "$per_test_log_dir" >&2
+					exit 1
+				fi
+				per_test_log_dir=$(cd "$per_test_log_dir" && pwd -P)
+				if [ -z "$per_test_log_dir" ]; then
+					echo "Could not resolve per-test log directory" >&2
+					exit 1
+				fi
+				if [ ! -w "$per_test_log_dir" ]; then
+					echo "Per-test log dir is not writable:" \
+					     "$per_test_log_dir" >&2
+					exit 1
+				fi
+				shift 2
+			else
+				shift
+			fi ;;
 		-t | --test)
 			TESTS="$TESTS $2"
 			shift 2 ;;
Signature · 1 line
2.53.0
#5 lore raw

PATCH 5/6 selftests: Preserve subtarget failures in all/install

In reply to Ricardo B. Marlière

Track failures explicitly in the top-level selftests all/install loops.

The current code multiplies ret by each sub-make exit status. For example, with TARGETS=net, the implicit net/lib dependency runs after net, so a failed net build can be followed by a successful net/lib build and reset the final result to success.

Set ret to 1 on any non-zero sub-make exit code and keep it sticky, so the top-level make returns failure when any selected selftest target fails.

---
 tools/testing/selftests/Makefile | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
tools/testing/selftests/Makefile +4 -4
index 450f13ba4cca..0949f370ad78 100644
@@ -209,14 +209,14 @@ export KHDR_INCLUDES
 .DEFAULT_GOAL := all
 
 all:
-	@ret=1;							\
+	@ret=0;							\
 	for TARGET in $(TARGETS) $(INSTALL_DEP_TARGETS); do	\
 		BUILD_TARGET=$$BUILD/$$TARGET;			\
 		mkdir $$BUILD_TARGET  -p;			\
 		$(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET	\
 				O=$(abs_objtree)		\
 				$(if $(FORCE_TARGETS),|| exit);	\
-		ret=$$((ret * $$?));				\
+		[ $$? -eq 0 ] || ret=1;			\
 	done; exit $$ret;
 
 run_tests: all
@@ -274,7 +274,7 @@ ifdef INSTALL_PATH
 	install -m 744 kselftest/ksft.py $(INSTALL_PATH)/kselftest/
 	install -m 744 run_kselftest.sh $(INSTALL_PATH)/
 	rm -f $(TEST_LIST)
-	@ret=1;	\
+	@ret=0;	\
 	for TARGET in $(TARGETS) $(INSTALL_DEP_TARGETS); do \
 		BUILD_TARGET=$$BUILD/$$TARGET;	\
 		$(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET install \
@@ -283,7 +283,7 @@ ifdef INSTALL_PATH
 				OBJ_PATH=$(INSTALL_PATH) \
 				O=$(abs_objtree)		\
 				$(if $(FORCE_TARGETS),|| exit);	\
-		ret=$$((ret * $$?));		\
+		[ $$? -eq 0 ] || ret=1;		\
 	done; exit $$ret;
 
 
Signature · 1 line
2.53.0
#6 lore raw

Re: [PATCH 5/6] selftests: Preserve subtarget failures in all/install

Quoted 10 lines · Ricardo B. Marlière

Track failures explicitly in the top-level selftests all/install loops.

The current code multiplies ret by each sub-make exit status. For example, with TARGETS=net, the implicit net/lib dependency runs after net, so a failed net build can be followed by a successful net/lib build and reset the final result to success.

Set ret to 1 on any non-zero sub-make exit code and keep it sticky, so the top-level make returns failure when any selected selftest target fails.

This patch, which is now in mainline as 7e47389142b8, is breaking a bunch of CI systems - at least KernelCI, our Arm internal CI and my personal stuff. It causes the equivalent of FORCE_TARGETS behaviour in the top level Makefile, the prior behaviour where the exit status of the top level Makefile ignores failures from individual directories is desirable since by default we try to build almost all the selftests but between quality issues and build time dependencies it's very common for at least one of them to fail. With this commit unless the user has configured a more restricted set of selftests it would be surprising if we manage to get a successful build and install.

As well as being a poor default due to the very high likelyhood of build failures this also has the undesirable effect of causing a build failure in one selftest to cause the whole install target to fail, meaning that the build failure is escallated to a complete lost of coverge for all selftests in common CI usage.

This wasn't showing up in my -next build tests since I set FORCE_TARGETS and explicitly choose a restricted set of kselftests which actually build with my system and configuration. It was less obvious than it should have been with the other systems since they did not expect there to be a complete failure to generate a kselftest tarball and variously masked the error or reported it in a manner that looked like an infrastructure issue.

It would be really nice to get to the point where we can reasonably do this but we're simply not there at the current time. At the moment if people want to see build failures reported at the top level that really needs to be opt in, we have FORCE_TARGETS for that.

maintainer
#7 lore raw

Re: [PATCH 5/6] selftests: Preserve subtarget failures in all/install

Quoted 29 lines · Mark Brown
Quoted 10 lines · Ricardo B. Marlière

Track failures explicitly in the top-level selftests all/install loops.

The current code multiplies ret by each sub-make exit status. For example, with TARGETS=net, the implicit net/lib dependency runs after net, so a failed net build can be followed by a successful net/lib build and reset the final result to success.

Set ret to 1 on any non-zero sub-make exit code and keep it sticky, so the top-level make returns failure when any selected selftest target fails.

This patch, which is now in mainline as 7e47389142b8, is breaking a bunch of CI systems - at least KernelCI, our Arm internal CI and my personal stuff. It causes the equivalent of FORCE_TARGETS behaviour in the top level Makefile, the prior behaviour where the exit status of the top level Makefile ignores failures from individual directories is desirable since by default we try to build almost all the selftests but between quality issues and build time dependencies it's very common for at least one of them to fail. With this commit unless the user has configured a more restricted set of selftests it would be surprising if we manage to get a successful build and install.

As well as being a poor default due to the very high likelyhood of build failures this also has the undesirable effect of causing a build failure in one selftest to cause the whole install target to fail, meaning that the build failure is escallated to a complete lost of coverge for all selftests in common CI usage.

Quoted 7 lines

This wasn't showing up in my -next build tests since I set FORCE_TARGETS and explicitly choose a restricted set of kselftests which actually build with my system and configuration. It was less obvious than it should have been with the other systems since they did not expect there to be a complete failure to generate a kselftest tarball and variously masked the error or reported it in a manner that looked like an infrastructure issue.

I didn't see it when I did test on linux-next and my repo. I did install to catch problems.

Sorry for not catching this. We can drop this patch.

Quoted 5 lines

It would be really nice to get to the point where we can reasonably do this but we're simply not there at the current time. At the moment if people want to see build failures reported at the top level that really needs to be opt in, we have FORCE_TARGETS for that.

Good point - I will go look and see if we document this in kselftest doc and add it.

Mark, would you like to a revert for this?

thanks,
-- Shuah

#8 lore raw

Re: [PATCH 5/6] selftests: Preserve subtarget failures in all/install

Quoted 44 lines · Shuah Khan
Quoted 29 lines · Mark Brown
Quoted 10 lines · Ricardo B. Marlière

Track failures explicitly in the top-level selftests all/install loops.

The current code multiplies ret by each sub-make exit status. For example, with TARGETS=net, the implicit net/lib dependency runs after net, so a failed net build can be followed by a successful net/lib build and reset the final result to success.

Set ret to 1 on any non-zero sub-make exit code and keep it sticky, so the top-level make returns failure when any selected selftest target fails.

This patch, which is now in mainline as 7e47389142b8, is breaking a bunch of CI systems - at least KernelCI, our Arm internal CI and my personal stuff. It causes the equivalent of FORCE_TARGETS behaviour in the top level Makefile, the prior behaviour where the exit status of the top level Makefile ignores failures from individual directories is desirable since by default we try to build almost all the selftests but between quality issues and build time dependencies it's very common for at least one of them to fail. With this commit unless the user has configured a more restricted set of selftests it would be surprising if we manage to get a successful build and install.

As well as being a poor default due to the very high likelyhood of build failures this also has the undesirable effect of causing a build failure in one selftest to cause the whole install target to fail, meaning that the build failure is escallated to a complete lost of coverge for all selftests in common CI usage.

Quoted 7 lines

This wasn't showing up in my -next build tests since I set FORCE_TARGETS and explicitly choose a restricted set of kselftests which actually build with my system and configuration. It was less obvious than it should have been with the other systems since they did not expect there to be a complete failure to generate a kselftest tarball and variously masked the error or reported it in a manner that looked like an infrastructure issue.

I didn't see it when I did test on linux-next and my repo. I did install to catch problems.

Sorry for not catching this. We can drop this patch.

Quoted 1 line
Quoted 7 lines
Quoted 4 lines

It would be really nice to get to the point where we can reasonably do this but we're simply not there at the current time. At the moment if people want to see build failures reported at the top level that really needs to be opt in, we have FORCE_TARGETS for that.

Good point - I will go look and see if we document this in kselftest doc and add it.

It's not documented. It would have solved my issue, sorry for overlooking this!

Quoted 5 lines

Mark, would you like to a revert for this?

thanks,
-- Shuah

maintainer
#9 lore raw

Re: [PATCH 5/6] selftests: Preserve subtarget failures in all/install

Quoted 50 lines · Ricardo B. Marlière
Quoted 49 lines · Shuah Khan
Quoted 29 lines · Mark Brown
Quoted 10 lines · Ricardo B. Marlière

Track failures explicitly in the top-level selftests all/install loops.

The current code multiplies ret by each sub-make exit status. For example, with TARGETS=net, the implicit net/lib dependency runs after net, so a failed net build can be followed by a successful net/lib build and reset the final result to success.

Set ret to 1 on any non-zero sub-make exit code and keep it sticky, so the top-level make returns failure when any selected selftest target fails.

This patch, which is now in mainline as 7e47389142b8, is breaking a bunch of CI systems - at least KernelCI, our Arm internal CI and my personal stuff. It causes the equivalent of FORCE_TARGETS behaviour in the top level Makefile, the prior behaviour where the exit status of the top level Makefile ignores failures from individual directories is desirable since by default we try to build almost all the selftests but between quality issues and build time dependencies it's very common for at least one of them to fail. With this commit unless the user has configured a more restricted set of selftests it would be surprising if we manage to get a successful build and install.

As well as being a poor default due to the very high likelyhood of build failures this also has the undesirable effect of causing a build failure in one selftest to cause the whole install target to fail, meaning that the build failure is escallated to a complete lost of coverge for all selftests in common CI usage.

Quoted 7 lines

This wasn't showing up in my -next build tests since I set FORCE_TARGETS and explicitly choose a restricted set of kselftests which actually build with my system and configuration. It was less obvious than it should have been with the other systems since they did not expect there to be a complete failure to generate a kselftest tarball and variously masked the error or reported it in a manner that looked like an infrastructure issue.

I didn't see it when I did test on linux-next and my repo. I did install to catch problems.

Sorry for not catching this. We can drop this patch.

Quoted 5 lines

It would be really nice to get to the point where we can reasonably do this but we're simply not there at the current time. At the moment if people want to see build failures reported at the top level that really needs to be opt in, we have FORCE_TARGETS for that.

Quoted 5 lines
Quoted 2 lines

Good point - I will go look and see if we document this in kselftest doc and add it.

It's not documented. It would have solved my issue, sorry for overlooking this!

Ricardo, Would you like to send me doc patch for this?

thanks,
-- Shuah

#10 lore raw

Re: [PATCH 5/6] selftests: Preserve subtarget failures in all/install

Quoted 51 lines · Shuah Khan
Quoted 50 lines · Ricardo B. Marlière
Quoted 49 lines · Shuah Khan
Quoted 29 lines · Mark Brown
Quoted 10 lines · Ricardo B. Marlière

Track failures explicitly in the top-level selftests all/install loops.

The current code multiplies ret by each sub-make exit status. For example, with TARGETS=net, the implicit net/lib dependency runs after net, so a failed net build can be followed by a successful net/lib build and reset the final result to success.

Set ret to 1 on any non-zero sub-make exit code and keep it sticky, so the top-level make returns failure when any selected selftest target fails.

This patch, which is now in mainline as 7e47389142b8, is breaking a bunch of CI systems - at least KernelCI, our Arm internal CI and my personal stuff. It causes the equivalent of FORCE_TARGETS behaviour in the top level Makefile, the prior behaviour where the exit status of the top level Makefile ignores failures from individual directories is desirable since by default we try to build almost all the selftests but between quality issues and build time dependencies it's very common for at least one of them to fail. With this commit unless the user has configured a more restricted set of selftests it would be surprising if we manage to get a successful build and install.

As well as being a poor default due to the very high likelyhood of build failures this also has the undesirable effect of causing a build failure in one selftest to cause the whole install target to fail, meaning that the build failure is escallated to a complete lost of coverge for all selftests in common CI usage.

Quoted 7 lines

This wasn't showing up in my -next build tests since I set FORCE_TARGETS and explicitly choose a restricted set of kselftests which actually build with my system and configuration. It was less obvious than it should have been with the other systems since they did not expect there to be a complete failure to generate a kselftest tarball and variously masked the error or reported it in a manner that looked like an infrastructure issue.

I didn't see it when I did test on linux-next and my repo. I did install to catch problems.

Sorry for not catching this. We can drop this patch.

Quoted 5 lines

It would be really nice to get to the point where we can reasonably do this but we're simply not there at the current time. At the moment if people want to see build failures reported at the top level that really needs to be opt in, we have FORCE_TARGETS for that.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

Good point - I will go look and see if we document this in kselftest doc and add it.

It's not documented. It would have solved my issue, sorry for overlooking this!

Ricardo, Would you like to send me doc patch for this?

Sure, thanks!

Quoted 3 lines

thanks,
-- Shuah

#11 lore raw

Re: [PATCH 5/6] selftests: Preserve subtarget failures in all/install

In reply to Shuah Khan
Quoted 10 lines · Shuah Khan
Quoted 7 lines · Mark Brown

This wasn't showing up in my -next build tests since I set FORCE_TARGETS and explicitly choose a restricted set of kselftests which actually build with my system and configuration. It was less obvious than it should have been with the other systems since they did not expect there to be a complete failure to generate a kselftest tarball and variously masked the error or reported it in a manner that looked like an infrastructure issue.

Quoted 4 lines

I didn't see it when I did test on linux-next and my repo. I did install to catch problems.

Sorry for not catching this. We can drop this patch.

Yeah, it's easy to miss if you're set up to build everything.

Quoted 1 line

Mark, would you like to a revert for this?

Yes, I'll massage the text from my report into a changelog send something - it'll probably be tomorrow now.

maintainer
#12 lore raw

Re: [PATCH 5/6] selftests: Preserve subtarget failures in all/install

Quoted 14 lines · Mark Brown
Quoted 12 lines · Shuah Khan
Quoted 7 lines · Mark Brown

This wasn't showing up in my -next build tests since I set FORCE_TARGETS and explicitly choose a restricted set of kselftests which actually build with my system and configuration. It was less obvious than it should have been with the other systems since they did not expect there to be a complete failure to generate a kselftest tarball and variously masked the error or reported it in a manner that looked like an infrastructure issue.

I didn't see it when I did test on linux-next and my repo. I did install to catch problems.

Quoted 8 lines
Quoted 1 line

Sorry for not catching this. We can drop this patch.

Yeah, it's easy to miss if you're set up to build everything.

Quoted 1 line

Mark, would you like to a revert for this?

Yes, I'll massage the text from my report into a changelog send something - it'll probably be tomorrow now.

Thank you Mark

-- Shuah

#13 lore raw

Re: [PATCH 5/6] selftests: Preserve subtarget failures in all/install

In reply to Mark Brown
Quoted 6 lines · Mark Brown
Quoted 1 line · Shuah Khan

Mark, would you like to a revert for this?

Yes, I'll massage the text from my report into a changelog send something - it'll probably be tomorrow now.

Sending shortly, FWIW I'm also seeing a buch of issues with:

./run_kselftest.sh: 5: ./kselftest/runner.sh: Bad substitution ./run_kselftest.sh: 5: .: cannot open ./ktap_helpers.sh: No such file

maintainer
#14 lore raw

Re: [PATCH 5/6] selftests: Preserve subtarget failures in all/install

Quoted 5 lines · Mark Brown
Quoted 3 lines · Mark Brown
Quoted 1 line · Shuah Khan

Mark, would you like to a revert for this?

Quoted 7 lines
Quoted 2 lines

Yes, I'll massage the text from my report into a changelog send something - it'll probably be tomorrow now.

Sending shortly, FWIW I'm also seeing a buch of issues with:

./run_kselftest.sh: 5: ./kselftest/runner.sh: Bad substitution ./run_kselftest.sh: 5: .: cannot open ./ktap_helpers.sh: No such file

I will take a look and isolate the two commits that changes run_kselftest.sh - sorry for the trouble with CI this time around.

thanks,
-- Shuah

#15 lore raw

Re: [PATCH 5/6] selftests: Preserve subtarget failures in all/install

Quoted 10 lines · Shuah Khan
Quoted 4 lines · Mark Brown

Sending shortly, FWIW I'm also seeing a buch of issues with:

./run_kselftest.sh: 5: ./kselftest/runner.sh: Bad substitution ./run_kselftest.sh: 5: .: cannot open ./ktap_helpers.sh: No such file

I will take a look and isolate the two commits that changes run_kselftest.sh - sorry for the trouble with CI this time around.

Pretty sure it's 2964f6b816c2 (selftests: Use ktap helpers for runner.sh) - I've just put together a fix for that one, will throw it at my testing and send it later today all being well. It uses readlink -e which isn't implemented by busybox.

maintainer
#16 lore raw

Re: [PATCH 5/6] selftests: Preserve subtarget failures in all/install

Quoted 8 lines · Mark Brown
Quoted 6 lines · Shuah Khan
Quoted 4 lines · Mark Brown

Sending shortly, FWIW I'm also seeing a buch of issues with:

./run_kselftest.sh: 5: ./kselftest/runner.sh: Bad substitution ./run_kselftest.sh: 5: .: cannot open ./ktap_helpers.sh: No such file

Quoted 8 lines
Quoted 3 lines

I will take a look and isolate the two commits that changes run_kselftest.sh - sorry for the trouble with CI this time around.

Pretty sure it's 2964f6b816c2 (selftests: Use ktap helpers for runner.sh) - I've just put together a fix for that one, will throw it at my testing and send it later today all being well. It uses readlink -e which isn't implemented by busybox.

Yes 2964f6b816c2 is my first suspect with ktap_helpers.sh no such file. Thank you for fixing this. That way we can patch it and not revert it.

thanks,
-- SHuah

maintainer
#17 lore raw

Re: [PATCH 5/6] selftests: Preserve subtarget failures in all/install

Quoted 13 lines · Shuah Khan
Quoted 12 lines · Mark Brown
Quoted 10 lines · Shuah Khan
Quoted 4 lines · Mark Brown

Sending shortly, FWIW I'm also seeing a buch of issues with:

./run_kselftest.sh: 5: ./kselftest/runner.sh: Bad substitution ./run_kselftest.sh: 5: .: cannot open ./ktap_helpers.sh: No such file

I will take a look and isolate the two commits that changes run_kselftest.sh - sorry for the trouble with CI this time around.

Quoted 8 lines
Quoted 4 lines

Pretty sure it's 2964f6b816c2 (selftests: Use ktap helpers for runner.sh) - I've just put together a fix for that one, will throw it at my testing and send it later today all being well.  It uses readlink -e which isn't implemented by busybox.

Yes 2964f6b816c2 is my first suspect with ktap_helpers.sh no such file. Thank you for fixing this. That way we can patch it and not revert it.

Just a quick note to say I applied all 3 patches and will send pr tomorrow.

thanks,
-- Shuah

#18 lore raw

Re: [PATCH 5/6] selftests: Preserve subtarget failures in all/install

Quoted 6 lines · Shuah Khan
Quoted 2 lines · Shuah Khan

Yes 2964f6b816c2 is my first suspect with ktap_helpers.sh no such file. Thank you for fixing this. That way we can patch it and not revert it.

Just a quick note to say I applied all 3 patches and will send pr tomorrow.

Thanks Shuah! I'll try to confirm everything looks good when they're all merged together after today's -next.

#19 lore raw

Re: [PATCH 5/6] selftests: Preserve subtarget failures in all/install

In reply to Shuah Khan
Quoted 1 line · Shuah Khan

Just a quick note to say I applied all 3 patches and will send pr tomorrow.

Confirmed that everything seems to be running fine in -next for me. I am seeing the test number duplicated in the log messages from the wrapper:

ok 59 59 selftests: arm64: syscall-abi

which is confusing my parser a little but is less of an emergency, I'll take a look.

maintainer
#20 lore raw

Re: [PATCH 5/6] selftests: Preserve subtarget failures in all/install

Quoted 4 lines · Mark Brown
Quoted 1 line · Shuah Khan

Just a quick note to say I applied all 3 patches and will send pr tomorrow.

Quoted 8 lines

Confirmed that everything seems to be running fine in -next for me. I am seeing the test number duplicated in the log messages from the wrapper:

ok 59 59 selftests: arm64: syscall-abi

which is confusing my parser a little but is less of an emergency, I'll take a look.

Just about to send pr when I noticed your patch to fix the above. I applied it to linux-kselftest next and will send a combined pr with all 4 patches tomorrow.

Thanks for fixing these regressions.

thanks,
-- Shuah

#21 lore raw

PATCH 6/6 kbuild: remove kselftest output in mrproper

In reply to Ricardo B. Marlière

Selftests built with O= store generated files by default under $(objtree)/kselftest. Those files are not removed by mrproper today, so stale generated artifacts can survive across builds and be reused unexpectedly.

Add kselftest to MRPROPER_FILES, so that the default kselftest output directory as part of mrproper target.

---
 Makefile | 1 +
 1 file changed, 1 insertion(+)
Makefile +1 -0
index c9b7bee102e8..91e6ec790a0f 100644
@@ -1662,6 +1662,7 @@ MRPROPER_FILES += include/config include/generated          \
 		  debian snap tar-install PKGBUILD pacman \
 		  .config .config.old .version \
 		  Module.symvers \
+		  kselftest \
 		  certs/signing_key.pem \
 		  certs/x509.genkey \
 		  vmlinux-gdb.py \
Signature · 1 line
2.53.0
maintainer
#22 lore raw

Re: [PATCH 6/6] kbuild: remove kselftest output in mrproper

Quoted 7 lines · Ricardo B. Marlière

Selftests built with O= store generated files by default under $(objtree)/kselftest. Those files are not removed by mrproper today, so stale generated artifacts can survive across builds and be reused unexpectedly.

Add kselftest to MRPROPER_FILES, so that the default kselftest output directory as part of mrproper target.

Does this change remove kselftest build objects in-tree builds? It didn't for me - also there is kselftest directory under tools/selftests that has several scripts.

Can you test this for in-tree builds - I would like this work for both.

I dropped this from my next for now. This can go through kbuild tree.

Quoted 12 lines
---
  Makefile | 1 +
  1 file changed, 1 insertion(+)
Makefile +0 -0
index c9b7bee102e8..91e6ec790a0f 100644

Makefile MRPROPER_FILES += include/config include/generated \ · line 1668

Quoted 7 lines
Makefile +1 -0
@@ -1662,6 +1662,7 @@ MRPROPER_FILES += include/config include/generated          \
  		  debian snap tar-install PKGBUILD pacman \
  		  .config .config.old .version \
  		  Module.symvers \
+		  kselftest \
  		  certs/signing_key.pem \
  		  certs/x509.genkey \
  		  vmlinux-gdb.py \

thanks,
-- Shuah

#23 lore raw

Re: [PATCH 6/6] kbuild: remove kselftest output in mrproper

Quoted 13 lines · Shuah Khan
Quoted 7 lines · Ricardo B. Marlière

Selftests built with O= store generated files by default under $(objtree)/kselftest. Those files are not removed by mrproper today, so stale generated artifacts can survive across builds and be reused unexpectedly.

Add kselftest to MRPROPER_FILES, so that the default kselftest output directory as part of mrproper target.

Does this change remove kselftest build objects in-tree builds? It didn't for me - also there is kselftest directory under tools/selftests that has several scripts.

Quoted 5 lines

Can you test this for in-tree builds - I would like this work for both.

I dropped this from my next for now. This can go through kbuild tree.

OK! But please also drop https://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest.git/commit/?h=next&id=33880424308df3c2e39fa88ea74f051205ebb7b4

Thanks!

Quoted 24 lines
Quoted 19 lines

---
  Makefile | 1 +

  1 file changed, 1 insertion(+)
Makefile +1 -0
index c9b7bee102e8..91e6ec790a0f 100644
@@ -1662,6 +1662,7 @@ MRPROPER_FILES += include/config 
 include/generated          \
             debian snap tar-install PKGBUILD pacman \
             .config .config.old .version \
             Module.symvers \
+          kselftest \
             certs/signing_key.pem \
             certs/x509.genkey \
Quoted 2 lines

            vmlinux-gdb.py \

thanks,
-- Shuah

maintainer
#24 lore raw

Re: [PATCH 6/6] kbuild: remove kselftest output in mrproper

Quoted 14 lines · Ricardo B. Marlière
Quoted 13 lines · Shuah Khan
Quoted 7 lines · Ricardo B. Marlière

Selftests built with O= store generated files by default under $(objtree)/kselftest. Those files are not removed by mrproper today, so stale generated artifacts can survive across builds and be reused unexpectedly.

Add kselftest to MRPROPER_FILES, so that the default kselftest output directory as part of mrproper target.

Does this change remove kselftest build objects in-tree builds? It didn't for me - also there is kselftest directory under tools/selftests that has several scripts.

Quoted 8 lines
Quoted 5 lines

Can you test this for in-tree builds - I would like this work for both.

I dropped this from my next for now. This can go through kbuild tree.

OK! But please also drop https://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest.git/commit/?h=next&id=33880424308df3c2e39fa88ea74f051205ebb7b4

I can do that - you didn't mention the reasons why you want me to drop this one. Do other patches in this series depend on this one?

thanks,
-- Shuah

#25 lore raw

Re: [PATCH 6/6] kbuild: remove kselftest output in mrproper

Quoted 18 lines · Shuah Khan
Quoted 17 lines · Ricardo B. Marlière
Quoted 16 lines · Shuah Khan
Quoted 7 lines · Ricardo B. Marlière

Selftests built with O= store generated files by default under $(objtree)/kselftest. Those files are not removed by mrproper today, so stale generated artifacts can survive across builds and be reused unexpectedly.

Add kselftest to MRPROPER_FILES, so that the default kselftest output directory as part of mrproper target.

Does this change remove kselftest build objects in-tree builds? It didn't for me - also there is kselftest directory under tools/selftests that has several scripts.

Can you test this for in-tree builds - I would like this work for both.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

I dropped this from my next for now. This can go through kbuild tree.

OK! But please also drop https://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest.git/commit/?h=next&id=33880424308df3c2e39fa88ea74f051205ebb7b4

I can do that - you didn't mention the reasons why you want me to drop this one. Do other patches in this series depend on this one?

Others are fine. The problem with this one is this:

-    ($dryrun cd "$collection" && $dryrun run_many $tests) +    ($dryrun cd "$collection" && $dryrun run_many "$tests")

but run_many expects word splitting.

Quoted 3 lines

thanks,
-- Shuah

maintainer
#26 lore raw
In reply to Ricardo B. Marlière
Quoted 22 lines · Ricardo B. Marlière

Hi Shuah,

Please consider merging the following patches. They are mostly small fixes to run_kselftest.sh, plus one feature: adding the option of passing a directory to the "-p --per-test-log" argument.

There is a small corner case spotted in tools/testing/selftests/Makefile regarding failing sub-targets, and also the removal of the default install directory for out of tree builds in the top-level Makefile.

Thank you!

---
Ricardo B. Marlière (6):
selftests/run_kselftest.sh: Remove unused $ROOT selftests/run_kselftest.sh: Add missing quotes selftests/run_kselftest.sh: Resolve BASE_DIR with pwd -P selftests/run_kselftest.sh: Allow choosing per-test log directory
selftests: Preserve subtarget failures in all/install
kbuild: remove kselftest output in mrproper

Quoted 5 lines
  Makefile                                    |  1 +
  tools/testing/selftests/Makefile            |  8 ++---
  tools/testing/selftests/kselftest/runner.sh |  3 +-
  tools/testing/selftests/run_kselftest.sh    | 46 +++++++++++++++++++++--------
  4 files changed, 40 insertions(+), 18 deletions(-)

Thank you Ricardo. I applied the series to linux_kselftest next

I had to fix a minor merge conflict when I applied patch v2. Please check to see if everything looks sane.

thanks,
-- Shuah

#27 lore raw
Quoted 29 lines · Shuah Khan
Quoted 22 lines · Ricardo B. Marlière

Hi Shuah,

Please consider merging the following patches. They are mostly small fixes to run_kselftest.sh, plus one feature: adding the option of passing a directory to the "-p --per-test-log" argument.

There is a small corner case spotted in tools/testing/selftests/Makefile regarding failing sub-targets, and also the removal of the default install directory for out of tree builds in the top-level Makefile.

Thank you!

---
Ricardo B. Marlière (6):
selftests/run_kselftest.sh: Remove unused $ROOT selftests/run_kselftest.sh: Add missing quotes selftests/run_kselftest.sh: Resolve BASE_DIR with pwd -P selftests/run_kselftest.sh: Allow choosing per-test log directory
selftests: Preserve subtarget failures in all/install
kbuild: remove kselftest output in mrproper

Quoted 5 lines
  Makefile                                    |  1 +
  tools/testing/selftests/Makefile            |  8 ++---
  tools/testing/selftests/kselftest/runner.sh |  3 +-
  tools/testing/selftests/run_kselftest.sh    | 46 +++++++++++++++++++++--------
  4 files changed, 40 insertions(+), 18 deletions(-)
Quoted 4 lines

Thank you Ricardo. I applied the series to linux_kselftest next

I had to fix a minor merge conflict when I applied patch v2. Please check to see if everything looks sane.

Can you please drop commit 33880424308d ("selftests/run_kselftest.sh: Add missing quotes") ? This actually introduced a regression. I'm sorry about that.

Quoted 3 lines

thanks,
-- Shuah