Skip to contentSkip to conversation

support kselftest on nommu platform

PATCH Superseded Hajime Tazaki 6 participants 17 messages Sep 26 – Sep 29

Subsystems (5)

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v3 cover support kselftest on nommu platform

This patchset adds an ability to execute kselftest on nommu platforms.

Currently there are several issues if we wish to run kselftests on nommu targets:

- it cannot compile/build test binaries because the current files mainly assume to build with glibc,
- some of the tests are not able to run on nommu targets as there are no fork(2) syscall.

The first issue can be avoided if we can build static PIE binaries (if targets support it), but in our case (build on ubuntu/glibc and run on alpine/musl-libc), it fails to invoke due to lack of the GNU ifunc mechanism. Thus, we need to cross-compile with musl toolchain, which needs to be solved the first issue.

The second issue is the lack of fork(2) syscall on those platforms. Especially the test harness helper (kselftest_harness.h) uses the syscall, which cannot be simply with vfork(2). timeout command used in runner.sh never works for nommu platform as it uses fork(2).

nommu component in the mm subsystem has several known issues and having test cases should help this situation, thus this patchset is very first step toward enriching test environment which has not been well tested for a while. The test cases is implemented based on the document (Documentation/admin-guide/mm/nommu-mmap.rst).

Initial shape for this patches is implemented as an opt-in TARGET, not built/invoked automatically if users don't specify this nommu target.

- v2:
https://lore.kernel.org/linux-mm/[email protected]/
- rfc:
https://lore.kernel.org/linux-mm/[email protected]/

Hajime Tazaki (3):
selftests: kselftest: avoid cd - in runner
selftests: run tests on nommu architecture selftests/nommu: add nommu mmap and mremap behavior tests

 Documentation/dev-tools/kselftest.rst         |  14 +
 tools/testing/selftests/kselftest/runner.sh   |   9 +-
 tools/testing/selftests/nommu/Makefile        |   8 +
 tools/testing/selftests/nommu/local.mk        |   7 +
 .../testing/selftests/nommu/nommu_mmap_test.c | 258 +++++++++++++
 .../selftests/nommu/nommu_mremap_test.c       | 362 ++++++++++++++++++
 6 files changed, 656 insertions(+), 2 deletions(-)
 create mode 100644 tools/testing/selftests/nommu/Makefile
 create mode 100644 tools/testing/selftests/nommu/local.mk
 create mode 100644 tools/testing/selftests/nommu/nommu_mmap_test.c
 create mode 100644 tools/testing/selftests/nommu/nommu_mremap_test.c

base-commit: e8d0f6a1b2a447d02845984fa6288787543cb03c

Signature · 1 line
2.43.0
#1 lore raw

PATCH v3 1/3 selftests: kselftest: avoid cd - in runner

The kselftest runner currently uses cd - to restore its working directory after running a test.

This is not supported by the minimal BusyBox hush shell used by some NOMMU targets. Store the original directory explicitly and restore it with a quoted path instead.

This also avoids printing the directory change performed by cd - and handles paths containing whitespace correctly.

Cc Shuah Khan <[email protected]>
Cc Kees Cook <[email protected]>
Cc Andy Lutomirski <[email protected]>
Cc Will Drewry <[email protected]>
Cc Mark Brown <[email protected]>
Cc Brendan Jackman <[email protected]>
Cc Hangbin Liu <[email protected]>
Cc "Ricardo B. Marliere" <[email protected]>
---
 tools/testing/selftests/kselftest/runner.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/testing/selftests/kselftest/runner.sh +2 -1
index 311811dc55a0..8fc1018d6fec 100644
@@ -130,6 +130,7 @@ run_one()
 				return $KSFT_FAIL
 			fi
 		fi
+		OLDDIR=$(pwd)
 		cd `dirname $TEST` > /dev/null
 		(((( tap_timeout "$cmd" 2>&1; echo $? >&3) |
 			tap_prefix >&4) 3>&1) |
@@ -147,7 +148,7 @@ run_one()
 		*)
 			ktap_test_fail "$TEST_HDR_MSG # exit=$rc";;
 		esac
