summaryrefslogtreecommitdiffstats
path: root/testsuite/systemtap.base/utrace_syscall_args.c
diff options
context:
space:
mode:
authorDavid Smith <dsmith@redhat.com>2009-04-17 09:37:00 -0500
committerDavid Smith <dsmith@redhat.com>2009-04-17 09:37:00 -0500
commitbe8770ce0c66eea1113c3c91682b4fdf6ae1ec77 (patch)
treeb055d3f37781e9e86d681398ce9a643c87d609c8 /testsuite/systemtap.base/utrace_syscall_args.c
parent889c4638f741163395438aca60226ff8a5e2009e (diff)
downloadsystemtap-steved-be8770ce0c66eea1113c3c91682b4fdf6ae1ec77.tar.gz
systemtap-steved-be8770ce0c66eea1113c3c91682b4fdf6ae1ec77.tar.xz
systemtap-steved-be8770ce0c66eea1113c3c91682b4fdf6ae1ec77.zip
Added new utrace syscall argument test.
2009-04-17 David Smith <dsmith@redhat.com> * systemtap.base/utrace_syscall_args.c: New test file. * systemtap.base/utrace_syscall_args.exp: New test file. * systemtap.base/utrace_syscall_args.stp: New test file.
Diffstat (limited to 'testsuite/systemtap.base/utrace_syscall_args.c')
-rw-r--r--testsuite/systemtap.base/utrace_syscall_args.c67
1 files changed, 67 insertions, 0 deletions
diff --git a/testsuite/systemtap.base/utrace_syscall_args.c b/testsuite/systemtap.base/utrace_syscall_args.c
new file mode 100644
index 00000000..2d3da838
--- /dev/null
+++ b/testsuite/systemtap.base/utrace_syscall_args.c
@@ -0,0 +1,67 @@
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/mman.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/syscall.h> /* For SYS_xxx definitions */
+
+int main()
+{
+ int fd, ret;
+ struct stat fs;
+ void *r;
+ int rc;
+
+ /* create a file with something in it */
+ fd = open("foobar", O_WRONLY|O_CREAT|O_TRUNC, 0600);
+ lseek(fd, 1024, SEEK_SET);
+ write(fd, "abcdef", 6);
+ close(fd);
+
+ fd = open("foobar", O_RDONLY);
+
+ /* stat for file size */
+ ret = fstat(fd, &fs);
+
+ /* mmap file file, then unmap it. */
+ r = mmap(NULL, fs.st_size, PROT_READ, MAP_SHARED, fd, 0);
+ if (r != MAP_FAILED)
+ munmap(r, fs.st_size);
+ close(fd);
+
+ /* OK, try some system calls to see if we get the arguments
+ * correctly. */
+#if (__LONG_MAX__ > __INT_MAX__)
+ rc = syscall (__NR_dup, (unsigned long)-12345,
+ (unsigned long)0xffffffffffffffff,
+ (unsigned long)0xa5a5a5a5a5a5a5a5,
+ (unsigned long)0xf0f0f0f0f0f0f0f0,
+ (unsigned long)0x5a5a5a5a5a5a5a5a,
+ (unsigned long)0xe38e38e38e38e38e);
+#else
+ rc = syscall (__NR_dup, (unsigned long)-12345,
+ (unsigned long)0xffffffff,
+ (unsigned long)0xa5a5a5a5,
+ (unsigned long)0xf0f0f0f0,
+ (unsigned long)0x5a5a5a5a,
+ (unsigned long)0xe38e38e3);
+#endif
+#if (__LONG_MAX__ > __INT_MAX__)
+ rc = syscall ((unsigned long)-1,
+ (unsigned long)0x1c71c71c71c71c71,
+ (unsigned long)0x0f0f0f0f0f0f0f0f,
+ (unsigned long)0xdb6db6db6db6db6d,
+ (unsigned long)0x2492492492492492,
+ (unsigned long)0xad6b5ad6b5ad6b5a,
+ (unsigned long)0xdef7ddef7ddef7dd);
+#else
+ rc = syscall ((unsigned long)-1,
+ (unsigned long)0x1c71c71c,
+ (unsigned long)0x0f0f0f0f,
+ (unsigned long)0xdb6db6db,
+ (unsigned long)0x24924924,
+ (unsigned long)0xad6b5ad6,
+ (unsigned long)0xdef7ddef);
+#endif
+ return 0;
+}