Back to home page

LXR

 
 

    


0001 Linux Kernel Selftests
0002 
0003 The kernel contains a set of "self tests" under the tools/testing/selftests/
0004 directory. These are intended to be small tests to exercise individual code
0005 paths in the kernel. Tests are intended to be run after building, installing
0006 and booting a kernel.
0007 
0008 On some systems, hot-plug tests could hang forever waiting for cpu and
0009 memory to be ready to be offlined. A special hot-plug target is created
0010 to run full range of hot-plug tests. In default mode, hot-plug tests run
0011 in safe mode with a limited scope. In limited mode, cpu-hotplug test is
0012 run on a single cpu as opposed to all hotplug capable cpus, and memory
0013 hotplug test is run on 2% of hotplug capable memory instead of 10%.
0014 
0015 Running the selftests (hotplug tests are run in limited mode)
0016 =============================================================
0017 
0018 To build the tests:
0019   $ make -C tools/testing/selftests
0020 
0021 
0022 To run the tests:
0023   $ make -C tools/testing/selftests run_tests
0024 
0025 To build and run the tests with a single command, use:
0026   $ make kselftest
0027 
0028 - note that some tests will require root privileges.
0029 
0030 
0031 Running a subset of selftests
0032 ========================================
0033 You can use the "TARGETS" variable on the make command line to specify
0034 single test to run, or a list of tests to run.
0035 
0036 To run only tests targeted for a single subsystem:
0037   $  make -C tools/testing/selftests TARGETS=ptrace run_tests
0038 
0039 You can specify multiple tests to build and run:
0040   $  make TARGETS="size timers" kselftest
0041 
0042 See the top-level tools/testing/selftests/Makefile for the list of all
0043 possible targets.
0044 
0045 
0046 Running the full range hotplug selftests
0047 ========================================
0048 
0049 To build the hotplug tests:
0050   $ make -C tools/testing/selftests hotplug
0051 
0052 To run the hotplug tests:
0053   $ make -C tools/testing/selftests run_hotplug
0054 
0055 - note that some tests will require root privileges.
0056 
0057 
0058 Install selftests
0059 =================
0060 
0061 You can use kselftest_install.sh tool installs selftests in default
0062 location which is tools/testing/selftests/kselftest or an user specified
0063 location.
0064 
0065 To install selftests in default location:
0066    $ cd tools/testing/selftests
0067    $ ./kselftest_install.sh
0068 
0069 To install selftests in an user specified location:
0070    $ cd tools/testing/selftests
0071    $ ./kselftest_install.sh install_dir
0072 
0073 Running installed selftests
0074 ===========================
0075 
0076 Kselftest install as well as the Kselftest tarball provide a script
0077 named "run_kselftest.sh" to run the tests.
0078 
0079 You can simply do the following to run the installed Kselftests. Please
0080 note some tests will require root privileges.
0081 
0082 cd kselftest
0083 ./run_kselftest.sh
0084 
0085 Contributing new tests
0086 ======================
0087 
0088 In general, the rules for selftests are
0089 
0090  * Do as much as you can if you're not root;
0091 
0092  * Don't take too long;
0093 
0094  * Don't break the build on any architecture, and
0095 
0096  * Don't cause the top-level "make run_tests" to fail if your feature is
0097    unconfigured.