-		cd - >/dev/null
+		cd "$OLDDIR" >/dev/null
 	fi
 
 	return $rc
Signature · 1 line
2.43.0
#7 lore raw

PATCH v3 2/3 selftests: run tests on nommu architecture

In reply to Hajime Tazaki

Architectures lacks MMU doesn't support fork(2) syscall and only vfork(2) is available with limitations. Thus, we cannot run kselftest on nommu architecture as is.

This commit addresses this issue with the following changes:

- on test run stage, avoid calling timeout command when NOMMU=1 variable added to environmental variable, since timeout command uses fork syscall which nommu platform doesn't support.
- describe the difference of nommu tests in the document.

So command line to build/execute tests for nommu should be like below:

 $ make ARCH=um NOMMU=1 O=build kselftest-all TARGETS=nommu
 $ make ARCH=um NOMMU=1 O=build kselftest-install TARGETS=nommu
 $ NOMMU=1 ./build/kselftest/kselftest_install/run_kselftest.sh -p \
   -c nommu

--

v2 => v3
- remove unnecessary modification
- new target is moved from TARGETS=mm/nommu to TARGETS=nommu
- rename CONFIG_NOMMU to NOMMU to avoid confusion to kernel config

rfc => v2
- reformat ktap header, reported by Sashiko review
- https://lore.kernel.org/linux-mm/[email protected]/

rfc: https://lore.kernel.org/linux-mm/[email protected]/

---
 Documentation/dev-tools/kselftest.rst       | 14 ++++++++++++++
 tools/testing/selftests/kselftest/runner.sh |  6 +++++-
 2 files changed, 19 insertions(+), 1 deletion(-)
Documentation/dev-tools/kselftest.rst +14 -0
index 64c0ec7428a2..c35b819947b7 100644
@@ -230,6 +230,20 @@ section::
 
 .. _tar's auto-compress: https://www.gnu.org/software/tar/manual/html_node/gzip.html#auto_002dcompress
 
+Build and test on nommu target
+==============================
+
+If you (cross-)build kselftests for nommu targets, or run tests on nommu targets, use
+``NOMMU=1`` as a make variable/environment setting to tell build system to do the additional
+checks.  These nommu targets may differ in several ways, such as not supporting fork(2) or
+using musl or another libc.  Set this variable to apply the necessary build and test adjustments.
+
+::
+
+  $ make ARCH=um NOMMU=1 O=build kselftest-all TARGETS=nommu  # <= build-only
+  $ make ARCH=um NOMMU=1 O=build kselftest-install TARGETS=nommu
+  $ NOMMU=1 ./build/kselftest/kselftest_install/run_kselftest.sh -p -c nommu
+
 Contributing new tests
 ======================
 
