Skip to contentSkip to conversation

docs: rust: Add instructions for the Rust kselftest

PATCH Superseded Laura Nao 2 participants 3 messages Apr 3, 2024 – Apr 5, 2024

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Laura Nao

author
#0 lore raw

PATCH v2 1/1 docs: rust: Add instructions for the Rust kselftest

Add section describing how to build and run the Rust kselftest.

---
Changes in v2:
- Use plural to account for potential other tests added later
- Omit details about the test_probe_samples test
- Clarify that kselftests are intended to be executed on a system running the same kernel to be tested

---
 Documentation/rust/testing.rst | 25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)
Documentation/rust/testing.rst +24 -1
index 6658998d1b6c..64f58c4308f8 100644
@@ -6,10 +6,11 @@ Testing
 This document contains useful information how to test the Rust code in the
 kernel.
 
-There are two sorts of tests:
+There are three sorts of tests:
 
 - The KUnit tests.
 - The ``#[test]`` tests.
+- The Kselftests.
 
 The KUnit tests
 ---------------
@@ -133,3 +134,25 @@ Additionally, there are the ``#[test]`` tests. These can be run using the
 This requires the kernel ``.config`` and downloads external repositories. It
 runs the ``#[test]`` tests on the host (currently) and thus is fairly limited in
 what these tests can test.
+
+The Kselftests
+--------------
+
+Kselftests are also available in the tools/testing/selftests/rust folder.
+
+The kernel config options required for the test are listed in the
+tools/testing/selftests/rust/config file and can be included with the aid
+of the merge_config.sh script::
+
+	./scripts/kconfig/merge_config.sh .config tools/testing/selftests/rust/config
+
+The kselftests are built within the kernel source tree and are intended to
+be executed on a system that is running the same kernel.
+
+Once a kernel matching the source tree has been booted, the tests
+can be compiled and executed using the following command::
+
+	make TARGETS="rust" kselftest
+
+Refer to Documentation/dev-tools/kselftest.rst for the general Kselftest
+documentation.
Signature · 1 line
2.30.2
Reviewed-by on v2 1/1
#1 lore raw
Quoted 4 lines

Add section describing how to build and run the Rust kselftest.

Hi,

thanks for clarifying the system requirements. Only minor things (see below), irrespective of that offering:

Quoted 27 lines

---
Changes in v2:
- Use plural to account for potential other tests added later
- Omit details about the test_probe_samples test
- Clarify that kselftests are intended to be executed on a system running the same kernel to be tested

---
 Documentation/rust/testing.rst | 25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)
Documentation/rust/testing.rst +2 -1
index 6658998d1b6c..64f58c4308f8 100644
@@ -6,10 +6,11 @@ Testing
 This document contains useful information how to test the Rust code in the
 kernel.
 
-There are two sorts of tests:
+There are three sorts of tests:
 
 - The KUnit tests.
 - The ``#[test]`` tests.
+- The Kselftests.
 
 The KUnit tests
 ---------------

Documentation/rust/testing.rst Additionally, there are the ``#[test]`` tests. These can be run using the · line 143

Quoted 10 lines
Documentation/rust/testing.rst +7 -0
@@ -133,3 +134,25 @@ Additionally, there are the ``#[test]`` tests. These can be run using the
 This requires the kernel ``.config`` and downloads external repositories. It
 runs the ``#[test]`` tests on the host (currently) and thus is fairly limited in
 what these tests can test.
+
+The Kselftests
+--------------
+
+Kselftests are also available in the tools/testing/selftests/rust folder.
+
+The kernel config options required for the test are listed in the

Is this intentionally still in singular? Maybe replace /test/tests/?

Documentation/rust/testing.rst Additionally, there are the ``#[test]`` tests. These can be run using the · line 152

Quoted 9 lines
Documentation/rust/testing.rst +9 -0
+tools/testing/selftests/rust/config file and can be included with the aid
+of the merge_config.sh script::
+
+	./scripts/kconfig/merge_config.sh .config tools/testing/selftests/rust/config
+
+The kselftests are built within the kernel source tree and are intended to
+be executed on a system that is running the same kernel.
+
+Once a kernel matching the source tree has been booted, the tests

Maybe say 'installed and booted' here since at least one test is using modprobe, which expects to find the modules and other things in some standard locations.

- Best Valentin

Quoted 10 lines
Documentation/rust/testing.rst +6 -1
+can be compiled and executed using the following command::
+
+	make TARGETS="rust" kselftest
+
+Refer to Documentation/dev-tools/kselftest.rst for the general Kselftest
+documentation.
--

2.30.2

author
#2 lore raw

Hi Valentin,

Quoted 36 lines · Valentin Obst
Quoted 4 lines

Add section describing how to build and run the Rust kselftest.

Hi,

thanks for clarifying the system requirements. Only minor things (see below), irrespective of that offering:

Quoted 24 lines

---
Changes in v2:
- Use plural to account for potential other tests added later
- Omit details about the test_probe_samples test
- Clarify that kselftests are intended to be executed on a system running the same kernel to be tested

---
  Documentation/rust/testing.rst | 25 ++++++++++++++++++++++++-
  1 file changed, 24 insertions(+), 1 deletion(-)
Documentation/rust/testing.rst +2 -1
index 6658998d1b6c..64f58c4308f8 100644
@@ -6,10 +6,11 @@ Testing
  This document contains useful information how to test the Rust code in the
  kernel.
 
-There are two sorts of tests:
+There are three sorts of tests:
 
  - The KUnit tests.
  - The ``#[test]`` tests.
+- The Kselftests.
 
Quoted 16 lines

Documentation/rust/testing.rst Additionally, there are the ``#[test]`` tests. These can be run using the · line 143

Quoted 13 lines
Documentation/rust/testing.rst +7 -0
  The KUnit tests
  ---------------
@@ -133,3 +134,25 @@ Additionally, there are the ``#[test]`` tests. These can be run using the
  This requires the kernel ``.config`` and downloads external repositories. It
  runs the ``#[test]`` tests on the host (currently) and thus is fairly limited in
  what these tests can test.
+
+The Kselftests
+--------------
+
+Kselftests are also available in the tools/testing/selftests/rust folder.
+
+The kernel config options required for the test are listed in the

Is this intentionally still in singular? Maybe replace /test/tests/?

Argh, that slipped through - I'll fix it.

Quoted 5 lines
Quoted 5 lines
Documentation/rust/testing.rst +5 -0
+tools/testing/selftests/rust/config file and can be included with the aid
+of the merge_config.sh script::
+
+	./scripts/kconfig/merge_config.sh .config tools/testing/selftests/rust/config
+
Quoted 9 lines

Documentation/rust/testing.rst Additionally, there are the ``#[test]`` tests. These can be run using the · line 152

Quoted 4 lines
Documentation/rust/testing.rst +4 -0
+The kselftests are built within the kernel source tree and are intended to
+be executed on a system that is running the same kernel.
+
+Once a kernel matching the source tree has been booted, the tests

Maybe say 'installed and booted' here since at least one test is using modprobe, which expects to find the modules and other things in some standard locations.

Right, thanks for the suggestion. I'll send another version with these couple changes applied.

Thanks,

Laura