Re: [PATCH 3/5] test: Fix some ustackdepth tests

Kris Van Hees
2025-10-09T16:30:05Z

On Fri, Oct 03, 2025 at 12:07:00AM -0400, Kris Van Hees wrote:
> On Wed, Oct 01, 2025 at 02:24:16AM -0400, eugene.loh@oracle.com wrote:
> >
> > Issue 3.
> >
> > That ustackdepth_big test only checked that the stackdepth was
> > consistent with the reported stack. While this check is good, it missed
> > the point of the test, which is that the system limit could be
> > increased.

This test seems to not work right if the system limit is already 200, which
it can be. Perhaps it should first lower it to e.g. 20, then raise it to 200,
and no matter what, restore the original value?

> > Signed-off-by: Eugene Loh <eugene.loh@oracle.com>
>
> Reviewed-by: Kris Van Hees <kris.van.hees@oracle.com>
>
> > ---
> > .../variables/bvar/tst.ustackdepth2.r | 2 +-
> > .../variables/bvar/tst.ustackdepth2.r.p | 2 +-
> > .../variables/bvar/tst.ustackdepth_big.r | 1 -
> > .../variables/bvar/tst.ustackdepth_big.r.p | 1 -
> > .../variables/bvar/tst.ustackdepth_big.sh | 34 +++++++++++++++++--
> > 5 files changed, 34 insertions(+), 6 deletions(-)
> > mode change 120000 => 100644 test/unittest/variables/bvar/tst.ustackdepth2.r
> > delete mode 120000 test/unittest/variables/bvar/tst.ustackdepth_big.r
> > delete mode 120000 test/unittest/variables/bvar/tst.ustackdepth_big.r.p
> >
> > diff --git a/test/unittest/variables/bvar/tst.ustackdepth2.r b/test/unittest/variables/bvar/tst.ustackdepth2.r
> > deleted file mode 120000
> > index 5cc8498f8..000000000
> > --- a/test/unittest/variables/bvar/tst.ustackdepth2.r
> > +++ /dev/null
> > @@ -1 +0,0 @@
> > -tst.stackdepth2.r
> > \ No newline at end of file
> > diff --git a/test/unittest/variables/bvar/tst.ustackdepth2.r b/test/unittest/variables/bvar/tst.ustackdepth2.r
> > new file mode 100644
> > index 000000000..3bd29b8ed
> > --- /dev/null
> > +++ b/test/unittest/variables/bvar/tst.ustackdepth2.r
> > @@ -0,0 +1 @@
> > +Stack depth OK
> > diff --git a/test/unittest/variables/bvar/tst.ustackdepth2.r.p b/test/unittest/variables/bvar/tst.ustackdepth2.r.p
> > index 8320b603c..e50f12822 120000
> > --- a/test/unittest/variables/bvar/tst.ustackdepth2.r.p
> > +++ b/test/unittest/variables/bvar/tst.ustackdepth2.r.p
> > @@ -1 +1 @@
> > -tst.stackdepth2.r.p
> > \ No newline at end of file
> > +check_stackdepth_to_stack.awk
> > \ No newline at end of file
> > diff --git a/test/unittest/variables/bvar/tst.ustackdepth_big.r b/test/unittest/variables/bvar/tst.ustackdepth_big.r
> > deleted file mode 120000
> > index b6a2d6bcd..000000000
> > --- a/test/unittest/variables/bvar/tst.ustackdepth_big.r
> > +++ /dev/null
> > @@ -1 +0,0 @@
> > -tst.ustackdepth2.r
> > \ No newline at end of file
> > diff --git a/test/unittest/variables/bvar/tst.ustackdepth_big.r.p b/test/unittest/variables/bvar/tst.ustackdepth_big.r.p
> > deleted file mode 120000
> > index 0e8338907..000000000
> > --- a/test/unittest/variables/bvar/tst.ustackdepth_big.r.p
> > +++ /dev/null
> > @@ -1 +0,0 @@
> > -tst.ustackdepth2.r.p
> > \ No newline at end of file
> > diff --git a/test/unittest/variables/bvar/tst.ustackdepth_big.sh b/test/unittest/variables/bvar/tst.ustackdepth_big.sh
> > index 777940ec8..e84850c02 100755
> > --- a/test/unittest/variables/bvar/tst.ustackdepth_big.sh
> > +++ b/test/unittest/variables/bvar/tst.ustackdepth_big.sh
> > @@ -14,11 +14,19 @@
> >
> > dtrace=$1
> >
> > +POSTPROC=$PWD/test/unittest/variables/bvar/check_stackdepth_to_stack.awk
> > +TRIGGER=$PWD/test/triggers/ustack-tst-bigstack-spin
> > +
> > +DIRNAME=$tmpdir/ustackdepth_big.$$.$RANDOM
> > +mkdir -p $DIRNAME
> > +cd $DIRNAME
> > +
> > orig_maxstack=`sysctl -n kernel.perf_event_max_stack`
> > echo kernel.perf_event_max_stack was $orig_maxstack
> > +trap "sysctl kernel.perf_event_max_stack=$orig_maxstack" QUIT EXIT
> > sysctl kernel.perf_event_max_stack=200
> >
> > -$dtrace $dt_flags -c test/triggers/ustack-tst-bigstack-spin -qn '
> > +$dtrace $dt_flags -c $TRIGGER -qn '
> > profile-1
> > /pid == $target/
> > {
> > @@ -32,7 +40,7 @@ ERROR
> > {
> > exit(1);
> > }
> > -'
> > +' > D.out
> > if [ $? -ne 0 ]; then
> > echo DTrace failure
> > exit 1
> > @@ -41,4 +49,26 @@ fi
> > sleep 2
> > sysctl kernel.perf_event_max_stack=$orig_maxstack
> >
> > +$POSTPROC D.out > awk.out
> > +if [ $? -ne 0 ]; then
> > + echo post processing failure
> > + exit 1
> > +fi
> > +
> > +if echo "Stack depth OK" | diff -q - awk.out; then
> > + mydepth=`gawk '/DEPTH/ { print $2 }' D.out`
> > + if [ $mydepth -gt $orig_maxstack ]; then
> > + echo success depth $mydepth exceeded original limit $orig_maxstack
> > + exit 0
> > + else
> > + echo ERROR: $mydepth does not exceed original limit $orig_maxstack
> > + cat D.out
> > + exit 1
> > + fi
> > +else
> > + echo "ERROR: stack depth does not match stack"
> > + cat D.out
> > + exit 1
> > +fi
> > +
> > exit 0
> > --
> > 2.47.3
> >