tools/testing/selftests/kselftest/runner.sh +5 -1
index 8fc1018d6fec..95b5ebb8bbb9 100644
@@ -38,8 +38,12 @@ tap_prefix()
 
 tap_timeout()
 {
+	# nommu doesn't support timeout command (missing fork(2))
+	if [ "$NOMMU" = "1" ] ; then
+		echo "timeout isn't supported for NOMMU"
+		$1
 	# Make sure tests will time out if utility is available.
-	if [ -x /usr/bin/timeout ] ; then
+	elif [ -x /usr/bin/timeout ] ; then
 		/usr/bin/timeout --foreground "$kselftest_timeout" \
 			/usr/bin/timeout "$kselftest_timeout" $1
 	else
Signature · 1 line
2.43.0
#14 lore raw

PATCH v3 3/3 selftests/nommu: add nommu mmap and mremap behavior tests

In reply to Hajime Tazaki

Introduce a kselftest utility to validate memory mapping capabilities under nommu kernels, aligned with Documentation/admin-guide/mm/nommu-mmap.rst.

The test implements basic checks into a generic architecture-agnostic test matrix applicable across nommu targets. It evaluates:

1. MAP_FIXED allocation rejections.
2. Standard MAP_PRIVATE and MAP_ANONYMOUS allocation resilience.
3. Regular file mappings via standard filesystem storage.
4. Block device subsystem mappings (gracefully skipping if node is missing).
5. Shared vs Private backing discrepancies under nommu conditions.
6. mremap limits, ensuring non-expandable restrictions behave properly.

Cc Andrew Morton <[email protected]>
Cc David Hildenbrand <[email protected]>
Cc Lorenzo Stoakes <[email protected]>
Cc "Liam R. Howlett" <[email protected]>
Cc Vlastimil Babka <[email protected]>
Cc Mike Rapoport <[email protected]>
Cc Suren Baghdasaryan <[email protected]>
Cc Michal Hocko <[email protected]>
Cc Shuah Khan <[email protected]>
Assisted-by Gemini:Pro [AI_Reviewer] [Sashiko_Linter]
Assisted-by cubic.dev:unspecified

--

v2 => v3
- remove unnecessary modifications
- address Sashiko review

rfc => v2
- prepare a different TARGETS for tests (mm/nommu)
- drop shrink fix tests
- drop mmap /dev/zero tests
- https://lore.kernel.org/linux-mm/[email protected]/

rfc:
- https://lore.kernel.org/linux-mm/[email protected]/

---
 tools/testing/selftests/nommu/Makefile        |   8 +
 tools/testing/selftests/nommu/local.mk        |   7 +
 .../testing/selftests/nommu/nommu_mmap_test.c | 258 +++++++++++++
 .../selftests/nommu/nommu_mremap_test.c       | 362 ++++++++++++++++++
 4 files changed, 635 insertions(+)
 create mode 100644 tools/testing/selftests/nommu/Makefile
 create mode 100644 tools/testing/selftests/nommu/local.mk
 create mode 100644 tools/testing/selftests/nommu/nommu_mmap_test.c
 create mode 100644 tools/testing/selftests/nommu/nommu_mremap_test.c
tools/testing/selftests/nommu/Makefile new file +8 -0
new file mode 100644
index 000000000000..8e7cd7315c53
@@ -0,0 +1,8 @@
+# SPDX-License-Identifier: GPL-2.0
+# Makefile for nommu selftests
+
+TEST_GEN_PROGS += nommu_mmap_test
+TEST_GEN_PROGS += nommu_mremap_test
+
+include ../lib.mk
+include local.mk
tools/testing/selftests/nommu/local.mk new file +7 -0
new file mode 100644
index 000000000000..0bd1300f00f4
@@ -0,0 +1,7 @@
+# detect if users request NOMMU build or not
+# User can set NOMMU to 1 to build/test for NOMMU platforms
+NOMMU ?= 0
+ifeq ($(NOMMU),1)
+CFLAGS += -DNOMMU
+export NOMMU
+endif
tools/testing/selftests/nommu/nommu_mmap_test.c new file +258 -0

258 lines not on this page · raw message

tools/testing/selftests/nommu/nommu_mremap_test.c new file +362 -0

362 lines not on this page · raw message

Signature · 1 line
2.43.0
maintainer
#8 lore raw

Re: [PATCH v3 2/3] selftests: run tests on nommu architecture

In reply to Hajime Tazaki
Quoted 1 line · Hajime Tazaki

Architectures lacks MMU doesn't support fork(2) syscall and only

nit: Architectures lacking MMU don't support the fork(2) syscall ...

Not sure where this should be merged? I guess selftests would make most sense, but you can't actually test it out before the UML nommu changes, so that doesn't work too well right now?

johannes

Reviewed-by on v3 1/3
#2 lore raw

Re: [PATCH v3 1/3] selftests: kselftest: avoid cd - in runner

In reply to Hajime Tazaki
Quoted 22 lines · Hajime Tazaki

The kselftest runner currently uses cd - to restore its working directory after running a test.

This is not supported by the minimal BusyBox hush shell used by some NOMMU targets. Store the original directory explicitly and restore it with a quoted path instead.

This also avoids printing the directory change performed by cd - and handles paths containing whitespace correctly.

Cc Shuah Khan <[email protected]>
Cc Kees Cook <[email protected]>
Cc Andy Lutomirski <[email protected]>
Cc Will Drewry <[email protected]>
Cc Mark Brown <[email protected]>
Cc Brendan Jackman <[email protected]>
Cc Hangbin Liu <[email protected]>
Cc "Ricardo B. Marliere" <[email protected]>
Quoted 1 line

---

Signature · 3 lines
Cheers,

David
#9 lore raw

Re: [PATCH v3 2/3] selftests: run tests on nommu architecture

In reply to Johannes Berg
Quoted 8 lines · Johannes Berg
Quoted 1 line · Hajime Tazaki

Architectures lacks MMU doesn't support fork(2) syscall and only

nit: Architectures lacking MMU don't support the fork(2) syscall ...

Not sure where this should be merged? I guess selftests would make most sense, but you can't actually test it out before the UML nommu changes, so that doesn't work too well right now?

I seem to recall Hajime saying he tested this on an actual nommu device/virtualised equivalent so nommu UML isn't strictly necessary (though very nice to have!)

I think I saw something fly by that implied it might be coming in 7.4 is that so? :)

