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