[DTrace-devel] [PATCH 02/12] Check correctly for status of DTrace job

Kris Van Hees kris.van.hees at oracle.com
Thu Jun 3 09:03:34 PDT 2021


On Fri, May 28, 2021 at 02:35:06PM -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     | 29 ++++++++++++-------
>  1 file changed, 19 insertions(+), 10 deletions(-)
> 
> diff --git a/test/unittest/ustack/tst.jstack_unprintable-bug26045010.sh b/test/unittest/ustack/tst.jstack_unprintable-bug26045010.sh
> index 9f6f6812..f81e1d33 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
> @@ -45,19 +46,27 @@ EOF
>  file=out.txt
>  rm -f $file
>  $dtrace -q $dt_flags -n 'profile-9 /execname == "java" && arg1/ { jstack(4); }' -o $file &
> -sleep 1
> +
> +# confirm that the DTrace job is running successfully
> +for nsecs in `seq 10`; do
> +	sleep 1
> +	jobs
> +	if [ `jobs | wc -l` -eq 0 ]; then
> +		echo DTrace job aborted early
> +		cat $file
> +		exit 1
> +	fi
> +done

I assume you are looping for 10 seconds here to ensure that the dtrace process
does not terminate early, i.e. wait long enough to ensure that it actually gets
to the point of starting the tracing, and not wait an insufficient time that
it seems to be up and running and yet it terminates early after the delay.

The delay time of 10 seconds is of course rather arbitrary and a risk.  Perhaps
it would be better to look at the output in $file for a sign that tracing did
start successfully?  That would avoid any arbitrary timeout.

Also, if you use a loop like this I think you really ought to check for the PID
of the dtrace process rather than just 'absence of any background process(es)'.

> +
> +# 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
> -- 
> 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