Skip to content

Commit

Permalink
Overhaul the stackdepth value test
Browse files Browse the repository at this point in the history
This test checks the value of stackdepth by using stack() as a
consistency check.  Address the following shortcomings:

1) The test fires in BEGIN, which no longer has a kernel stack.

2) The test incorrectly counts stack frames.

3) The test passes because neither stack() nor stackdepth is implemented!
(Currently, stack() always reports nothing and stackdepth always 0.)

4) An ERROR in the D script would cause the test to hang.

The corrected test will XFAIL until stack() and stackdepth are implemented.

Signed-off-by: Eugene Loh <eugene.loh@oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees@oracle.com>
  • Loading branch information
euloh authored and kvanhees committed Jun 18, 2021
1 parent 7c27af0 commit b1e2f8a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
14 changes: 13 additions & 1 deletion test/unittest/stackdepth/tst.value.d
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
/*
* Oracle Linux DTrace.
* Copyright (c) 2006, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2006, 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 */

#pragma D option destructive
#pragma D option quiet

/*
Expand All @@ -16,10 +18,20 @@
*/

BEGIN
{
system("echo write something > /dev/null");
}

fbt::ksys_write:entry
{
printf("DEPTH %d\n", stackdepth);
printf("TRACE BEGIN\n");
stack();
printf("TRACE END\n");
exit(0);
}

ERROR
{
exit(1);
}
8 changes: 5 additions & 3 deletions test/unittest/stackdepth/tst.value.r.p
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/gawk -f
# Oracle Linux DTrace.
# Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2016, 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.

Expand All @@ -12,12 +12,12 @@
getline;
count = 0;
while ($0 !~ /^TRACE END/) {
if (NF)
count++;
if (getline != 1) {
print "EOF or error while processing stack\n";
exit 0;
}
if (NF)
count++;
}
}

Expand All @@ -26,6 +26,8 @@ END {
printf "Stack depth too large (%d > %d)\n", depth, count;
else if (count > depth)
printf "Stack depth too small (%d < %d)\n", depth, count;
else if (count == 0)
printf "Stack depth is 0\n";
else
printf "Stack depth OK\n";
}

0 comments on commit b1e2f8a

Please sign in to comment.