kselftest.txt 2.5 KB

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