^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) Linux Ftrace Testcases
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) This is a collection of testcases for ftrace tracing feature in the Linux
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) kernel. Since ftrace exports interfaces via the debugfs, we just need
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) shell scripts for testing. Feel free to add new test cases.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) Running the ftrace testcases
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) ============================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) At first, you need to be the root user to run this script.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) To run all testcases:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) $ sudo ./ftracetest
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) To run specific testcases:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) # ./ftracetest test.d/basic3.tc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) Or you can also run testcases under given directory:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) # ./ftracetest test.d/kprobe/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) Contributing new testcases
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) ==========================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) Copy test.d/template to your testcase (whose filename must have *.tc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) extension) and rewrite the test description line.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) * The working directory of the script is <debugfs>/tracing/.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) * Take care with side effects as the tests are run with root privilege.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) * The tests should not run for a long period of time (more than 1 min.)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) These are to be unit tests.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) * You can add a directory for your testcases under test.d/ if needed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) * The test cases should run on dash (busybox shell) for testing on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) minimal cross-build environments.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) * Note that the tests are run with "set -e" (errexit) option. If any
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) command fails, the test will be terminated immediately.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) * The tests can return some result codes instead of pass or fail by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) using exit_unresolved, exit_untested, exit_unsupported and exit_xfail.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) Result code
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) ===========
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) Ftracetest supports following result codes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) * PASS: The test succeeded as expected. The test which exits with 0 is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) counted as passed test.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) * FAIL: The test failed, but was expected to succeed. The test which exits
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) with !0 is counted as failed test.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) * UNRESOLVED: The test produced unclear or intermidiate results.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) for example, the test was interrupted
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) or the test depends on a previous test, which failed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) or the test was set up incorrectly
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) The test which is in above situation, must call exit_unresolved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) * UNTESTED: The test was not run, currently just a placeholder.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) In this case, the test must call exit_untested.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) * UNSUPPORTED: The test failed because of lack of feature.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) In this case, the test must call exit_unsupported.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) * XFAIL: The test failed, and was expected to fail.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) To return XFAIL, call exit_xfail from the test.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) There are some sample test scripts for result code under samples/.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) You can also run samples as below:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) # ./ftracetest samples/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) TODO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) ====
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) * Fancy colored output :)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82)