linux/tools/testing/selftests/ftrace
Linus Torvalds b7dbc2e813 Probes updates for v6.17:
- Stack usage reduction for probe events:
    - Allocate string buffers from the heap for uprobe, eprobe, kprobe,
      and fprobe events to avoid stack overflow.
    - Allocate traceprobe_parse_context from the heap to prevent
      potential stack overflow.
    - Fix a typo in the above commit.
 
  - New features for eprobe and tprobe events:
    - Add support for arrays in eprobes.
    - Support multiple tprobes on the same tracepoint.
 
  - Improve efficiency:
    - Register fprobe-events only when it is enabled to reduce overhead.
    - Register tracepoints for tprobe events only when enabled to
      resolve a lock dependency.
 
  - Code Cleanup:
    - Add kerneldoc for traceprobe_parse_event_name() and __get_insn_slot().
    - Sort #include alphabetically in the probes code.
    - Remove the unused 'mod' field from the tprobe-event.
    - Clean up the entry-arg storing code in probe-events.
 
  - Selftest update
    - Enable fprobe events before checking enable_functions in selftests.
 -----BEGIN PGP SIGNATURE-----
 
 iQFPBAABCgA5FiEEh7BulGwFlgAOi5DV2/sHvwUrPxsFAmiJ2DQbHG1hc2FtaS5o
 aXJhbWF0c3VAZ21haWwuY29tAAoJENv7B78FKz8bSfkH/06Zn5I55rU85FKSBQll
 FN4hipmef/9Nd13skDwpEuFyzLPNS4P1up/UBUuyDQUTlO74+t2zSFO2dpcNrWmu
 sPTenQ+6h82H3K591WTIC23VzF54syIbFLXEj8iMBALT3wyU4Nn0bs4DCbnTo5HX
 R3NVo77rk6wxNJoKYOtT6ALf/lHonuNlGF+KTUGWP8UbWsIY3fIp0RWWy572M0bt
 +YBE8D8RIVrw+ZY+vNKn1LdZdWlR1ton518XDf1gV9isTCfKErcd/6HJKwuj5q2v
 qMgwiaKK+Gne/ylAKmWLEg2oNDo7kpyfW+612oiECitgZkqxOXhyYYfWgRt1lFNp
 Wb8=
 =E+Z6
 -----END PGP SIGNATURE-----

Merge tag 'probes-v6.17' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace

Pull probes updates from Masami Hiramatsu:
 "Stack usage reduction for probe events:
   - Allocate string buffers from the heap for uprobe, eprobe, kprobe,
     and fprobe events to avoid stack overflow
   - Allocate traceprobe_parse_context from the heap to prevent
     potential stack overflow
   - Fix a typo in the above commit

  New features for eprobe and tprobe events:
   - Add support for arrays in eprobes
   - Support multiple tprobes on the same tracepoint

  Improve efficiency:
   - Register fprobe-events only when it is enabled to reduce overhead
   - Register tracepoints for tprobe events only when enabled to resolve
     a lock dependency

  Code Cleanup:
   - Add kerneldoc for traceprobe_parse_event_name() and
     __get_insn_slot()
   - Sort #include alphabetically in the probes code
   - Remove the unused 'mod' field from the tprobe-event
   - Clean up the entry-arg storing code in probe-events

  Selftest update
   - Enable fprobe events before checking enable_functions in selftests"

* tag 'probes-v6.17' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace:
  tracing: trace_fprobe: Fix typo of the semicolon
  tracing: Have eprobes handle arrays
  tracing: probes: Add a kerneldoc for traceprobe_parse_event_name()
  tracing: uprobe-event: Allocate string buffers from heap
  tracing: eprobe-event: Allocate string buffers from heap
  tracing: kprobe-event: Allocate string buffers from heap
  tracing: fprobe-event: Allocate string buffers from heap
  tracing: probe: Allocate traceprobe_parse_context from heap
  tracing: probes: Sort #include alphabetically
  kprobes: Add missing kerneldoc for __get_insn_slot
  tracing: tprobe-events: Register tracepoint when enable tprobe event
  selftests: tracing: Enable fprobe events before checking enable_functions
  tracing: fprobe-events: Register fprobe-events only when it is enabled
  tracing: tprobe-events: Support multiple tprobes on the same tracepoint
  tracing: tprobe-events: Remove mod field from tprobe-event
  tracing: probe-events: Cleanup entry-arg storing code
2025-07-30 15:38:01 -07:00
..
samples
test.d Probes updates for v6.17: 2025-07-30 15:38:01 -07:00
.gitignore selftests/ftrace: add 'poll' binary to gitignore 2025-03-04 08:51:17 -07:00
config sefltests/tracing: Add a test for tracepoint events on modules 2024-09-25 23:23:44 +09:00
ftracetest tracing/selftests: Support log output when generating KTAP output 2024-05-06 13:57:19 -06:00
ftracetest-ktap tracing/selftests: Default to verbose mode when running in kselftest 2024-05-06 13:57:20 -06:00
Makefile selftests/ftrace: Convert poll to a gen_file 2025-05-09 12:43:10 -06:00
poll.c selftests/tracing: Add hist poll() support test 2025-01-07 11:48:07 -05:00
README
settings

Linux Ftrace Testcases

This is a collection of testcases for ftrace tracing feature in the Linux
kernel. Since ftrace exports interfaces via the debugfs, we just need
shell scripts for testing. Feel free to add new test cases.

Running the ftrace testcases
============================

At first, you need to be the root user to run this script.
To run all testcases:

  $ sudo ./ftracetest

To run specific testcases:

  # ./ftracetest test.d/basic3.tc

Or you can also run testcases under given directory:

  # ./ftracetest test.d/kprobe/

Contributing new testcases
==========================

Copy test.d/template to your testcase (whose filename must have *.tc
extension) and rewrite the test description line.

 * The working directory of the script is <debugfs>/tracing/.

 * Take care with side effects as the tests are run with root privilege.

 * The tests should not run for a long period of time (more than 1 min.)
   These are to be unit tests.

 * You can add a directory for your testcases under test.d/ if needed.

 * The test cases should run on dash (busybox shell) for testing on
   minimal cross-build environments.

 * Note that the tests are run with "set -e" (errexit) option. If any
   command fails, the test will be terminated immediately.

 * The tests can return some result codes instead of pass or fail by
   using exit_unresolved, exit_untested, exit_unsupported and exit_xfail.

Result code
===========

Ftracetest supports following result codes.

 * PASS: The test succeeded as expected. The test which exits with 0 is
         counted as passed test.

 * FAIL: The test failed, but was expected to succeed. The test which exits
         with !0 is counted as failed test.

 * UNRESOLVED: The test produced unclear or intermidiate results.
             for example, the test was interrupted
                       or the test depends on a previous test, which failed.
                       or the test was set up incorrectly
             The test which is in above situation, must call exit_unresolved.

 * UNTESTED: The test was not run, currently just a placeholder.
             In this case, the test must call exit_untested.

 * UNSUPPORTED: The test failed because of lack of feature.
               In this case, the test must call exit_unsupported.

 * XFAIL: The test failed, and was expected to fail.
          To return XFAIL, call exit_xfail from the test.

There are some sample test scripts for result code under samples/.
You can also run samples as below:

  # ./ftracetest samples/

TODO
====

 * Fancy colored output :)