diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-10-12 07:33:37 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-10-12 07:33:37 -0400 |
| commit | 90eac7eee2f4257644dcfb9d22348fded7c24afd (patch) | |
| tree | ea472521485299a830095ea341f263cfb0425f1e /tools/testing | |
| parent | 6bbcb1d3a2e0a31593e3b7d9bfd112fa7f447141 (diff) | |
| parent | 89c5497d1f933af56dac617f0fd86150942a7fb6 (diff) | |
Merge tag 'ftracetest-3.18' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace
Pull ftrace test code from Steven Rostedt:
"This patch series starts a new selftests section in the
tools/testing/selftest directory called "ftrace" that holds tests
aimed at testing ftrace and subsystems that use ftrace (like kprobes).
So far only a few tests were written (by Masami Hiramatsu), but more
will be added in the near future (3.19)"
* tag 'ftracetest-3.18' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace:
tracing/kprobes: Add selftest scripts testing kprobe-tracer as startup test
ftracetest: Add POSIX.3 standard and XFAIL result codes
ftracetest: Add kprobe basic testcases
ftracetest: Add ftrace basic testcases
ftracetest: Initial commit for ftracetest
Diffstat (limited to 'tools/testing')
18 files changed, 445 insertions, 0 deletions
diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile index 36ff2e4c7b6f..45f145c6f843 100644 --- a/tools/testing/selftests/Makefile +++ b/tools/testing/selftests/Makefile | |||
| @@ -14,6 +14,7 @@ TARGETS += powerpc | |||
| 14 | TARGETS += user | 14 | TARGETS += user |
| 15 | TARGETS += sysctl | 15 | TARGETS += sysctl |
| 16 | TARGETS += firmware | 16 | TARGETS += firmware |
| 17 | TARGETS += ftrace | ||
| 17 | 18 | ||
| 18 | TARGETS_HOTPLUG = cpu-hotplug | 19 | TARGETS_HOTPLUG = cpu-hotplug |
| 19 | TARGETS_HOTPLUG += memory-hotplug | 20 | TARGETS_HOTPLUG += memory-hotplug |
diff --git a/tools/testing/selftests/ftrace/Makefile b/tools/testing/selftests/ftrace/Makefile new file mode 100644 index 000000000000..76cc9f156267 --- /dev/null +++ b/tools/testing/selftests/ftrace/Makefile | |||
| @@ -0,0 +1,7 @@ | |||
| 1 | all: | ||
| 2 | |||
| 3 | run_tests: | ||
| 4 | @/bin/sh ./ftracetest || echo "ftrace selftests: [FAIL]" | ||
| 5 | |||
| 6 | clean: | ||
| 7 | rm -rf logs/* | ||
diff --git a/tools/testing/selftests/ftrace/README b/tools/testing/selftests/ftrace/README new file mode 100644 index 000000000000..182e76fa4b82 --- /dev/null +++ b/tools/testing/selftests/ftrace/README | |||
| @@ -0,0 +1,82 @@ | |||
| 1 | Linux Ftrace Testcases | ||
| 2 | |||
| 3 | This is a collection of testcases for ftrace tracing feature in the Linux | ||
| 4 | kernel. Since ftrace exports interfaces via the debugfs, we just need | ||
| 5 | shell scripts for testing. Feel free to add new test cases. | ||
| 6 | |||
| 7 | Running the ftrace testcases | ||
| 8 | ============================ | ||
| 9 | |||
| 10 | At first, you need to be the root user to run this script. | ||
| 11 | To run all testcases: | ||
| 12 | |||
| 13 | $ sudo ./ftracetest | ||
| 14 | |||
| 15 | To run specific testcases: | ||
| 16 | |||
| 17 | # ./ftracetest test.d/basic3.tc | ||
| 18 | |||
| 19 | Or you can also run testcases under given directory: | ||
| 20 | |||
| 21 | # ./ftracetest test.d/kprobe/ | ||
| 22 | |||
| 23 | Contributing new testcases | ||
| 24 | ========================== | ||
| 25 | |||
| 26 | Copy test.d/template to your testcase (whose filename must have *.tc | ||
| 27 | extension) and rewrite the test description line. | ||
| 28 | |||
| 29 | * The working directory of the script is <debugfs>/tracing/. | ||
| 30 | |||
| 31 | * Take care with side effects as the tests are run with root privilege. | ||
| 32 | |||
| 33 | * The tests should not run for a long period of time (more than 1 min.) | ||
| 34 | These are to be unit tests. | ||
| 35 | |||
| 36 | * You can add a directory for your testcases under test.d/ if needed. | ||
| 37 | |||
| 38 | * The test cases should run on dash (busybox shell) for testing on | ||
| 39 | minimal cross-build environments. | ||
| 40 | |||
| 41 | * Note that the tests are run with "set -e" (errexit) option. If any | ||
| 42 | command fails, the test will be terminated immediately. | ||
| 43 | |||
| 44 | * The tests can return some result codes instead of pass or fail by | ||
| 45 | using exit_unresolved, exit_untested, exit_unsupported and exit_xfail. | ||
| 46 | |||
| 47 | Result code | ||
| 48 | =========== | ||
| 49 | |||
| 50 | Ftracetest supports following result codes. | ||
| 51 | |||
| 52 | * PASS: The test succeeded as expected. The test which exits with 0 is | ||
| 53 | counted as passed test. | ||
| 54 | |||
| 55 | * FAIL: The test failed, but was expected to succeed. The test which exits | ||
| 56 | with !0 is counted as failed test. | ||
| 57 | |||
| 58 | * UNRESOLVED: The test produced unclear or intermidiate results. | ||
| 59 | for example, the test was interrupted | ||
| 60 | or the test depends on a previous test, which failed. | ||
| 61 | or the test was set up incorrectly | ||
| 62 | The test which is in above situation, must call exit_unresolved. | ||
| 63 | |||
| 64 | * UNTESTED: The test was not run, currently just a placeholder. | ||
| 65 | In this case, the test must call exit_untested. | ||
| 66 | |||
| 67 | * UNSUPPORTED: The test failed because of lack of feature. | ||
| 68 | In this case, the test must call exit_unsupported. | ||
| 69 | |||
| 70 | * XFAIL: The test failed, and was expected to fail. | ||
| 71 | To return XFAIL, call exit_xfail from the test. | ||
| 72 | |||
| 73 | There are some sample test scripts for result code under samples/. | ||
| 74 | You can also run samples as below: | ||
| 75 | |||
| 76 | # ./ftracetest samples/ | ||
| 77 | |||
| 78 | TODO | ||
| 79 | ==== | ||
| 80 | |||
| 81 | * Fancy colored output :) | ||
| 82 | |||
diff --git a/tools/testing/selftests/ftrace/ftracetest b/tools/testing/selftests/ftrace/ftracetest new file mode 100755 index 000000000000..a8f81c782856 --- /dev/null +++ b/tools/testing/selftests/ftrace/ftracetest | |||
| @@ -0,0 +1,253 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | # ftracetest - Ftrace test shell scripts | ||
| 4 | # | ||
| 5 | # Copyright (C) Hitachi Ltd., 2014 | ||
| 6 | # Written by Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> | ||
| 7 | # | ||
| 8 | # Released under the terms of the GPL v2. | ||
| 9 | |||
| 10 | usage() { # errno [message] | ||
| 11 | [ "$2" ] && echo $2 | ||
| 12 | echo "Usage: ftracetest [options] [testcase(s)] [testcase-directory(s)]" | ||
| 13 | echo " Options:" | ||
| 14 | echo " -h|--help Show help message" | ||
| 15 | echo " -k|--keep Keep passed test logs" | ||
| 16 | echo " -d|--debug Debug mode (trace all shell commands)" | ||
| 17 | exit $1 | ||
| 18 | } | ||
| 19 | |||
| 20 | errexit() { # message | ||
| 21 | echo "Error: $1" 1>&2 | ||
| 22 | exit 1 | ||
| 23 | } | ||
| 24 | |||
| 25 | # Ensuring user privilege | ||
| 26 | if [ `id -u` -ne 0 ]; then | ||
| 27 | errexit "this must be run by root user" | ||
| 28 | fi | ||
| 29 | |||
| 30 | # Utilities | ||
| 31 | absdir() { # file_path | ||
| 32 | (cd `dirname $1`; pwd) | ||
| 33 | } | ||
| 34 | |||
| 35 | abspath() { | ||
| 36 | echo `absdir $1`/`basename $1` | ||
| 37 | } | ||
| 38 | |||
| 39 | find_testcases() { #directory | ||
| 40 | echo `find $1 -name \*.tc` | ||
| 41 | } | ||
| 42 | |||
| 43 | parse_opts() { # opts | ||
| 44 | local OPT_TEST_CASES= | ||
| 45 | local OPT_TEST_DIR= | ||
| 46 | |||
| 47 | while [ "$1" ]; do | ||
| 48 | case "$1" in | ||
| 49 | --help|-h) | ||
| 50 | usage 0 | ||
| 51 | ;; | ||
| 52 | --keep|-k) | ||
| 53 | KEEP_LOG=1 | ||
