[DTrace-devel] [PATCH] test: Fix tst.InvalidModule4.sh

Eugene Loh eugene.loh at oracle.com
Mon Apr 4 16:12:49 UTC 2022


Bringing this to the internal list for some discussion about expected 
behavior.

This test was failing on all platforms, and I'm bewildered about what 
behavior was expected.

If you say "dtrace -lm foo", then you should get all probes with module foo.

1)  The test checks "dtrace -lm unix".  There was a module unix in 
Solaris, not in legacy DT on Linux, but now in DT on BPF.

2)  If you specify a nonexistent module, DTrace is okay with that and 
returns error code 0.  The test expects otherwise?

3)  What does
         dtrace -lm unix'/probefunc == "preempt"/{printf("FOUND");}'
mean?  The test does not like this, but I do not know why. Because 
module unix does not exist?  Or because the rest of the name looks like 
a probe predicate and clause?

Anyhow, the test was apparently never vetted on Solaris.  On Solaris,

*)  The predicate/clause stuff is simply ignored.
*)  There is a unix module that has lots of probes.
*)  There are even :unix:preempt: probes.
*)  The return value is in any case 0, even if a bogus module name is 
specified.

Not earth-shattering stuff, but should be cleaned up before we test the 
next errata.  Sorry if I mangled the commit message in the patch.

On 4/4/22 1:30 AM, eugene.loh at oracle.com wrote:
> From: Eugene Loh <eugene.loh at oracle.com>
>
> This test has had a mysterious history.  It was apparently introduced
> as part of the DTrace port to Linux.  It presumed the probe description
> was not valid, but the reasoning is unclear why.  More specifically, the
> probe description was seemingly valid under Solaris and matched multiple
> probes.  With the port to Linux, there were no module-unix probes.  Thus,
> the probe description ended up not matching any probes, but perhaps not
> for the originally intended reason.
>
> With the port to DTrace on BPF, there are now module-unix probes.  So
> DTrace finds matching probes, which causes the test to FAIL, but for
> dubious reasons.
>
> The test also perhaps assumed that DTrace would return a nonzero value
> if the probe description fits no probes.  If no probes are found,
> however, DTrace simply indicates so while still returning a 0 value --
> whether on Solaris, legacy DTrace on Linux, or now DTrace on BPF.
>
> The next intriguing development was that the XFAIL annotation was lifted
> in patch 9574434662d0
> "Remove @@xfail markers from tests that should pass with assoc support".
> Again, the reasoning is unclear.  Specifically, there is no connection
> between this test and associative support.
>
> Fix the test so that it clearly references an invalid module:  foounix.
> Ignore the return value of the command.  Now, the test should correctly
> find no matching probes for the invalid module;  the test should now
> pass.
>
> Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
> ---
>   .../dtrace-util/man.ListProbesWithModules     |  5 -----
>   .../unittest/dtrace-util/tst.InvalidModule4.r |  4 +---
>   .../dtrace-util/tst.InvalidModule4.sh         | 19 ++-----------------
>   3 files changed, 3 insertions(+), 25 deletions(-)
>
> diff --git a/test/unittest/dtrace-util/man.ListProbesWithModules b/test/unittest/dtrace-util/man.ListProbesWithModules
> index 0b880df0..c6305296 100644
> --- a/test/unittest/dtrace-util/man.ListProbesWithModules
> +++ b/test/unittest/dtrace-util/man.ListProbesWithModules
> @@ -65,9 +65,4 @@
>    * 12)
>    * /usr/sbin/dtrace -lm unix '{printf("FOUND");}'
>    * RESULT: List of only unix probes.
> - *
> - * 13) automated in tst.InvalidModule4.d.ksh
> - * /usr/sbin/dtrace -lm
> - * unix'/probefunc == "preempt"/{printf("FOUND");}'
> - * RESULT: not a valid probe description.
>    */
> diff --git a/test/unittest/dtrace-util/tst.InvalidModule4.r b/test/unittest/dtrace-util/tst.InvalidModule4.r
> index 71563854..42515c55 100644
> --- a/test/unittest/dtrace-util/tst.InvalidModule4.r
> +++ b/test/unittest/dtrace-util/tst.InvalidModule4.r
> @@ -1,5 +1,3 @@
>      ID   PROVIDER            MODULE                          FUNCTION NAME
> -0
> -test/unittest/dtrace-util/tst.InvalidModule4: dtrace failed
>   -- @@stderr --
> -dtrace: failed to match :unix::: No probe matches description
> +dtrace: failed to match :foounix::: No probe matches description
> diff --git a/test/unittest/dtrace-util/tst.InvalidModule4.sh b/test/unittest/dtrace-util/tst.InvalidModule4.sh
> index c46938ce..83fcf3dc 100755
> --- a/test/unittest/dtrace-util/tst.InvalidModule4.sh
> +++ b/test/unittest/dtrace-util/tst.InvalidModule4.sh
> @@ -17,22 +17,7 @@
>   #
>   ##
>   
> -if [ $# != 1 ]; then
> -	echo expected one argument: '<'dtrace-path'>'
> -	exit 2
> -fi
> -
>   dtrace=$1
>   
> -$dtrace $dt_flags -lm unix'/probefunc == "preempt"/{printf("FOUND");}'
> -
> -status=$?
> -
> -echo $status
> -
> -if [ "$status" -ne 0 ]; then
> -	exit 0
> -fi
> -
> -echo $tst: dtrace failed
> -exit $status
> +$dtrace $dt_flags -lm foounix'/probefunc == "preempt"/{printf("FOUND");}'
> +exit 0



More information about the DTrace-devel mailing list