ftrace: Add a ftrace test collection
cover ftrace: Add a ftrace test collection
Hi,
I'd like to introduce a collection of testcases for ftrace to avoid regressions.
For a long time, we've tried to stabilize and extend ftrace tracing infrastructure. This small test framework is a kind of stabilizing work for ftrace. For the first step, this series just introduces a few basic testcases. However, it is easy to add additional tests. I'd like to ask you, ftrace developers, to add tests for your features to ensure it will not be broken by future works.
ftracetest is a tiny bash script so that anyone can easily understand what it does. I think it is better to share and discuss this tests before growing it.
- Is it enough to support bash script? (of course you can invoke other commands from the script)
- What's the good naming method of testcases?
- Is any dependency check required?
BTW, I decided to put this under tools/testing/ftrace instead of tools/testing/selftests/, because all tests requires root privilege. It will be one of discussion points. Anyway, it is easy to integrate this to the selftests.
Thank you,
---
Masami Hiramatsu (3):
ftracetest: Initial commit for ftracetest
ftracetest: Add ftrace basic testcases
ftracetest: Add kprobe basic testcases
tools/testing/ftrace/README | 38 ++++++ tools/testing/ftrace/ftracetest | 133 ++++++++++++++++++++ tools/testing/ftrace/test.d/basic1.tc | 3 tools/testing/ftrace/test.d/basic2.tc | 6 + tools/testing/ftrace/test.d/basic3.tc | 8 + .../testing/ftrace/test.d/kprobe/add_and_remove.tc | 11 ++ tools/testing/ftrace/test.d/kprobe/busy_check.tc | 14 ++ tools/testing/ftrace/test.d/template | 4 + 8 files changed, 217 insertions(+) create mode 100644 tools/testing/ftrace/README create mode 100755 tools/testing/ftrace/ftracetest create mode 100644 tools/testing/ftrace/test.d/basic1.tc create mode 100644 tools/testing/ftrace/test.d/basic2.tc create mode 100644 tools/testing/ftrace/test.d/basic3.tc create mode 100644 tools/testing/ftrace/test.d/kprobe/add_and_remove.tc create mode 100644 tools/testing/ftrace/test.d/kprobe/busy_check.tc create mode 100644 tools/testing/ftrace/test.d/template
--
RFC PATCH 1/3 ftracetest: Initial commit for ftracetest
ftracetest is a collection of testcase shell-scripts for ftrace. To avoid regressions of ftrace, these testcases check correct ftrace behaviors. If someone would like to add any features on ftrace, the patch series should have at least one testcase for checking the new behavior.
--- tools/testing/ftrace/README | 38 ++++++++++ tools/testing/ftrace/ftracetest | 133 ++++++++++++++++++++++++++++++++++ tools/testing/ftrace/test.d/template | 4 + 3 files changed, 175 insertions(+) create mode 100644 tools/testing/ftrace/README create mode 100755 tools/testing/ftrace/ftracetest create mode 100644 tools/testing/ftrace/test.d/template
tools/testing/ftrace/README new file +38 -0
@@ -0,0 +1,38 @@ +Linux Ftrace Testcases + +This is a collection of testcases for ftrace tracing feature in the Linux +kernel. Since ftrace exports interfaces via the debugfs, we just need +shell scripts for testing. Feel free to add new test cases. + +Running the ftrace testcases +============================ + +At first, you need to be the root user to run this script. +To run all testcases: + + $ sudo ./ftracetest + +To run specific testcases: + + # ./ftracetest test.d/basic3.tc + +Contributing new testcases +========================== + +Copy test.d/template to your testcase (whose filename must has *.tc extension) +and rewrite test description line. + + * The working directory of the script is <debugfs>/tracing/. + + * Take care about the side effect, because that is run with root privilege. + + * Don't take too long. It's a kind of unit test. + + * You can add a directory for your testcases under test.d/ if needed. + +TODO +==== + + * Fancy colored output :) + + * Integrate with selftest?
tools/testing/ftrace/ftracetest new file +133 -0
133 lines not on this page · raw message
tools/testing/ftrace/test.d/template new file +4 -0
@@ -0,0 +1,4 @@ +#!/bin/bash +# description: %HERE DESCRIBE WHAT THIS DOES% +# you have to add ".tc" extention for your testcase file +exit 0 # Return 0 if the test is passed, otherwise return !0
RFC PATCH 2/3 ftracetest: Add ftrace basic testcases
In reply to Masami HiramatsuAdd ftrace basic testcases. This just checks ftrace debugfs interface works as it is designed.
--- tools/testing/ftrace/test.d/basic1.tc | 3 +++ tools/testing/ftrace/test.d/basic2.tc | 6 ++++++ tools/testing/ftrace/test.d/basic3.tc | 8 ++++++++ 3 files changed, 17 insertions(+) create mode 100644 tools/testing/ftrace/test.d/basic1.tc create mode 100644 tools/testing/ftrace/test.d/basic2.tc create mode 100644 tools/testing/ftrace/test.d/basic3.tc
tools/testing/ftrace/test.d/basic1.tc new file +3 -0
@@ -0,0 +1,3 @@ +#!/bin/bash +# description: Basic trace file check +test -f README -a -f trace -a -f tracing_on -a -f trace_pipe
tools/testing/ftrace/test.d/basic2.tc new file +6 -0
@@ -0,0 +1,6 @@ +#!/bin/bash +# description: Basic test for tracers +for t in `cat available_tracers`; do + echo $t > current_tracer || exit 1 +done +echo nop > current_tracer
tools/testing/ftrace/test.d/basic3.tc new file +8 -0
@@ -0,0 +1,8 @@ +#!/bin/bash +# description: Basic trace clock test +[ -f trace_clock ] || exit 1 +for c in `cat trace_clock | tr -d \[\]`; do + echo $c > trace_clock || exit 1 + grep '\['$c'\]' trace_clock || exit 1 +done +echo local > trace_clock
RFC PATCH 3/3 ftracetest: Add kprobe basic testcases
In reply to Masami HiramatsuAdd basic testcases for kprobe dynamic events. This also shows that the ftracetest accepts sub-directory for new testcases.
--- .../testing/ftrace/test.d/kprobe/add_and_remove.tc | 11 +++++++++++ tools/testing/ftrace/test.d/kprobe/busy_check.tc | 14 ++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 tools/testing/ftrace/test.d/kprobe/add_and_remove.tc create mode 100644 tools/testing/ftrace/test.d/kprobe/busy_check.tc
tools/testing/ftrace/test.d/kprobe/add_and_remove.tc new file +11 -0
@@ -0,0 +1,11 @@ +#!/bin/bash +# description: Kprobe dynamic event - adding and removing + +[ -f kprobe_events ] || exit 1 + +echo 0 > events/enable || exit 1 +echo > kprobe_events || exit 1 +echo p:myevent do_fork > kprobe_events || exit 1 +grep myevent kprobe_events || exit 1 +[ -d events/kprobes/myevent ] || exit 1 +echo > kprobe_events
tools/testing/ftrace/test.d/kprobe/busy_check.tc new file +14 -0
@@ -0,0 +1,14 @@ +#!/bin/bash +# description: Kprobe dynamic event - busy event check + +[ -f kprobe_events ] || exit 1 + +echo 0 > events/enable || exit 1 +echo > kprobe_events || exit 1 +echo p:myevent do_fork > kprobe_events || exit 1 +[ -d events/kprobes/myevent ] || exit 1 +echo 1 > events/kprobes/myevent/enable || exit 1 +echo > kprobe_events && exit 1 # this must fail +echo 0 > events/kprobes/myevent/enable || exit 1 +echo > kprobe_events # this must succeed +
Hi Masami,
This looks great. I'm a bit busy at the moment (just came back from vacation, and digging myself out of the hole that left me). But I definitely want this in. I have a bunch of tests too, that I can put on top of this. My tests are rather hacky, and hard code a lot of stuff in them, but they do test a bunch of features of ftrace. It shouldn't be too hard to include them here.
Quoted 22 lines · On Tue, 05 Aug 2014 02:45:44 +0000 Masami Hiramatsu…
Hi,
I'd like to introduce a collection of testcases for ftrace to avoid regressions.
For a long time, we've tried to stabilize and extend ftrace tracing infrastructure. This small test framework is a kind of stabilizing work for ftrace. For the first step, this series just introduces a few basic testcases. However, it is easy to add additional tests. I'd like to ask you, ftrace developers, to add tests for your features to ensure it will not be broken by future works.
ftracetest is a tiny bash script so that anyone can easily understand what it does. I think it is better to share and discuss this tests before growing it.
- Is it enough to support bash script? (of course you can invoke other commands from the script)
- What's the good naming method of testcases?
- Is any dependency check required?
Quoted 4 lines
BTW, I decided to put this under
tools/testing/ftraceinstead oftools/testing/selftests/, because all tests requires root privilege. It will be one of discussion points. Anyway, it is easy to integrate this to the selftests.
I agree. I think having its own directory is a good idea. Lets see what other people think. When I get time, I'll see if I can start a branch that pulls this in and start adding my own tests on top of it.
Thanks!
-- Steve
Quoted 8 lines · Steven Rostedt
Hi Masami,
This looks great. I'm a bit busy at the moment (just came back from vacation, and digging myself out of the hole that left me). But I definitely want this in. I have a bunch of tests too, that I can put on top of this. My tests are rather hacky, and hard code a lot of stuff in them, but they do test a bunch of features of ftrace. It shouldn't be too hard to include them here.
Thanks! and I found some ftrace testcases in LTP,
Most of them are for stress test, but basic ideas are good for unit test. And IMHO, ftrace unit test should be within the kernel tree.
Quoted 27 lines
Quoted 22 lines · On Tue, 05 Aug 2014 02:45:44 +0000 Masami Hiramatsu…
Hi,
I'd like to introduce a collection of testcases for ftrace to avoid regressions.
For a long time, we've tried to stabilize and extend ftrace tracing infrastructure. This small test framework is a kind of stabilizing work for ftrace. For the first step, this series just introduces a few basic testcases. However, it is easy to add additional tests. I'd like to ask you, ftrace developers, to add tests for your features to ensure it will not be broken by future works.
ftracetest is a tiny bash script so that anyone can easily understand what it does. I think it is better to share and discuss this tests before growing it.
- Is it enough to support bash script? (of course you can invoke other commands from the script)
- What's the good naming method of testcases?
- Is any dependency check required?
Quoted 7 lines
Quoted 4 lines
BTW, I decided to put this under
tools/testing/ftraceinstead oftools/testing/selftests/, because all tests requires root privilege. It will be one of discussion points. Anyway, it is easy to integrate this to the selftests.I agree. I think having its own directory is a good idea. Lets see what other people think.
Actually, current sefltests provides just a space, not minimal functions, like log management, test statistics, etc. which ftracetest has. And I doubt that Make-based test framework is good for providing such functions.
I think it is also another option to generalize the ftracetest script for selftests :)
Quoted 2 lines
When I get time, I'll see if I can start a branch that pulls this in and start adding my own tests on top of it.
I look forward to see your tests :)
Thank you,
Signature · 4 lines
Masami HIRAMATSU Software Platform Research Dept. Linux Technology Research Center Hitachi, Ltd., Yokohama Research Laboratory E-mail: [email protected]
Hi Steve and Masami,
Quoted 10 lines · Steven Rostedt
Hi Masami,
This looks great. I'm a bit busy at the moment (just came back from vacation, and digging myself out of the hole that left me). But I definitely want this in. I have a bunch of tests too, that I can put on top of this. My tests are rather hacky, and hard code a lot of stuff in them, but they do test a bunch of features of ftrace. It shouldn't be too hard to include them here.
Quoted 22 lines
Quoted 19 lines · On Tue, 05 Aug 2014 02:45:44 +0000 Masami Hiramatsu…
Hi,
I'd like to introduce a collection of testcases for ftrace to avoid regressions.
For a long time, we've tried to stabilize and extend ftrace tracing infrastructure. This small test framework is a kind of stabilizing work for ftrace. For the first step, this series just introduces a few basic testcases. However, it is easy to add additional tests. I'd like to ask you, ftrace developers, to add tests for your features to ensure it will not be broken by future works.
ftracetest is a tiny bash script so that anyone can easily understand what it does. I think it is better to share and discuss this tests before growing it.
- Is it enough to support bash script? (of course you can invoke other commands from the script)
Btw, does it use any bash-specific feature?
Quoted 1 line
Quoted 1 line
- What's the good naming method of testcases?
I'm okay with the ftracetest, but tracing-test may be an option. :)
Quoted 1 line
Quoted 1 line
- Is any dependency check required?
I think we need to start from no/minimum external dependency.
Quoted 9 lines
Quoted 5 lines
BTW, I decided to put this under
tools/testing/ftraceinstead oftools/testing/selftests/, because all tests requires root privilege. It will be one of discussion points. Anyway, it is easy to integrate this to the selftests.I agree. I think having its own directory is a good idea. Lets see what other people think. When I get time, I'll see if I can start a branch that pulls this in and start adding my own tests on top of it.
I also agree to have a separate directory and it's not a selftest :)
Steve, I think you already have a lot of testcases that I want to add, I'll take a look if you setup the branch and try to add my own if needed.
Thanks,
Namhyung
Quoted 5 lines · Namhyung Kim
Quoted 2 lines · Steven Rostedt
Quoted 1 line · Masami Hiramatsu
- What's the good naming method of testcases?
I'm okay with the ftracetest, but tracing-test may be an option. :)
Ouch, did you say about *.tc file name? I have no problem with that too anyway :)
Thanks,
Namhyung
Quoted 29 lines · Namhyung Kim
Hi Steve and Masami,
Quoted 26 lines · Steven Rostedt
Hi Masami,
This looks great. I'm a bit busy at the moment (just came back from vacation, and digging myself out of the hole that left me). But I definitely want this in. I have a bunch of tests too, that I can put on top of this. My tests are rather hacky, and hard code a lot of stuff in them, but they do test a bunch of features of ftrace. It shouldn't be too hard to include them here.
Quoted 13 lines · On Tue, 05 Aug 2014 02:45:44 +0000 Masami Hiramatsu…
Hi,
I'd like to introduce a collection of testcases for ftrace to avoid regressions.
For a long time, we've tried to stabilize and extend ftrace tracing infrastructure. This small test framework is a kind of stabilizing work for ftrace. For the first step, this series just introduces a few basic testcases. However, it is easy to add additional tests. I'd like to ask you, ftrace developers, to add tests for your features to ensure it will not be broken by future works.
Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
ftracetest is a tiny bash script so that anyone can easily understand what it does. I think it is better to share and discuss this tests before growing it.
- Is it enough to support bash script? (of course you can invoke other commands from the script)
Btw, does it use any bash-specific feature?
Not much ("function" keyword is possible bashism). I usually use bash and sometimes unintentionally use bash-specific features :) Anyway, I guess bash is enough common now and sometimes its extensions are good for short scripting.
Quoted 3 lines
Quoted 1 line
Quoted 1 line
- What's the good naming method of testcases?
I'm okay with the ftracetest, but tracing-test may be an option. :)
Ah, as you said, I meant its extensions *.tc. :)
Quoted 15 lines
Quoted 1 line
Quoted 1 line
- Is any dependency check required?
I think we need to start from no/minimum external dependency.
Quoted 9 lines
Quoted 5 lines
BTW, I decided to put this under
tools/testing/ftraceinstead oftools/testing/selftests/, because all tests requires root privilege. It will be one of discussion points. Anyway, it is easy to integrate this to the selftests.I agree. I think having its own directory is a good idea. Lets see what other people think. When I get time, I'll see if I can start a branch that pulls this in and start adding my own tests on top of it.
Quoted 5 lines
I also agree to have a separate directory and it's not a selftest :)
Steve, I think you already have a lot of testcases that I want to add, I'll take a look if you setup the branch and try to add my own if needed.
Great! That's so helpful for us :)
Thank you,
Signature · 4 lines
Masami HIRAMATSU Software Platform Research Dept. Linux Technology Research Center Hitachi, Ltd., Yokohama Research Laboratory E-mail: [email protected]