-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for copyoutstr() subroutine
Move tests to their own copyoutstr/ subdirectory to mimic other copy* tests. Signed-off-by: Eugene Loh <eugene.loh@oracle.com> Reviewed-by: Kris Van Hees <kris.van.hees@oracle.com>
- Loading branch information
Showing
12 changed files
with
159 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
2 changes: 2 additions & 0 deletions
2
test/unittest/funcs/copyoutstr/err.D_PROTO_LEN.copyoutstrbadarg.r
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
-- @@stderr -- | ||
dtrace: failed to compile script test/unittest/funcs/copyoutstr/err.D_PROTO_LEN.copyoutstrbadarg.d: [D_PROTO_LEN] line 19: copyoutstr( ) prototype mismatch: 2 args passed, 3 expected |
File renamed without changes.
2 changes: 2 additions & 0 deletions
2
test/unittest/funcs/copyoutstr/err.D_PROTO_LEN.copyoutstrtoofew.r
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
-- @@stderr -- | ||
dtrace: failed to compile script test/unittest/funcs/copyoutstr/err.D_PROTO_LEN.copyoutstrtoofew.d: [D_PROTO_LEN] line 19: copyoutstr( ) prototype mismatch: 1 arg passed, 3 expected |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
size is longer than the string; expect full string with terminating byte | ||
HELLO WORLD; YOU HAVE A LONG MESSAGE TO DELIVER|--------------- | ||
|
||
size is shorter than the string; expect 32 chars without terminating byte | ||
HELLO WORLD; YOU HAVE A LONG MES------------------------------- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#!/bin/bash | ||
# | ||
# Oracle Linux DTrace. | ||
# Copyright (c) 2023, 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. | ||
|
||
dtrace=$1 | ||
DIRNAME="$tmpdir/copyoutstr.$$.$RANDOM" | ||
mkdir -p $DIRNAME | ||
cd $DIRNAME | ||
|
||
# Construct a C program that: | ||
# - initializes a user buffer | ||
# - passes that buffer to a syscall (where DTrace will overwrite the buffer) | ||
# - checks the buffer | ||
cat << EOF > main.c | ||
#include <fcntl.h> | ||
#include <unistd.h> | ||
#include <stdio.h> | ||
#include <string.h> | ||
int main(int c, char **v) { | ||
int i, fd = open("/dev/null", O_WRONLY); | ||
char s[64]; | ||
/* initialize buffer */ | ||
memset(s, '-', sizeof(s)); | ||
s[sizeof(s) - 1] = '\0'; | ||
/* write buffer to /dev/null (the D script will overwrite s) */ | ||
write(fd, s, strlen(s)); | ||
close(fd); | ||
/* turn NUL chars (except last one) into printable '|' */ | ||
for (i = 0; i < sizeof(s) - 1; i++) | ||
if (s[i] == '\0') | ||
s[i] = '|'; | ||
/* print buffer contents */ | ||
printf("%s\n", s); | ||
return 0; | ||
} | ||
EOF | ||
|
||
gcc main.c | ||
if [ $? -ne 0 ]; then | ||
echo "compilation error" | ||
exit 1 | ||
fi | ||
|
||
# $1 is copyoutstr() size | ||
# $2 is DTrace options | ||
# $3 is description of test | ||
function mytest() { | ||
echo $3 | ||
$dtrace $dt_flags $2 -qwn ' | ||
syscall::write:entry | ||
/pid == $target/ | ||
{ | ||
s = "HELLO WORLD; YOU HAVE A LONG MESSAGE TO DELIVER"; | ||
copyoutstr(s, arg1, '$1'); | ||
exit(0); | ||
}' -c ./a.out | ||
if [ $? -ne 0 ]; then | ||
echo "DTrace error" | ||
exit 1 | ||
fi | ||
} | ||
|
||
mytest 64 " " "size is longer than the string; expect full string with terminating byte" | ||
mytest 32 " " "size is shorter than the string; expect 32 chars without terminating byte" | ||
|
||
exit 0 |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
4 changes: 2 additions & 2 deletions
4
test/unittest/speculation/err.D_ACT_SPEC.SpeculateWithCopyOutStr.d
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters