ftracetest: Do not use usleep directly
PATCH v3 1/1 ftracetest: Do not use usleep directly
The usleep is only provided on distros from Redhat so running ftracetest on other distro resulted in failures due to the missing usleep.
The reason of using [u]sleep in the test was to generate (scheduler) events. It can be done various ways like this:
yield() { ping localhost -c 1 || sleep .001 || usleep 1 || sleep 1; }
For more information to the history of this patch, please refer to:
--- tools/testing/selftests/ftrace/test.d/event/event-enable.tc | 13 ++++++++++--- .../selftests/ftrace/test.d/event/subsystem-enable.tc | 13 ++++++++++--- .../selftests/ftrace/test.d/event/toplevel-enable.tc | 13 +++++++++++++ 3 files changed, 33 insertions(+), 6 deletions(-)
tools/testing/selftests/ftrace/test.d/event/event-enable.tc +10 -3
@@ -12,6 +12,10 @@ fail() { #msg exit $FAIL } +yield() { + ping localhost -c 1 || sleep .001 || usleep 1 || sleep 1 +} + if [ ! -f set_event -o ! -d events/sched ]; then echo "event tracing is not supported" exit_unsupported
@@ -21,7 +25,8 @@ reset_tracer do_reset echo 'sched:sched_switch' > set_event -usleep 1 + +yield count=`cat trace | grep sched_switch | wc -l` if [ $count -eq 0 ]; then
@@ -31,7 +36,8 @@ fi do_reset echo 1 > events/sched/sched_switch/enable -usleep 1 + +yield count=`cat trace | grep sched_switch | wc -l` if [ $count -eq 0 ]; then
@@ -41,7 +47,8 @@ fi do_reset echo 0 > events/sched/sched_switch/enable -usleep 1 + +yield count=`cat trace | grep sched_switch | wc -l` if [ $count -ne 0 ]; then
tools/testing/selftests/ftrace/test.d/event/subsystem-enable.tc +10 -3
@@ -12,6 +12,10 @@ fail() { #msg exit $FAIL } +yield() { + ping localhost -c 1 || sleep .001 || usleep 1 || sleep 1 +} + if [ ! -f set_event -o ! -d events/sched ]; then echo "event tracing is not supported" exit_unsupported
@@ -21,7 +25,8 @@ reset_tracer do_reset echo 'sched:*' > set_event -usleep 1 + +yield count=`cat trace | grep -v ^# | awk '{ print $5 }' | sort -u | wc -l` if [ $count -lt 3 ]; then
@@ -31,7 +36,8 @@ fi do_reset echo 1 > events/sched/enable -usleep 1 + +yield count=`cat trace | grep -v ^# | awk '{ print $5 }' | sort -u | wc -l` if [ $count -lt 3 ]; then
@@ -41,7 +47,8 @@ fi do_reset echo 0 > events/sched/enable -usleep 1 + +yield count=`cat trace | grep -v ^# | awk '{ print $5 }' | sort -u | wc -l` if [ $count -ne 0 ]; then
tools/testing/selftests/ftrace/test.d/event/toplevel-enable.tc +13 -0
@@ -12,6 +12,10 @@ fail() { #msg exit $FAIL } +yield() { + ping localhost -c 1 || sleep .001 || usleep 1 || sleep 1 +} + if [ ! -f available_events -o ! -f set_event -o ! -d events ]; then echo "event tracing is not supported" exit_unsupported
@@ -21,6 +25,9 @@ reset_tracer do_reset echo '*:*' > set_event + +yield + count=`cat trace | grep -v ^# | wc -l` if [ $count -eq 0 ]; then fail "none of events are recorded"
@@ -29,6 +36,9 @@ fi do_reset echo 1 > events/enable + +yield + count=`cat trace | grep -v ^# | wc -l` if [ $count -eq 0 ]; then fail "none of events are recorded"
@@ -37,6 +47,9 @@ fi do_reset echo 0 > events/enable + +yield + count=`cat trace | grep -v ^# | wc -l` if [ $count -ne 0 ]; then fail "any of events should not be recorded"
Signature · 1 line
2.3.4
Quoted 12 lines · Namhyung Kim
The usleep is only provided on distros from Redhat so running ftracetest on other distro resulted in failures due to the missing usleep.
The reason of using [u]sleep in the test was to generate (scheduler) events. It can be done various ways like this:
yield(){ ping localhost -c 1 || sleep .001 || usleep 1 || sleep 1; }For more information to the history of this patch, please refer to:
Quoted 8 lines
Reported-by Michael Ellerman <[email protected]>Reported-by Dave Jones <[email protected]>Reported-by Luis Henriques <[email protected]>Suggested-by Pádraig Brady <[email protected]>Acked-by Steven Rostedt <[email protected]>Acked-by Masami Hiramatsu <[email protected]>Signed-off-by Namhyung Kim <[email protected]>---
Thanks for getting to this quickly. Applied it to
linux-kselftest next for 4.1
thanks,
-- Shuah
Signature · 5 lines
Shuah Khan Sr. Linux Kernel Developer Open Source Innovation Group Samsung Research America (Silicon Valley) [email protected] | (970) 217-8978