diff options
| author | Mickaël Salaün <mic@digikod.net> | 2017-05-26 14:43:59 -0400 |
|---|---|---|
| committer | Shuah Khan <shuahkh@osg.samsung.com> | 2017-06-07 12:07:21 -0400 |
| commit | 55c70f11e729f17c86f2400a457138682e03b00f (patch) | |
| tree | 2a1e953ddedadfa0cb3a9a470424a2d5ad00bf9a /Documentation/dev-tools | |
| parent | dfa47d31fa0a5120c53c48da1b2a15dab3b8ea8c (diff) | |
Documentation/dev-tools: Add kselftest
Move kselftest.txt to dev-tools/kselftest.rst .
Signed-off-by: Mickaël Salaün <mic@digikod.net>
Acked-by: Kees Cook <keescook@chromium.org>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Shuah Khan <shuah@kernel.org>
Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
Diffstat (limited to 'Documentation/dev-tools')
| -rw-r--r-- | Documentation/dev-tools/kselftest.rst | 109 |
1 files changed, 109 insertions, 0 deletions
diff --git a/Documentation/dev-tools/kselftest.rst b/Documentation/dev-tools/kselftest.rst new file mode 100644 index 000000000000..5bd590335839 --- /dev/null +++ b/Documentation/dev-tools/kselftest.rst | |||
| @@ -0,0 +1,109 @@ | |||
| 1 | Linux Kernel Selftests | ||
| 2 | |||
| 3 | The kernel contains a set of "self tests" under the tools/testing/selftests/ | ||
| 4 | directory. These are intended to be small tests to exercise individual code | ||
| 5 | paths in the kernel. Tests are intended to be run after building, installing | ||
| 6 | and booting a kernel. | ||
| 7 | |||
| 8 | On some systems, hot-plug tests could hang forever waiting for cpu and | ||
| 9 | memory to be ready to be offlined. A special hot-plug target is created | ||
| 10 | to run full range of hot-plug tests. In default mode, hot-plug tests run | ||
| 11 | in safe mode with a limited scope. In limited mode, cpu-hotplug test is | ||
| 12 | run on a single cpu as opposed to all hotplug capable cpus, and memory | ||
| 13 | hotplug test is run on 2% of hotplug capable memory instead of 10%. | ||
| 14 | |||
| 15 | Running the selftests (hotplug tests are run in limited mode) | ||
| 16 | ============================================================= | ||
| 17 | |||
| 18 | To build the tests: | ||
| 19 | $ make -C tools/testing/selftests | ||
| 20 | |||
| 21 | |||
| 22 | To run the tests: | ||
| 23 | $ make -C tools/testing/selftests run_tests | ||
| 24 | |||
| 25 | To build and run the tests with a single command, use: | ||
| 26 | $ make kselftest | ||
| 27 | |||
| 28 | - note that some tests will require root privileges. | ||
| 29 | |||
| 30 | |||
| 31 | Running a subset of selftests | ||
| 32 | ======================================== | ||
| 33 | You can use the "TARGETS" variable on the make command line to specify | ||
| 34 | single test to run, or a list of tests to run. | ||
| 35 | |||
| 36 | To run only tests targeted for a single subsystem: | ||
| 37 | $ make -C tools/testing/selftests TARGETS=ptrace run_tests | ||
| 38 | |||
| 39 | You can specify multiple tests to build and run: | ||
| 40 | $ make TARGETS="size timers" kselftest | ||
| 41 | |||
| 42 | See the top-level tools/testing/selftests/Makefile for the list of all | ||
| 43 | possible targets. | ||
| 44 | |||
| 45 | |||
| 46 | Running the full range hotplug selftests | ||
| 47 | ======================================== | ||
| 48 | |||
| 49 | To build the hotplug tests: | ||
| 50 | $ make -C tools/testing/selftests hotplug | ||
| 51 | |||
| 52 | To run the hotplug tests: | ||
| 53 | $ make -C tools/testing/selftests run_hotplug | ||
| 54 | |||
| 55 | - note that some tests will require root privileges. | ||
| 56 | |||
| 57 | |||
| 58 | Install selftests | ||
| 59 | ================= | ||
| 60 | |||
| 61 | You can use kselftest_install.sh tool installs selftests in default | ||
| 62 | location which is tools/testing/selftests/kselftest or a user specified | ||
| 63 | location. | ||
| 64 | |||
| 65 | To install selftests in default location: | ||
| 66 | $ cd tools/testing/selftests | ||
| 67 | $ ./kselftest_install.sh | ||
| 68 | |||
| 69 | To install selftests in a user specified location: | ||
| 70 | $ cd tools/testing/selftests | ||
| 71 | $ ./kselftest_install.sh install_dir | ||
| 72 | |||
| 73 | Running installed selftests | ||
| 74 | =========================== | ||
| 75 | |||
| 76 | Kselftest install as well as the Kselftest tarball provide a script | ||
| 77 | named "run_kselftest.sh" to run the tests. | ||
| 78 | |||
| 79 | You can simply do the following to run the installed Kselftests. Please | ||
| 80 | note some tests will require root privileges. | ||
| 81 | |||
| 82 | cd kselftest | ||
| 83 | ./run_kselftest.sh | ||
| 84 | |||
| 85 | Contributing new tests | ||
| 86 | ====================== | ||
| 87 | |||
| 88 | In general, the rules for selftests are | ||
| 89 | |||
| 90 | * Do as much as you can if you're not root; | ||
| 91 | |||
| 92 | * Don't take too long; | ||
| 93 | |||
| 94 | * Don't break the build on any architecture, and | ||
| 95 | |||
| 96 | * Don't cause the top-level "make run_tests" to fail if your feature is | ||
| 97 | unconfigured. | ||
| 98 | |||
| 99 | Contributing new tests(details) | ||
| 100 | =============================== | ||
| 101 | |||
| 102 | * Use TEST_GEN_XXX if such binaries or files are generated during | ||
| 103 | compiling. | ||
| 104 | TEST_PROGS, TEST_GEN_PROGS mean it is the excutable tested by | ||
| 105 | default. | ||
| 106 | TEST_PROGS_EXTENDED, TEST_GEN_PROGS_EXTENDED mean it is the | ||
| 107 | executable which is not tested by default. | ||
| 108 | TEST_FILES, TEST_GEN_FILES mean it is the file which is used by | ||
| 109 | test. | ||
