[PATCH v5 6/9] stapsdt: add test for listing systemwide probes in object
Alan Maguire <[email protected]> Wed, 4 Mar 2026 08:01:22 +0000
| Newsgroups | dev.linux.lists.dtrace |
|---|---|
| Message-ID | <[email protected]> |
Need to use -lm since we need to specify module level to identify the object. Signed-off-by: Alan Maguire <[email protected]> --- .../usdt/tst.stapsdt-notes-systemwide-l.sh | 48 +++++++++++++++++++ .../usdt/tst.stapsdt-notes-systemwide-lv.sh | 48 +++++++++++++++++++ 2 files changed, 96 insertions(+) create mode 100755 test/unittest/usdt/tst.stapsdt-notes-systemwide-l.sh create mode 100755 test/unittest/usdt/tst.stapsdt-notes-systemwide-lv.sh diff --git a/test/unittest/usdt/tst.stapsdt-notes-systemwide-l.sh b/test/unittest/usdt/tst.stapsdt-notes-systemwide-l.sh new file mode 100755 index 00000000..fab71973 --- /dev/null +++ b/test/unittest/usdt/tst.stapsdt-notes-systemwide-l.sh @@ -0,0 +1,48 @@ +#!/bin/bash +# +# Oracle Linux DTrace. +# Copyright (c) 2026, 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. + +# This test covers stapsdt probes fired by the STAP_PROBEn macros, +# testing listing probes. + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 +CC=/usr/bin/gcc +CFLAGS="-I${PWD}/test/unittest/usdt" + +DIRNAME="$tmpdir/usdt-notes.$$.$RANDOM" +mkdir -p $DIRNAME +cd $DIRNAME + +cat > test.c <<EOF +#include <sdt_notes.h> + +int +main(int argc, char **argv) +{ + STAP_PROBE(test_prov, zero); + STAP_PROBE1(test_prov, one, argc); + STAP_PROBE2(test_prov, two, 2, 3); + STAP_PROBE4(test_prov, args, argc, argv[0], argv[1] + 4, 18); +} +EOF + +${CC} ${CFLAGS} -o test test.c +if [ $? -ne 0 ]; then + echo "failed to compile test.c" >& 2 + exit 1 +fi + +export PATH=.:$PATH + +$dtrace -c './test arg1val' -lm test_prov\*:test +status=$? + +exit $status diff --git a/test/unittest/usdt/tst.stapsdt-notes-systemwide-lv.sh b/test/unittest/usdt/tst.stapsdt-notes-systemwide-lv.sh new file mode 100755 index 00000000..e77eaf38 --- /dev/null +++ b/test/unittest/usdt/tst.stapsdt-notes-systemwide-lv.sh @@ -0,0 +1,48 @@ +#!/bin/bash +# +# Oracle Linux DTrace. +# Copyright (c) 2026, 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. + +# This test covers stapsdt probes fired by the STAP_PROBEn macros, +# testing listing probes. + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 +CC=/usr/bin/gcc +CFLAGS="-I${PWD}/test/unittest/usdt" + +DIRNAME="$tmpdir/usdt-notes.$$.$RANDOM" +mkdir -p $DIRNAME +cd $DIRNAME + +cat > test.c <<EOF +#include <sdt_notes.h> + +int +main(int argc, char **argv) +{ + STAP_PROBE(test_prov, zero); + STAP_PROBE1(test_prov, one, argc); + STAP_PROBE2(test_prov, two, argc, argv[0][0]); + STAP_PROBE4(test_prov, args, argc, argv[0], argv[1] + 4, 18); +} +EOF + +${CC} ${CFLAGS} -o test test.c +if [ $? -ne 0 ]; then + echo "failed to compile test.c" >& 2 + exit 1 +fi + +export PATH=.:$PATH + +$dtrace -c './test arg1val' -lvm test_prov\*:test +status=$? + +exit $status -- 2.43.5