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