Quoted 2 lines

johannes

--
Cheers, Lorenzo

Reviewed-by on v3 1/3
#3 lore raw

Re: [PATCH v3 1/3] selftests: kselftest: avoid cd - in runner

In reply to Hajime Tazaki
Quoted 10 lines · Hajime Tazaki

The kselftest runner currently uses cd - to restore its working directory after running a test.

This is not supported by the minimal BusyBox hush shell used by some NOMMU targets. Store the original directory explicitly and restore it with a quoted path instead.

This also avoids printing the directory change performed by cd - and handles paths containing whitespace correctly.

Quoted 12 lines
Cc Shuah Khan <[email protected]>
Cc Kees Cook <[email protected]>
Cc Andy Lutomirski <[email protected]>
Cc Will Drewry <[email protected]>
Cc Mark Brown <[email protected]>
Cc Brendan Jackman <[email protected]>
Cc Hangbin Liu <[email protected]>
Cc "Ricardo B. Marliere" <[email protected]>

Looks fine to me so:

Quoted 26 lines
---
 tools/testing/selftests/kselftest/runner.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/testing/selftests/kselftest/runner.sh +2 -2
index 311811dc55a0..8fc1018d6fec 100644
@@ -130,6 +130,7 @@ run_one()
 				return $KSFT_FAIL
 			fi
 		fi
+		OLDDIR=$(pwd)
 		cd `dirname $TEST` > /dev/null
 		(((( tap_timeout "$cmd" 2>&1; echo $? >&3) |
 			tap_prefix >&4) 3>&1) |
@@ -147,7 +148,7 @@ run_one()
 		*)
 			ktap_test_fail "$TEST_HDR_MSG # exit=$rc";;
 		esac
-		cd - >/dev/null
+		cd "$OLDDIR" >/dev/null
 	fi
 
 	return $rc
--
Quoted 2 lines

2.43.0

--
Cheers, Lorenzo

Reviewed-by on v3 2/3
#13 lore raw

Re: [PATCH v3 2/3] selftests: run tests on nommu architecture

In reply to Hajime Tazaki
Quoted 18 lines · Hajime Tazaki

Architectures lacks MMU doesn't support fork(2) syscall and only vfork(2) is available with limitations. Thus, we cannot run kselftest on nommu architecture as is.

This commit addresses this issue with the following changes:

- on test run stage, avoid calling timeout command when NOMMU=1 variable added to environmental variable, since timeout command uses fork syscall which nommu platform doesn't support.
- describe the difference of nommu tests in the document.

So command line to build/execute tests for nommu should be like below:

 $ make ARCH=um NOMMU=1 O=build kselftest-all TARGETS=nommu
 $ make ARCH=um NOMMU=1 O=build kselftest-install TARGETS=nommu
 $ NOMMU=1 ./build/kselftest/kselftest_install/run_kselftest.sh -p \
   -c nommu
Quoted 15 lines

LGTM so:

Quoted 62 lines

--

v2 => v3
- remove unnecessary modification
- new target is moved from TARGETS=mm/nommu to TARGETS=nommu
- rename CONFIG_NOMMU to NOMMU to avoid confusion to kernel config

