162306a36Sopenharmony_ciLinux Ftrace Testcases 262306a36Sopenharmony_ci 362306a36Sopenharmony_ciThis is a collection of testcases for ftrace tracing feature in the Linux 462306a36Sopenharmony_cikernel. Since ftrace exports interfaces via the debugfs, we just need 562306a36Sopenharmony_cishell scripts for testing. Feel free to add new test cases. 662306a36Sopenharmony_ci 762306a36Sopenharmony_ciRunning the ftrace testcases 862306a36Sopenharmony_ci============================ 962306a36Sopenharmony_ci 1062306a36Sopenharmony_ciAt first, you need to be the root user to run this script. 1162306a36Sopenharmony_ciTo run all testcases: 1262306a36Sopenharmony_ci 1362306a36Sopenharmony_ci $ sudo ./ftracetest 1462306a36Sopenharmony_ci 1562306a36Sopenharmony_ciTo run specific testcases: 1662306a36Sopenharmony_ci 1762306a36Sopenharmony_ci # ./ftracetest test.d/basic3.tc 1862306a36Sopenharmony_ci 1962306a36Sopenharmony_ciOr you can also run testcases under given directory: 2062306a36Sopenharmony_ci 2162306a36Sopenharmony_ci # ./ftracetest test.d/kprobe/ 2262306a36Sopenharmony_ci 2362306a36Sopenharmony_ciContributing new testcases 2462306a36Sopenharmony_ci========================== 2562306a36Sopenharmony_ci 2662306a36Sopenharmony_ciCopy test.d/template to your testcase (whose filename must have *.tc 2762306a36Sopenharmony_ciextension) and rewrite the test description line. 2862306a36Sopenharmony_ci 2962306a36Sopenharmony_ci * The working directory of the script is <debugfs>/tracing/. 3062306a36Sopenharmony_ci 3162306a36Sopenharmony_ci * Take care with side effects as the tests are run with root privilege. 3262306a36Sopenharmony_ci 3362306a36Sopenharmony_ci * The tests should not run for a long period of time (more than 1 min.) 3462306a36Sopenharmony_ci These are to be unit tests. 3562306a36Sopenharmony_ci 3662306a36Sopenharmony_ci * You can add a directory for your testcases under test.d/ if needed. 3762306a36Sopenharmony_ci 3862306a36Sopenharmony_ci * The test cases should run on dash (busybox shell) for testing on 3962306a36Sopenharmony_ci minimal cross-build environments. 4062306a36Sopenharmony_ci 4162306a36Sopenharmony_ci * Note that the tests are run with "set -e" (errexit) option. If any 4262306a36Sopenharmony_ci command fails, the test will be terminated immediately. 4362306a36Sopenharmony_ci 4462306a36Sopenharmony_ci * The tests can return some result codes instead of pass or fail by 4562306a36Sopenharmony_ci using exit_unresolved, exit_untested, exit_unsupported and exit_xfail. 4662306a36Sopenharmony_ci 4762306a36Sopenharmony_ciResult code 4862306a36Sopenharmony_ci=========== 4962306a36Sopenharmony_ci 5062306a36Sopenharmony_ciFtracetest supports following result codes. 5162306a36Sopenharmony_ci 5262306a36Sopenharmony_ci * PASS: The test succeeded as expected. The test which exits with 0 is 5362306a36Sopenharmony_ci counted as passed test. 5462306a36Sopenharmony_ci 5562306a36Sopenharmony_ci * FAIL: The test failed, but was expected to succeed. The test which exits 5662306a36Sopenharmony_ci with !0 is counted as failed test. 5762306a36Sopenharmony_ci 5862306a36Sopenharmony_ci * UNRESOLVED: The test produced unclear or intermidiate results. 5962306a36Sopenharmony_ci for example, the test was interrupted 6062306a36Sopenharmony_ci or the test depends on a previous test, which failed. 6162306a36Sopenharmony_ci or the test was set up incorrectly 6262306a36Sopenharmony_ci The test which is in above situation, must call exit_unresolved. 6362306a36Sopenharmony_ci 6462306a36Sopenharmony_ci * UNTESTED: The test was not run, currently just a placeholder. 6562306a36Sopenharmony_ci In this case, the test must call exit_untested. 6662306a36Sopenharmony_ci 6762306a36Sopenharmony_ci * UNSUPPORTED: The test failed because of lack of feature. 6862306a36Sopenharmony_ci In this case, the test must call exit_unsupported. 6962306a36Sopenharmony_ci 7062306a36Sopenharmony_ci * XFAIL: The test failed, and was expected to fail. 7162306a36Sopenharmony_ci To return XFAIL, call exit_xfail from the test. 7262306a36Sopenharmony_ci 7362306a36Sopenharmony_ciThere are some sample test scripts for result code under samples/. 7462306a36Sopenharmony_ciYou can also run samples as below: 7562306a36Sopenharmony_ci 7662306a36Sopenharmony_ci # ./ftracetest samples/ 7762306a36Sopenharmony_ci 7862306a36Sopenharmony_ciTODO 7962306a36Sopenharmony_ci==== 8062306a36Sopenharmony_ci 8162306a36Sopenharmony_ci * Fancy colored output :) 8262306a36Sopenharmony_ci 83