Skip to content

Commit 9a154c8

Browse files
committed
ftracetest: Fix instance test to use proper shell command for pids
The ftracetest instance test used parsing of the "jobs" output to find the pid of the subshell that is executed previously. But this is not portable to all major shells that may run these tests. The proper way to get the pid of the subshell is the shell command "$!". This will return the pid of the previously executed command. Use that instead, otherwise the test does not work in all environments. Link: http://lkml.kernel.org/r/20151211143617.65f4d7a1@gandalf.local.home Reported-by: Michael Ellerman <mpe@ellerman.id.au> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
1 parent b33c8ff commit 9a154c8

File tree

1 file changed

+5
-10
lines changed
  • tools/testing/selftests/ftrace/test.d/instances

1 file changed

+5
-10
lines changed

tools/testing/selftests/ftrace/test.d/instances/instance.tc

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,28 +39,23 @@ instance_slam() {
3939
}
4040

4141
instance_slam &
42-
x=`jobs -l`
43-
p1=`echo $x | cut -d' ' -f2`
42+
p1=$!
4443
echo $p1
4544

4645
instance_slam &
47-
x=`jobs -l | tail -1`
48-
p2=`echo $x | cut -d' ' -f2`
46+
p2=$!
4947
echo $p2
5048

5149
instance_slam &
52-
x=`jobs -l | tail -1`
53-
p3=`echo $x | cut -d' ' -f2`
50+
p3=$!
5451
echo $p3
5552

5653
instance_slam &
57-
x=`jobs -l | tail -1`
58-
p4=`echo $x | cut -d' ' -f2`
54+
p4=$!
5955
echo $p4
6056

6157
instance_slam &
62-
x=`jobs -l | tail -1`
63-
p5=`echo $x | cut -d' ' -f2`
58+
p5=$!
6459
echo $p5
6560

6661
ls -lR >/dev/null

0 commit comments

Comments
 (0)