Skip to content

Commit

Permalink
test: Check rindex() for addresses that are not DTrace pointers
Browse files Browse the repository at this point in the history
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 Feb 20, 2023
1 parent c6efccb commit 1718548
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test/unittest/funcs/tst.rindex_nonDPTR.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Oracle Linux DTrace.
* Copyright (c) 2022, 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.
*/

#pragma D option quiet
#pragma D option destructive

BEGIN
{
/* "abcdef" */
system("printf '\x61\x62\x63\x64\x65\x66' > /dev/null 2>&1");
}

syscall::write:entry
/ppid == $pid/
{
printf("rindex is %d, should be 0\n", rindex((void *)arg1, (void *)arg1));
exit(0);
}

ERROR { exit(1); }
2 changes: 2 additions & 0 deletions test/unittest/funcs/tst.rindex_nonDPTR.r
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
rindex is 0, should be 0

0 comments on commit 1718548

Please sign in to comment.