xref: /linux/tools/testing/selftests/ftrace/README (revision e5451c8f8330e03ad3cfa16048b4daf961af434f)
16e68e6c5SMasami HiramatsuLinux Ftrace Testcases
26e68e6c5SMasami Hiramatsu
36e68e6c5SMasami HiramatsuThis is a collection of testcases for ftrace tracing feature in the Linux
46e68e6c5SMasami Hiramatsukernel. Since ftrace exports interfaces via the debugfs, we just need
56e68e6c5SMasami Hiramatsushell scripts for testing. Feel free to add new test cases.
66e68e6c5SMasami Hiramatsu
76e68e6c5SMasami HiramatsuRunning the ftrace testcases
86e68e6c5SMasami Hiramatsu============================
96e68e6c5SMasami Hiramatsu
106e68e6c5SMasami HiramatsuAt first, you need to be the root user to run this script.
116e68e6c5SMasami HiramatsuTo run all testcases:
126e68e6c5SMasami Hiramatsu
136e68e6c5SMasami Hiramatsu  $ sudo ./ftracetest
146e68e6c5SMasami Hiramatsu
156e68e6c5SMasami HiramatsuTo run specific testcases:
166e68e6c5SMasami Hiramatsu
176e68e6c5SMasami Hiramatsu  # ./ftracetest test.d/basic3.tc
186e68e6c5SMasami Hiramatsu
196e68e6c5SMasami HiramatsuOr you can also run testcases under given directory:
206e68e6c5SMasami Hiramatsu
216e68e6c5SMasami Hiramatsu  # ./ftracetest test.d/kprobe/
226e68e6c5SMasami Hiramatsu
236e68e6c5SMasami HiramatsuContributing new testcases
246e68e6c5SMasami Hiramatsu==========================
256e68e6c5SMasami Hiramatsu
266e68e6c5SMasami HiramatsuCopy test.d/template to your testcase (whose filename must have *.tc
276e68e6c5SMasami Hiramatsuextension) and rewrite the test description line.
286e68e6c5SMasami Hiramatsu
296e68e6c5SMasami Hiramatsu * The working directory of the script is <debugfs>/tracing/.
306e68e6c5SMasami Hiramatsu
316e68e6c5SMasami Hiramatsu * Take care with side effects as the tests are run with root privilege.
326e68e6c5SMasami Hiramatsu
336e68e6c5SMasami Hiramatsu * The tests should not run for a long period of time (more than 1 min.)
346e68e6c5SMasami Hiramatsu   These are to be unit tests.
356e68e6c5SMasami Hiramatsu
366e68e6c5SMasami Hiramatsu * You can add a directory for your testcases under test.d/ if needed.
376e68e6c5SMasami Hiramatsu
386e68e6c5SMasami Hiramatsu * The test cases should run on dash (busybox shell) for testing on
396e68e6c5SMasami Hiramatsu   minimal cross-build environments.
406e68e6c5SMasami Hiramatsu
41*915de2adSMasami Hiramatsu * Note that the tests are run with "set -e" (errexit) option. If any
42*915de2adSMasami Hiramatsu   command fails, the test will be terminated immediately.
43*915de2adSMasami Hiramatsu
44*915de2adSMasami Hiramatsu * The tests can return some result codes instead of pass or fail by
45*915de2adSMasami Hiramatsu   using exit_unresolved, exit_untested, exit_unsupported and exit_xfail.
46*915de2adSMasami Hiramatsu
47*915de2adSMasami HiramatsuResult code
48*915de2adSMasami Hiramatsu===========
49*915de2adSMasami Hiramatsu
50*915de2adSMasami HiramatsuFtracetest supports following result codes.
51*915de2adSMasami Hiramatsu
52*915de2adSMasami Hiramatsu * PASS: The test succeeded as expected. The test which exits with 0 is
53*915de2adSMasami Hiramatsu         counted as passed test.
54*915de2adSMasami Hiramatsu
55*915de2adSMasami Hiramatsu * FAIL: The test failed, but was expected to succeed. The test which exits
56*915de2adSMasami Hiramatsu         with !0 is counted as failed test.
57*915de2adSMasami Hiramatsu
58*915de2adSMasami Hiramatsu * UNRESOLVED: The test produced unclear or intermidiate results.
59*915de2adSMasami Hiramatsu             for example, the test was interrupted
60*915de2adSMasami Hiramatsu                       or the test depends on a previous test, which failed.
61*915de2adSMasami Hiramatsu                       or the test was set up incorrectly
62*915de2adSMasami Hiramatsu             The test which is in above situation, must call exit_unresolved.
63*915de2adSMasami Hiramatsu
64*915de2adSMasami Hiramatsu * UNTESTED: The test was not run, currently just a placeholder.
65*915de2adSMasami Hiramatsu             In this case, the test must call exit_untested.
66*915de2adSMasami Hiramatsu
67*915de2adSMasami Hiramatsu * UNSUPPORTED: The test failed because of lack of feature.
68*915de2adSMasami Hiramatsu               In this case, the test must call exit_unsupported.
69*915de2adSMasami Hiramatsu
70*915de2adSMasami Hiramatsu * XFAIL: The test failed, and was expected to fail.
71*915de2adSMasami Hiramatsu          To return XFAIL, call exit_xfail from the test.
72*915de2adSMasami Hiramatsu
73*915de2adSMasami HiramatsuThere are some sample test scripts for result code under samples/.
74*915de2adSMasami HiramatsuYou can also run samples as below:
75*915de2adSMasami Hiramatsu
76*915de2adSMasami Hiramatsu  # ./ftracetest samples/
77*915de2adSMasami Hiramatsu
786e68e6c5SMasami HiramatsuTODO
796e68e6c5SMasami Hiramatsu====
806e68e6c5SMasami Hiramatsu
816e68e6c5SMasami Hiramatsu * Fancy colored output :)
826e68e6c5SMasami Hiramatsu
83