[DTrace-devel] [PATCH 4/5] test, usdt: test multiple simultaneous tracers of multiple processes

Kris Van Hees kris.van.hees at oracle.com
Sat May 13 15:30:52 UTC 2023


How do you know that test PASS actually indicates that the condition you aim
to test was exercised and found to work?  As I see it, you do not distinguish
between the probe firings, so it is perfectly possible that you get the first
five from the first test and dtrace, and the second five from the second test
and dtrace, meaning that they were consecutive and this no simultaneous tracing
ever took place.

I modified the test to pass i into the go() probe call (probe go(int i)) and
then add arg0 at the end of the printf, and I actually got exactly the
situation I mention above (and a few times not all probes were reported, which
means that the initial sleep(3) wasn't long enough).

This test needs more work to ensure it tests what it should in a predictable
manner, and in a way that the results verification (possibly using a .r.p
script) verifies that simultaneous tracing took place.

(Disclaimer: I tested this on a tree that has all pending patches, i.e. yours,
Eugene's, and mine) so it is possible that your testing appeared to work OK
because it predates some other bugfixes.)

On Mon, Apr 24, 2023 at 08:08:15PM +0100, Nick Alcock via DTrace-devel wrote:
> We start them one after the other, to determine whether starting (or
> starting tracing) one process affects the same active tracepoints in
> other processes currently being traced.
> 
> Signed-off-by: Nick Alcock <nick.alcock at oracle.com>
> ---
>  test/unittest/usdt/tst.multitrace.r  | 10 +++
>  test/unittest/usdt/tst.multitrace.sh | 92 ++++++++++++++++++++++++++++
>  2 files changed, 102 insertions(+)
>  create mode 100644 test/unittest/usdt/tst.multitrace.r
>  create mode 100755 test/unittest/usdt/tst.multitrace.sh
> 
> diff --git a/test/unittest/usdt/tst.multitrace.r b/test/unittest/usdt/tst.multitrace.r
> new file mode 100644
> index 0000000000000..14888902841fe
> --- /dev/null
> +++ b/test/unittest/usdt/tst.multitrace.r
> @@ -0,0 +1,10 @@
> +test:main:go
> +test:main:go
> +test:main:go
> +test:main:go
> +test:main:go
> +test:main:go
> +test:main:go
> +test:main:go
> +test:main:go
> +test:main:go
> diff --git a/test/unittest/usdt/tst.multitrace.sh b/test/unittest/usdt/tst.multitrace.sh
> new file mode 100755
> index 0000000000000..b0dc6c4745fa1
> --- /dev/null
> +++ b/test/unittest/usdt/tst.multitrace.sh
> @@ -0,0 +1,92 @@
> +#!/bin/bash
> +#
> +# Oracle Linux DTrace.
> +# Copyright (c) 2006, 2023, 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.
> +#
> +# Test multiple simultaneous tracers, invoked successively (so there
> +# are multiple dtracers and multiple processes tracing the same probe).
> +if [ $# != 1 ]; then
> +	echo expected one argument: '<'dtrace-path'>'
> +	exit 2
> +fi
> +
> +dtrace=$1
> +CC=/usr/bin/gcc
> +CFLAGS=
> +
> +DIRNAME="$tmpdir/usdt-multitrace.$$.$RANDOM"
> +mkdir -p $DIRNAME
> +cd $DIRNAME
> +
> +cat > prov.d <<EOF
> +provider test_prov {
> +	probe go();
> +	probe exiting();
> +};
> +EOF
> +
> +$dtrace -h -s prov.d
> +if [ $? -ne 0 ]; then
> +	echo "failed to generate header file" >& 2
> +	exit 1
> +fi
> +
> +cat > test.c <<EOF
> +#include <sys/types.h>
> +#include "prov.h"
> +
> +int
> +main(int argc, char **argv)
> +{
> +	size_t i;
> +	sleep(3); /* until we have startup sync */
> +	for (i = 0; i < 5; i++) {
> +		if (TEST_PROV_GO_ENABLED())
> +			TEST_PROV_GO();
> +		sleep(1);
> +	}
> +	TEST_PROV_EXITING();
> +
> +	return 0;
> +}
> +EOF
> +
> +${CC} ${CFLAGS} -c test.c
> +if [ $? -ne 0 ]; then
> +	echo "failed to compile test.c" >& 2
> +	exit 1
> +fi
> +$dtrace -G -s prov.d test.o
> +if [ $? -ne 0 ]; then
> +	echo "failed to create DOF" >& 2
> +	exit 1
> +fi
> +${CC} ${CFLAGS} -o test test.o prov.o
> +if [ $? -ne 0 ]; then
> +	echo "failed to link final executable" >& 2
> +	exit 1
> +fi
> +
> +script() {
> +	$dtrace -qs /dev/stdin <<EOF | grep -v '^$'| grep -v '^$'
> +	test_prov$1:::go
> +	{
> +		printf("%s:%s:%s\n", probemod, probefunc, probename);
> +	}
> +	test_prov$1:::exiting
> +	{
> +		exit(0);
> +	}
> +EOF
> +}
> +
> +./test & script $! &
> +sleep 2
> +./test & script $! &
> +wait
> +
> +status=$?
> +
> +exit $status
> -- 
> 2.39.1.268.g9de2f9a303
> 
> 
> _______________________________________________
> 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