Commit 2bfd4d1f authored by Namhyung Kim's avatar Namhyung Kim Committed by Shuah Khan

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:

Link: http://lkml.kernel.org/r/1427329943-16896-1-git-send-email-namhyung@kernel.orgReported-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Reported-by: default avatarDave Jones <davej@codemonkey.org.uk>
Reported-by: default avatarLuis Henriques <luis.henriques@canonical.com>
Suggested-by: default avatarPádraig Brady <P@draigBrady.com>
Acked-by: default avatarSteven Rostedt <rostedt@goodmis.org>
Acked-by: default avatarMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
Signed-off-by: default avatarShuah Khan <shuahkh@osg.samsung.com>
parent 6886f41d
...@@ -12,6 +12,10 @@ fail() { #msg ...@@ -12,6 +12,10 @@ fail() { #msg
exit $FAIL exit $FAIL
} }
yield() {
ping localhost -c 1 || sleep .001 || usleep 1 || sleep 1
}
if [ ! -f set_event -o ! -d events/sched ]; then if [ ! -f set_event -o ! -d events/sched ]; then
echo "event tracing is not supported" echo "event tracing is not supported"
exit_unsupported exit_unsupported
...@@ -21,7 +25,8 @@ reset_tracer ...@@ -21,7 +25,8 @@ reset_tracer
do_reset do_reset
echo 'sched:sched_switch' > set_event echo 'sched:sched_switch' > set_event
usleep 1
yield
count=`cat trace | grep sched_switch | wc -l` count=`cat trace | grep sched_switch | wc -l`
if [ $count -eq 0 ]; then if [ $count -eq 0 ]; then
...@@ -31,7 +36,8 @@ fi ...@@ -31,7 +36,8 @@ fi
do_reset do_reset
echo 1 > events/sched/sched_switch/enable echo 1 > events/sched/sched_switch/enable
usleep 1
yield
count=`cat trace | grep sched_switch | wc -l` count=`cat trace | grep sched_switch | wc -l`
if [ $count -eq 0 ]; then if [ $count -eq 0 ]; then
...@@ -41,7 +47,8 @@ fi ...@@ -41,7 +47,8 @@ fi
do_reset do_reset
echo 0 > events/sched/sched_switch/enable echo 0 > events/sched/sched_switch/enable
usleep 1
yield
count=`cat trace | grep sched_switch | wc -l` count=`cat trace | grep sched_switch | wc -l`
if [ $count -ne 0 ]; then if [ $count -ne 0 ]; then
......
...@@ -12,6 +12,10 @@ fail() { #msg ...@@ -12,6 +12,10 @@ fail() { #msg
exit $FAIL exit $FAIL
} }
yield() {
ping localhost -c 1 || sleep .001 || usleep 1 || sleep 1
}
if [ ! -f set_event -o ! -d events/sched ]; then if [ ! -f set_event -o ! -d events/sched ]; then
echo "event tracing is not supported" echo "event tracing is not supported"
exit_unsupported exit_unsupported
...@@ -21,7 +25,8 @@ reset_tracer ...@@ -21,7 +25,8 @@ reset_tracer
do_reset do_reset
echo 'sched:*' > set_event echo 'sched:*' > set_event
usleep 1
yield
count=`cat trace | grep -v ^# | awk '{ print $5 }' | sort -u | wc -l` count=`cat trace | grep -v ^# | awk '{ print $5 }' | sort -u | wc -l`
if [ $count -lt 3 ]; then if [ $count -lt 3 ]; then
...@@ -31,7 +36,8 @@ fi ...@@ -31,7 +36,8 @@ fi
do_reset do_reset
echo 1 > events/sched/enable echo 1 > events/sched/enable
usleep 1
yield
count=`cat trace | grep -v ^# | awk '{ print $5 }' | sort -u | wc -l` count=`cat trace | grep -v ^# | awk '{ print $5 }' | sort -u | wc -l`
if [ $count -lt 3 ]; then if [ $count -lt 3 ]; then
...@@ -41,7 +47,8 @@ fi ...@@ -41,7 +47,8 @@ fi
do_reset do_reset
echo 0 > events/sched/enable echo 0 > events/sched/enable
usleep 1
yield
count=`cat trace | grep -v ^# | awk '{ print $5 }' | sort -u | wc -l` count=`cat trace | grep -v ^# | awk '{ print $5 }' | sort -u | wc -l`
if [ $count -ne 0 ]; then if [ $count -ne 0 ]; then
......
...@@ -12,6 +12,10 @@ fail() { #msg ...@@ -12,6 +12,10 @@ fail() { #msg
exit $FAIL 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 if [ ! -f available_events -o ! -f set_event -o ! -d events ]; then
echo "event tracing is not supported" echo "event tracing is not supported"
exit_unsupported exit_unsupported
...@@ -21,6 +25,9 @@ reset_tracer ...@@ -21,6 +25,9 @@ reset_tracer
do_reset do_reset
echo '*:*' > set_event echo '*:*' > set_event
yield
count=`cat trace | grep -v ^# | wc -l` count=`cat trace | grep -v ^# | wc -l`
if [ $count -eq 0 ]; then if [ $count -eq 0 ]; then
fail "none of events are recorded" fail "none of events are recorded"
...@@ -29,6 +36,9 @@ fi ...@@ -29,6 +36,9 @@ fi
do_reset do_reset
echo 1 > events/enable echo 1 > events/enable
yield
count=`cat trace | grep -v ^# | wc -l` count=`cat trace | grep -v ^# | wc -l`
if [ $count -eq 0 ]; then if [ $count -eq 0 ]; then
fail "none of events are recorded" fail "none of events are recorded"
...@@ -37,6 +47,9 @@ fi ...@@ -37,6 +47,9 @@ fi
do_reset do_reset
echo 0 > events/enable echo 0 > events/enable
yield
count=`cat trace | grep -v ^# | wc -l` count=`cat trace | grep -v ^# | wc -l`
if [ $count -ne 0 ]; then if [ $count -ne 0 ]; then
fail "any of events should not be recorded" fail "any of events should not be recorded"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment