ftracetest: Replace usleep with sleep 0.000001
PATCH 1/1 ftracetest: Replace usleep with sleep 0.000001
usleep is a Fedoraism, it's not generally available on Debian based systems AFAICS.
GNU sleep accepts a floating point argument, so use that instead.
--- tools/testing/selftests/ftrace/test.d/event/event-enable.tc | 6 +++--- tools/testing/selftests/ftrace/test.d/event/subsystem-enable.tc | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-)
tools/testing/selftests/ftrace/test.d/event/event-enable.tc +3 -3
@@ -21,7 +21,7 @@ reset_tracer do_reset echo 'sched:sched_switch' > set_event -usleep 1 +sleep 0.000001 count=`cat trace | grep sched_switch | wc -l` if [ $count -eq 0 ]; then
@@ -31,7 +31,7 @@ fi do_reset echo 1 > events/sched/sched_switch/enable -usleep 1 +sleep 0.000001 count=`cat trace | grep sched_switch | wc -l` if [ $count -eq 0 ]; then
@@ -41,7 +41,7 @@ fi do_reset echo 0 > events/sched/sched_switch/enable -usleep 1 +sleep 0.000001 count=`cat trace | grep sched_switch | wc -l` if [ $count -ne 0 ]; then
tools/testing/selftests/ftrace/test.d/event/subsystem-enable.tc +3 -3
@@ -21,7 +21,7 @@ reset_tracer do_reset echo 'sched:*' > set_event -usleep 1 +sleep 0.000001 count=`cat trace | grep -v ^# | awk '{ print $5 }' | sort -u | wc -l` if [ $count -lt 3 ]; then
@@ -31,7 +31,7 @@ fi do_reset echo 1 > events/sched/enable -usleep 1 +sleep 0.000001 count=`cat trace | grep -v ^# | awk '{ print $5 }' | sort -u | wc -l` if [ $count -lt 3 ]; then
@@ -41,7 +41,7 @@ fi do_reset echo 0 > events/sched/enable -usleep 1 +sleep 0.000001 count=`cat trace | grep -v ^# | awk '{ print $5 }' | sort -u | wc -l` if [ $count -ne 0 ]; then
Signature · 1 line
1.9.1
Hi Michael,
Quoted 4 lines · Michael Ellerman
usleep is a Fedoraism, it's not generally available on Debian based systems AFAICS.
GNU sleep accepts a floating point argument, so use that instead.
I tested it on busybox not Debian, sorry. But it seems busybox's sleep doesn't support floating point argument..
/ # ls -l which sleep
lrwxrwxrwx 1 root rooot 7 May 22 2014 /bin/sleep -> busybox
/ # sleep 0.1
sleep: invalid number '0.1'
Thanks,
Namhyung
Hi,
Quoted 8 lines · Namhyung Kim
Hi Michael,
Quoted 4 lines · Michael Ellerman
usleep is a Fedoraism, it's not generally available on Debian based systems AFAICS.
GNU sleep accepts a floating point argument, so use that instead.
Quoted 8 lines
I tested it on busybox not Debian, sorry. But it seems busybox's sleep doesn't support floating point argument..
/ # ls -l
which sleep
lrwxrwxrwx 1 root rooot 7 May 22 2014/bin/sleep-> busybox/ # sleep 0.1
sleep: invalid number '0.1'
I also have same result. Basically, ftracetest should be able to run on busybox. So, I think we'd better check whether usleep is available, and if not, fallback to sleep like as below.
if which usleep &> /dev/null; then
usleep 1
else
sleep 0.000001
fi
Thank you,
Signature · 4 lines
Masami HIRAMATSU Software Platform Research Dept. Linux Technology Research Center Hitachi, Ltd., Yokohama Research Laboratory E-mail: [email protected]
Quoted 14 lines · Masami Hiramatsu
Hi,
Quoted 11 lines · Namhyung Kim
Hi Michael,
Quoted 4 lines · Michael Ellerman
usleep is a Fedoraism, it's not generally available on Debian based systems AFAICS.
GNU sleep accepts a floating point argument, so use that instead.
I tested it on busybox not Debian, sorry. But it seems busybox's sleep doesn't support floating point argument..
Quoted 7 lines
Quoted 5 lines
/ # ls -l
which sleep
lrwxrwxrwx 1 root rooot 7 May 22 2014/bin/sleep-> busybox/ # sleep 0.1
sleep: invalid number '0.1'I also have same result. Basically, ftracetest should be able to run on busybox.
Yeah OK.
Quoted 8 lines
So, I think we'd better check whether usleep is available, and if not, fallback to sleep like as below.
if which usleep &>
/dev/null; then
usleep 1
elsesleep 0.000001fi
Why do we need to call (u)sleep anyway? It's generally a bad sign when tests use sleep as it's asking for random timing related failures to creep in.
cheers
Quoted 6 lines · Michael Ellerman
usleep is a Fedoraism, it's not generally available on Debian based systems AFAICS.
GNU sleep accepts a floating point argument, so use that instead.
Signed-off-by Michael Ellerman <[email protected]>
Could ftrace user interface be enhanced not to need random delays?
Pavel
Quoted 67 lines
--- tools/testing/selftests/ftrace/test.d/event/event-enable.tc | 6 +++--- tools/testing/selftests/ftrace/test.d/event/subsystem-enable.tc | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-)tools/testing/selftests/ftrace/test.d/event/event-enable.tc +3
-3@@ -21,7 +21,7 @@ reset_tracer do_reset echo 'sched:sched_switch' > set_event -usleep 1 +sleep 0.000001 count=`cat trace | grep sched_switch | wc -l` if [ $count -eq 0 ]; then@@ -31,7 +31,7 @@ fi do_reset echo 1 > events/sched/sched_switch/enable -usleep 1 +sleep 0.000001 count=`cat trace | grep sched_switch | wc -l` if [ $count -eq 0 ]; then@@ -41,7 +41,7 @@ fi do_reset echo 0 > events/sched/sched_switch/enable -usleep 1 +sleep 0.000001 count=`cat trace | grep sched_switch | wc -l` if [ $count -ne 0 ]; thentools/testing/selftests/ftrace/test.d/event/subsystem-enable.tc +3
-3@@ -21,7 +21,7 @@ reset_tracer do_reset echo 'sched:*' > set_event -usleep 1 +sleep 0.000001 count=`cat trace | grep -v ^# | awk '{ print $5 }' | sort -u | wc -l` if [ $count -lt 3 ]; then@@ -31,7 +31,7 @@ fi do_reset echo 1 > events/sched/enable -usleep 1 +sleep 0.000001 count=`cat trace | grep -v ^# | awk '{ print $5 }' | sort -u | wc -l` if [ $count -lt 3 ]; then@@ -41,7 +41,7 @@ fi do_reset echo 0 > events/sched/enable -usleep 1 +sleep 0.000001 count=`cat trace | grep -v ^# | awk '{ print $5 }' | sort -u | wc -l` if [ $count -ne 0 ]; then
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Steven Rostedt
maintainerQuoted 10 lines · On Sat, 20 Dec 2014 21:42:13 +0100 Pavel Machek <[email protected]> wrote:
Quoted 6 lines · Michael Ellerman
usleep is a Fedoraism, it's not generally available on Debian based systems AFAICS.
GNU sleep accepts a floating point argument, so use that instead.
Signed-off-by Michael Ellerman <[email protected]>Could ftrace user interface be enhanced not to need random delays?
Not sure what you are talking about. These "random delays" are not for the interface, but instead to force some events to happen and to make sure they did.
As the subject states, this is for "ftracetest" which is the selftests for ftrace.
The usleep is basically a "do something to trigger events", and we don't want to wait long in doing it.
-- Steve
Quoted 18 lines · Steven Rostedt
Quoted 10 lines · On Sat, 20 Dec 2014 21:42:13 +0100 Pavel Machek <[email protected]> wrote:
Quoted 6 lines · Michael Ellerman
usleep is a Fedoraism, it's not generally available on Debian based systems AFAICS.
GNU sleep accepts a floating point argument, so use that instead.
Signed-off-by Michael Ellerman <[email protected]>Could ftrace user interface be enhanced not to need random delays?
Not sure what you are talking about. These "random delays" are not for the interface, but instead to force some events to happen and to make sure they did.
Quoted 5 lines
As the subject states, this is for "ftracetest" which is the selftests for ftrace.
The usleep is basically a "do something to trigger events", and we don't want to wait long in doing it.
Right. AFAIK what ftracetest expects is a scheduler event so it doesn't need to be the [u]sleep.
Thanks,
Namhyung
Quoted 19 lines · Namhyung Kim
Quoted 18 lines · Steven Rostedt
Quoted 10 lines · On Sat, 20 Dec 2014 21:42:13 +0100 Pavel Machek <[email protected]> wrote:
Quoted 6 lines · Michael Ellerman
usleep is a Fedoraism, it's not generally available on Debian based systems AFAICS.
GNU sleep accepts a floating point argument, so use that instead.
Signed-off-by Michael Ellerman <[email protected]>Could ftrace user interface be enhanced not to need random delays?
Not sure what you are talking about. These "random delays" are not for the interface, but instead to force some events to happen and to make sure they did.
Quoted 8 lines
Quoted 5 lines
As the subject states, this is for "ftracetest" which is the selftests for ftrace.
The usleep is basically a "do something to trigger events", and we don't want to wait long in doing it.
Right. AFAIK what ftracetest expects is a scheduler event so it doesn't need to be the [u]sleep.
Would /bin/true work in that case?
cheers
Quoted 23 lines · Michael Ellerman
Quoted 22 lines · Namhyung Kim
Quoted 21 lines · Steven Rostedt
Quoted 10 lines · On Sat, 20 Dec 2014 21:42:13 +0100 Pavel Machek <[email protected]> wrote:
Quoted 6 lines · Michael Ellerman
usleep is a Fedoraism, it's not generally available on Debian based systems AFAICS.
GNU sleep accepts a floating point argument, so use that instead.
Signed-off-by Michael Ellerman <[email protected]>Could ftrace user interface be enhanced not to need random delays?
Not sure what you are talking about. These "random delays" are not for the interface, but instead to force some events to happen and to make sure they did.
As the subject states, this is for "ftracetest" which is the selftests for ftrace.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
The usleep is basically a "do something to trigger events", and we don't want to wait long in doing it.
Right. AFAIK what ftracetest expects is a scheduler event so it doesn't need to be the [u]sleep.
Would
/bin/truework in that case?
As other scripts doing, just (echo "forked") would be enough. It forks sub shell and wait for that.
Please check test.d/kprobe/kprobe_args.tc
Thanks!
Signature · 4 lines
Masami HIRAMATSU Software Platform Research Dept. Linux Technology Research Center Hitachi, Ltd., Yokohama Research Laboratory E-mail: [email protected]
Quoted 18 lines · Steven Rostedt
Quoted 10 lines · On Sat, 20 Dec 2014 21:42:13 +0100 Pavel Machek <[email protected]> wrote:
Quoted 6 lines · Michael Ellerman
usleep is a Fedoraism, it's not generally available on Debian based systems AFAICS.
GNU sleep accepts a floating point argument, so use that instead.
Signed-off-by Michael Ellerman <[email protected]>Could ftrace user interface be enhanced not to need random delays?
Not sure what you are talking about. These "random delays" are not for the interface, but instead to force some events to happen and to make sure they did.
Quoted 5 lines
As the subject states, this is for "ftracetest" which is the selftests for ftrace.
The usleep is basically a "do something to trigger events", and we don't want to wait long in doing it.
Yep, I misunderstood, sorry.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html