rfc => v2
- reformat ktap header, reported by Sashiko review
- https://lore.kernel.org/linux-mm/[email protected]/

rfc: https://lore.kernel.org/linux-mm/[email protected]/

---
 Documentation/dev-tools/kselftest.rst       | 14 ++++++++++++++
 tools/testing/selftests/kselftest/runner.sh |  6 +++++-
 2 files changed, 19 insertions(+), 1 deletion(-)
Documentation/dev-tools/kselftest.rst +14 -0
index 64c0ec7428a2..c35b819947b7 100644
@@ -230,6 +230,20 @@ section::
 
 .. _tar's auto-compress: https://www.gnu.org/software/tar/manual/html_node/gzip.html#auto_002dcompress
 
+Build and test on nommu target
+==============================
+
+If you (cross-)build kselftests for nommu targets, or run tests on nommu targets, use
+``NOMMU=1`` as a make variable/environment setting to tell build system to do the additional
+checks.  These nommu targets may differ in several ways, such as not supporting fork(2) or
+using musl or another libc.  Set this variable to apply the necessary build and test adjustments.
+
+::
+
+  $ make ARCH=um NOMMU=1 O=build kselftest-all TARGETS=nommu  # <= build-only
+  $ make ARCH=um NOMMU=1 O=build kselftest-install TARGETS=nommu
+  $ NOMMU=1 ./build/kselftest/kselftest_install/run_kselftest.sh -p -c nommu
+
 Contributing new tests
 ======================
 
tools/testing/selftests/kselftest/runner.sh +5 -2
index 8fc1018d6fec..95b5ebb8bbb9 100644
@@ -38,8 +38,12 @@ tap_prefix()
 
 tap_timeout()
 {
+	# nommu doesn't support timeout command (missing fork(2))
+	if [ "$NOMMU" = "1" ] ; then
+		echo "timeout isn't supported for NOMMU"
+		$1
 	# Make sure tests will time out if utility is available.
-	if [ -x /usr/bin/timeout ] ; then
+	elif [ -x /usr/bin/timeout ] ; then
 		/usr/bin/timeout --foreground "$kselftest_timeout" \
 			/usr/bin/timeout "$kselftest_timeout" $1
 	else
--
Quoted 2 lines

2.43.0

--
Cheers, Lorenzo

maintainer
#10 lore raw

Re: [PATCH v3 2/3] selftests: run tests on nommu architecture

In reply to Lorenzo Stoakes (ARM)
Quoted 7 lines · Lorenzo Stoakes (ARM)
Quoted 3 lines

Not sure where this should be merged? I guess selftests would make most sense, but you can't actually test it out before the UML nommu changes, so that doesn't work too well right now?

I seem to recall Hajime saying he tested this on an actual nommu device/virtualised equivalent so nommu UML isn't strictly necessary (though very nice to have!)

Oh, I don't recall, but I guess that's plausibe.

Quoted 2 lines

I think I saw something fly by that implied it might be coming in 7.4 is that so? :)

I did end up merging just about everything that was pending for uml/next, so if we don't forget to send a pull request in the merge window, or something equally catastrophic happens, yes ;-)

Sorry for the delay. The onslaught of LLMs means priority is elsewhere, sadly.

johannes

#15 lore raw

Re: [PATCH v3 3/3] selftests/nommu: add nommu mmap and mremap behavior tests

In reply to Hajime Tazaki
Quoted 8 lines · Hajime Tazaki

Introduce a kselftest utility to validate memory mapping capabilities under nommu kernels, aligned with Documentation/admin-guide/mm/nommu-mmap.rst.

tools/testing/selftests/nommu/nommu_mmap_test.c new file +4 -0
+static int run_mapping_matrix_test(struct test_case_t *tcase)
+{
+	int fd;
+	void *ptr;

tools/testing/selftests/nommu/nommu_mmap_test.c line 117

Quoted 10 lines
tools/testing/selftests/nommu/nommu_mmap_test.c new file +9 -0
+	char path_buf[PATH_MAX];
+	const char *path = tcase->pathname;
+	int rc = KSFT_PASS;
+	int expected_error;
+
+	ksft_print_msg("[RUN] Testing: %s\n", tcase->name);
 
+		if (fd < 0) {
+			ksft_test_result_skip("Failed to setup temp node: %s\n",
+					      tcase->pathname);

Your test reports should use a consistant string when reporting the result for a given test, that way tooling can tie results together between different runs. Report the diagnostic information with a separate print.

tools/testing/selftests/nommu/nommu_mmap_test.c line 258

Quoted 5 lines
tools/testing/selftests/nommu/nommu_mmap_test.c new file +5 -0
+	if (result == KSFT_PASS)
+		ksft_finished();
+
+	ksft_exit_fail();
+}

Just unconditionally call ksft_finshed(), it will check the counts of reported tests and exit with an appropriate error code - you don't need to manually collate the results in your test code.

#11 lore raw

Re: [PATCH v3 2/3] selftests: run tests on nommu architecture

In reply to Johannes Berg
Quoted 9 lines · Johannes Berg
Quoted 7 lines · Lorenzo Stoakes (ARM)
Quoted 3 lines

Not sure where this should be merged? I guess selftests would make most sense, but you can't actually test it out before the UML nommu changes, so that doesn't work too well right now?

I seem to recall Hajime saying he tested this on an actual nommu device/virtualised equivalent so nommu UML isn't strictly necessary (though very nice to have!)

Quoted 8 lines

Oh, I don't recall, but I guess that's plausibe.

Quoted 2 lines

I think I saw something fly by that implied it might be coming in 7.4 is that so? :)

I did end up merging just about everything that was pending for uml/next, so if we don't forget to send a pull request in the merge window, or something equally catastrophic happens, yes ;-)

Awesome, thanks! :)

Quoted 3 lines

Sorry for the delay. The onslaught of LLMs means priority is elsewhere, sadly.

Yeah understood, onslaught has reached all areas of the kernel it seems...

Quoted 2 lines

johannes

--
Cheers, Lorenzo

#4 lore raw

Re: [PATCH v3 1/3] selftests: kselftest: avoid cd - in runner

In reply to Hajime Tazaki
Quoted 10 lines · Hajime Tazaki

The kselftest runner currently uses cd - to restore its working directory after running a test.

This is not supported by the minimal BusyBox hush shell used by some NOMMU targets. Store the original directory explicitly and restore it with a quoted path instead.

This also avoids printing the directory change performed by cd - and handles paths containing whitespace correctly.

Quoted 12 lines
Cc Shuah Khan <[email protected]>
Cc Kees Cook <[email protected]>
Cc Andy Lutomirski <[email protected]>
Cc Will Drewry <[email protected]>
Cc Mark Brown <[email protected]>
Cc Brendan Jackman <[email protected]>
Cc Hangbin Liu <[email protected]>
Cc "Ricardo B. Marliere" <[email protected]>

NACK.

https://pubs.opengroup.org/onlinepubs/009695099/utilities/cd.html

-
When a hyphen is used as the operand, this shall be equivalent to the command:
cd "$OLDPWD" && pwd

which changes to the previous working directory and then writes its name.

If you're running selftests on !POSIX compliant shells, that's a you-issue. Fix the shell, or use something decent.

Signature · 1 line
Pedro
#5 lore raw

Re: [PATCH v3 1/3] selftests: kselftest: avoid cd - in runner

Quoted 32 lines · Pedro Falcato
Quoted 10 lines · Hajime Tazaki

The kselftest runner currently uses cd - to restore its working directory after running a test.

This is not supported by the minimal BusyBox hush shell used by some NOMMU targets. Store the original directory explicitly and restore it with a quoted path instead.

This also avoids printing the directory change performed by cd - and handles paths containing whitespace correctly.

Quoted 12 lines
Cc Shuah Khan <[email protected]>
Cc Kees Cook <[email protected]>
Cc Andy Lutomirski <[email protected]>
Cc Will Drewry <[email protected]>
Cc Mark Brown <[email protected]>
Cc Brendan Jackman <[email protected]>
Cc Hangbin Liu <[email protected]>
Cc "Ricardo B. Marliere" <[email protected]>

NACK.

