kselftest.txt 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. Linux Kernel Selftests
  2. The kernel contains a set of "self tests" under the tools/testing/selftests/
  3. directory. These are intended to be small unit tests to exercise individual
  4. code paths in the kernel.
  5. On some systems, hot-plug tests could hang forever waiting for cpu and
  6. memory to be ready to be offlined. A special hot-plug target is created
  7. to run full range of hot-plug tests. In default mode, hot-plug tests run
  8. in safe mode with a limited scope. In limited mode, cpu-hotplug test is
  9. run on a single cpu as opposed to all hotplug capable cpus, and memory
  10. hotplug test is run on 2% of hotplug capable memory instead of 10%.
  11. Running the selftests (hotplug tests are run in limited mode)
  12. =============================================================
  13. To build the tests:
  14. $ make -C tools/testing/selftests
  15. To run the tests:
  16. $ make -C tools/testing/selftests run_tests
  17. To build and run the tests with a single command, use:
  18. $ make kselftest
  19. - note that some tests will require root privileges.
  20. Running a subset of selftests
  21. ========================================
  22. You can use the "TARGETS" variable on the make command line to specify
  23. single test to run, or a list of tests to run.
  24. To run only tests targeted for a single subsystem:
  25. $ make -C tools/testing/selftests TARGETS=ptrace run_tests
  26. You can specify multiple tests to build and run:
  27. $ make TARGETS="size timers" kselftest
  28. See the top-level tools/testing/selftests/Makefile for the list of all
  29. possible targets.
  30. Running the full range hotplug selftests
  31. ========================================
  32. To build the hotplug tests:
  33. $ make -C tools/testing/selftests hotplug
  34. To run the hotplug tests:
  35. $ make -C tools/testing/selftests run_hotplug
  36. - note that some tests will require root privileges.
  37. Install selftests
  38. =================
  39. You can use kselftest_install.sh tool installs selftests in default
  40. location which is tools/testing/selftests/kselftest or an user specified
  41. location.
  42. To install selftests in default location:
  43. $ cd tools/testing/selftests
  44. $ ./kselftest_install.sh
  45. To install selftests in an user specified location:
  46. $ cd tools/testing/selftests
  47. $ ./kselftest_install.sh install_dir
  48. Contributing new tests
  49. ======================
  50. In general, the rules for for selftests are
  51. * Do as much as you can if you're not root;
  52. * Don't take too long;
  53. * Don't break the build on any architecture, and
  54. * Don't cause the top-level "make run_tests" to fail if your feature is
  55. unconfigured.