[DTrace-devel] [PATCH v3 02/12] Check correctly for status of DTrace job
Kris Van Hees
kris.van.hees at oracle.com
Tue Jun 15 11:14:47 PDT 2021
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>
On Tue, Jun 15, 2021 at 02:06:50PM -0400, eugene.loh at oracle.com wrote:
> From: Eugene Loh <eugene.loh at oracle.com>
>
> 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 at oracle.com>
> ---
> .../tst.jstack_unprintable-bug26045010.sh | 58 ++++++++++++++-----
> 1 file changed, 44 insertions(+), 14 deletions(-)
>
> diff --git a/test/unittest/ustack/tst.jstack_unprintable-bug26045010.sh b/test/unittest/ustack/tst.jstack_unprintable-bug26045010.sh
> index 9f6f6812..c5fca2a5 100755
> --- a/test/unittest/ustack/tst.jstack_unprintable-bug26045010.sh
> +++ b/test/unittest/ustack/tst.jstack_unprintable-bug26045010.sh
> @@ -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
> @@ -44,20 +45,50 @@ 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
> @@ -65,10 +96,9 @@ if [ $n -gt 0 ]; then
> echo "==================== file start"
> cat $file
> echo "==================== file end"
> - status=1
> + n=1
> fi
>
> rm -f $file
>
> -exit $status
> -
> +exit $n
> --
> 2.18.4
>
>
> _______________________________________________
> DTrace-devel mailing list
> DTrace-devel at oss.oracle.com
> https://oss.oracle.com/mailman/listinfo/dtrace-devel
More information about the DTrace-devel
mailing list