Skip to content

Commit

Permalink
Check correctly for status of DTrace job
Browse files Browse the repository at this point in the history
A test launched a DTrace job in the background and was incorrectly
checking its status.  Specifically, it was passing spuriously.  Fix,
and for now mark XFAIL.

Signed-off-by: Eugene Loh <eugene.loh@oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees@oracle.com>
  • Loading branch information
euloh authored and kvanhees committed Jun 18, 2021
1 parent 0e55522 commit 7c27af0
Showing 1 changed file with 44 additions and 14 deletions.
58 changes: 44 additions & 14 deletions test/unittest/ustack/tst.jstack_unprintable-bug26045010.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/bin/bash
#
# Oracle Linux DTrace.
# Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
# Licensed under the Universal Permissive License v 1.0 as shown at
# http://oss.oracle.com/licenses/upl.
#
# @@xfail: dtv2
if [ $# != 1 ]; then
echo expected one argument: '<'dtrace-path'>'
exit 2
Expand Down Expand Up @@ -44,31 +45,60 @@ EOF

file=out.txt
rm -f $file
$dtrace -q $dt_flags -n 'profile-9 /execname == "java" && arg1/ { jstack(4); }' -o $file &
sleep 1
$dtrace -q $dt_flags -n '
BEGIN
{
printf("hello world\n");
}
profile-9
/execname == "java" && arg1/
{
jstack(4);
}' -o $file &
pid=$!

# confirm that the DTrace job is running successfully
nsecs=0
while true; do
sleep 1
nsecs=$(($nsecs + 1))
if grep -q "hello world" $file; then
break
fi
if ! ps -p $pid >& /dev/null; then
echo DTrace died
cat $file
rm -f $file
exit 1
fi
if [ $nsecs -ge 10 ] ; then
echo error starting DTrace job
kill %1
cat $file
rm -f $file
exit 1
fi
done

# run the Java job
/usr/bin/java bug26045010

# kill the DTrace job
sleep 1
kill %1
sleep 1

status=$?
if [ "$status" -ne 0 ]; then
echo $tst: dtrace failed
rm -f $file
exit $status
fi
wait

# check results
n=`sed 's/[[:print:]]//g' $file | awk 'BEGIN {x = 0}; NF>0 {x += 1}; END {print x}'`
if [ $n -gt 0 ]; then
echo $tst: $n lines have unprintable characters
sed 's/[[:print:]]//g' $file | awk 'NF>0'
echo "==================== file start"
cat $file
echo "==================== file end"
status=1
n=1
fi

rm -f $file

exit $status

exit $n

0 comments on commit 7c27af0

Please sign in to comment.