https://pubs.opengroup.org/onlinepubs/009695099/utilities/cd.html

-
When a hyphen is used as the operand, this shall be equivalent to the command:
cd "$OLDPWD" && pwd

Quoted 5 lines

which changes to the previous working directory and then writes its name.

If you're running selftests on !POSIX compliant shells, that's a you-issue. Fix the shell, or use something decent.

... I realize I was a bit too aggressive but seriously, lets not support broken software, please?

Signature · 1 line
Pedro
#12 lore raw

Re: [PATCH v3 2/3] selftests: run tests on nommu architecture

In reply to Johannes Berg
Quoted 5 lines · Johannes Berg
Quoted 1 line · Hajime Tazaki

Architectures lacks MMU doesn't support fork(2) syscall and only

nit: Architectures lacking MMU don't support the fork(2) syscall ...

ah, thanks. will fix this line.

Quoted 3 lines

Not sure where this should be merged? I guess selftests would make most sense, but you can't actually test it out before the UML nommu changes, so that doesn't work too well right now?

I think this can be used for other NOMMU architecture (riscv, arm, m68k) if those are properly build so, it isn't intended for UML only tests.

-- Hajime

#6 lore raw

Re: [PATCH v3 1/3] selftests: kselftest: avoid cd - in runner

In reply to Pedro Falcato
Quoted 34 lines · Pedro Falcato
Quoted 32 lines · Pedro Falcato
Quoted 10 lines · Hajime Tazaki

The kselftest runner currently uses cd - to restore its working directory after running a test.

This is not supported by the minimal BusyBox hush shell used by some NOMMU targets. Store the original directory explicitly and restore it with a quoted path instead.

This also avoids printing the directory change performed by cd - and handles paths containing whitespace correctly.

Quoted 12 lines
Cc Shuah Khan <[email protected]>
Cc Kees Cook <[email protected]>
Cc Andy Lutomirski <[email protected]>
Cc Will Drewry <[email protected]>
Cc Mark Brown <[email protected]>
Cc Brendan Jackman <[email protected]>
Cc Hangbin Liu <[email protected]>
Cc "Ricardo B. Marliere" <[email protected]>

NACK.

https://pubs.opengroup.org/onlinepubs/009695099/utilities/cd.html

-
When a hyphen is used as the operand, this shall be equivalent to the command:
cd "$OLDPWD" && pwd

Quoted 8 lines
Quoted 5 lines

which changes to the previous working directory and then writes its name.

If you're running selftests on !POSIX compliant shells, that's a you-issue. Fix the shell, or use something decent.

... I realize I was a bit too aggressive but seriously, lets not support broken software, please?

thanks for the comments.

no, your comment makes 100% sense to me.
under fork-less environment, we have less options but I agree that this should be addressed in a shell implementation.

I will try to fix a busybox shell and drop this patch from next spin.

-- Hajime

#16 lore raw

Re: [PATCH v3 3/3] selftests/nommu: add nommu mmap and mremap behavior tests

In reply to Mark Brown
Quoted 11 lines · Mark Brown

tools/testing/selftests/nommu/nommu_mmap_test.c line 117

Quoted 5 lines
tools/testing/selftests/nommu/nommu_mmap_test.c new file +4 -0
+	ksft_print_msg("[RUN] Testing: %s\n", tcase->name);
 
+		if (fd < 0) {
+			ksft_test_result_skip("Failed to setup temp node: %s\n",
+					      tcase->pathname);

Your test reports should use a consistant string when reporting the result for a given test, that way tooling can tie results together between different runs. Report the diagnostic information with a separate print.

Quoted 9 lines

tools/testing/selftests/nommu/nommu_mmap_test.c line 258

Quoted 5 lines
tools/testing/selftests/nommu/nommu_mmap_test.c new file +5 -0
+	if (result == KSFT_PASS)
+		ksft_finished();
+
+	ksft_exit_fail();
+}

Just unconditionally call ksft_finshed(), it will check the counts of reported tests and exit with an appropriate error code - you don't need to manually collate the results in your test code.

thanks for the comments, and I understand all of them. I will revise
those in next spin.

-- Hajime