18c2ecf20Sopenharmony_ciLinux Ftrace Testcases
28c2ecf20Sopenharmony_ci
38c2ecf20Sopenharmony_ciThis is a collection of testcases for ftrace tracing feature in the Linux
48c2ecf20Sopenharmony_cikernel. Since ftrace exports interfaces via the debugfs, we just need
58c2ecf20Sopenharmony_cishell scripts for testing. Feel free to add new test cases.
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ciRunning the ftrace testcases
88c2ecf20Sopenharmony_ci============================
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ciAt first, you need to be the root user to run this script.
118c2ecf20Sopenharmony_ciTo run all testcases:
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci  $ sudo ./ftracetest
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ciTo run specific testcases:
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci  # ./ftracetest test.d/basic3.tc
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ciOr you can also run testcases under given directory:
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_ci  # ./ftracetest test.d/kprobe/
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ciContributing new testcases
248c2ecf20Sopenharmony_ci==========================
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ciCopy test.d/template to your testcase (whose filename must have *.tc
278c2ecf20Sopenharmony_ciextension) and rewrite the test description line.
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_ci * The working directory of the script is <debugfs>/tracing/.
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_ci * Take care with side effects as the tests are run with root privilege.
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci * The tests should not run for a long period of time (more than 1 min.)
348c2ecf20Sopenharmony_ci   These are to be unit tests.
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ci * You can add a directory for your testcases under test.d/ if needed.
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ci * The test cases should run on dash (busybox shell) for testing on
398c2ecf20Sopenharmony_ci   minimal cross-build environments.
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_ci * Note that the tests are run with "set -e" (errexit) option. If any
428c2ecf20Sopenharmony_ci   command fails, the test will be terminated immediately.
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_ci * The tests can return some result codes instead of pass or fail by
458c2ecf20Sopenharmony_ci   using exit_unresolved, exit_untested, exit_unsupported and exit_xfail.
468c2ecf20Sopenharmony_ci
478c2ecf20Sopenharmony_ciResult code
488c2ecf20Sopenharmony_ci===========
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_ciFtracetest supports following result codes.
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ci * PASS: The test succeeded as expected. The test which exits with 0 is
538c2ecf20Sopenharmony_ci         counted as passed test.
548c2ecf20Sopenharmony_ci
558c2ecf20Sopenharmony_ci * FAIL: The test failed, but was expected to succeed. The test which exits
568c2ecf20Sopenharmony_ci         with !0 is counted as failed test.
578c2ecf20Sopenharmony_ci
588c2ecf20Sopenharmony_ci * UNRESOLVED: The test produced unclear or intermidiate results.
598c2ecf20Sopenharmony_ci             for example, the test was interrupted
608c2ecf20Sopenharmony_ci                       or the test depends on a previous test, which failed.
618c2ecf20Sopenharmony_ci                       or the test was set up incorrectly
628c2ecf20Sopenharmony_ci             The test which is in above situation, must call exit_unresolved.
638c2ecf20Sopenharmony_ci
648c2ecf20Sopenharmony_ci * UNTESTED: The test was not run, currently just a placeholder.
658c2ecf20Sopenharmony_ci             In this case, the test must call exit_untested.
668c2ecf20Sopenharmony_ci
678c2ecf20Sopenharmony_ci * UNSUPPORTED: The test failed because of lack of feature.
688c2ecf20Sopenharmony_ci               In this case, the test must call exit_unsupported.
698c2ecf20Sopenharmony_ci
708c2ecf20Sopenharmony_ci * XFAIL: The test failed, and was expected to fail.
718c2ecf20Sopenharmony_ci          To return XFAIL, call exit_xfail from the test.
728c2ecf20Sopenharmony_ci
738c2ecf20Sopenharmony_ciThere are some sample test scripts for result code under samples/.
748c2ecf20Sopenharmony_ciYou can also run samples as below:
758c2ecf20Sopenharmony_ci
768c2ecf20Sopenharmony_ci  # ./ftracetest samples/
778c2ecf20Sopenharmony_ci
788c2ecf20Sopenharmony_ciTODO
798c2ecf20Sopenharmony_ci====
808c2ecf20Sopenharmony_ci
818c2ecf20Sopenharmony_ci * Fancy colored output :)
828c2ecf20Sopenharmony_ci
83