]> sourceware.org Git - systemtap.git/commitdiff
Add openat() and unlinkat() syscall testing.
authorDavid Smith <dsmith@redhat.com>
Wed, 15 Jan 2014 16:52:51 +0000 (10:52 -0600)
committerDavid Smith <dsmith@redhat.com>
Wed, 15 Jan 2014 16:52:51 +0000 (10:52 -0600)
* testsuite/systemtap.syscall/openclose.c: Added openat() testing.
* testsuite/systemtap.syscall/unlink.c: Add unlinkat() testing.

testsuite/systemtap.syscall/openclose.c
testsuite/systemtap.syscall/unlink.c

index ed79210be44481612a6c15c445be2b17d7b58c20..e0b2c11a1016145eb79279b914c42029965d568f 100644 (file)
@@ -1,4 +1,4 @@
-/* COVERAGE: open close creat */
+/* COVERAGE: open openat close creat */
 #define _GNU_SOURCE
 #include <stdio.h>
 #include <sys/types.h>
@@ -7,6 +7,16 @@
 #include <stdlib.h>
 #include <unistd.h>
 
+// To test for glibc support for openat():
+//
+// Since glibc 2.10:
+//     _XOPEN_SOURCE >= 700 || _POSIX_C_SOURCE >= 200809L
+// Before glibc 2.10:
+//     _ATFILE_SOURCE
+
+#define GLIBC_SUPPORT \
+  (_XOPEN_SOURCE >= 700 || _POSIX_C_SOURCE >= 200809L \
+   || defined(_ATFILE_SOURCE))
 
 int main()
 {
@@ -20,39 +30,93 @@ int main()
   close(fd1);
   //staptest// close (NNNN) = 0
 
+#if GLIBC_SUPPORT
+  fd1 = openat(AT_FDCWD, "foobar2", O_WRONLY|O_CREAT, S_IRWXU);
+  //staptest// openat (AT_FDCWD, "foobar2", O_WRONLY|O_CREAT[[[[.O_LARGEFILE]]]]?, 0700) = NNNN
+  close(fd1);
+  //staptest// close (NNNN) = 0
+#endif
+
   fd1 = open("foobar2",O_RDONLY);
   //staptest// open ("foobar2", O_RDONLY[[[[.O_LARGEFILE]]]]?) = NNNN
   close(fd1);
   //staptest// close (NNNN) = 0
 
+#if GLIBC_SUPPORT
+  fd1 = openat(AT_FDCWD, "foobar2", O_RDONLY);
+  //staptest// openat (AT_FDCWD, "foobar2", O_RDONLY[[[[.O_LARGEFILE]]]]?) = NNNN
+  close(fd1);
+  //staptest// close (NNNN) = 0
+#endif
+
   fd1 = open("foobar2",O_RDWR);
   //staptest// open ("foobar2", O_RDWR[[[[.O_LARGEFILE]]]]?) = NNNN
   close(fd1);
   //staptest// close (NNNN) = 0
 
+#if GLIBC_SUPPORT
+  fd1 = openat(AT_FDCWD, "foobar2", O_RDWR);
+  //staptest// openat (AT_FDCWD, "foobar2", O_RDWR[[[[.O_LARGEFILE]]]]?) = NNNN
+  close(fd1);
+  //staptest// close (NNNN) = 0
+#endif
+
   fd1 = open("foobar2",O_APPEND|O_WRONLY);
   //staptest// open ("foobar2", O_WRONLY|O_APPEND[[[[.O_LARGEFILE]]]]?) = NNNN
   close(fd1);
   //staptest// close (NNNN) = 0
 
+#if GLIBC_SUPPORT
+  fd1 = openat(AT_FDCWD, "foobar2", O_APPEND|O_WRONLY);
+  //staptest// openat (AT_FDCWD, "foobar2", O_WRONLY|O_APPEND[[[[.O_LARGEFILE]]]]?) = NNNN
+  close(fd1);
+  //staptest// close (NNNN) = 0
+#endif
+
   fd1 = open("foobar2",O_DIRECT|O_RDWR);
   //staptest// open ("foobar2", O_RDWR|O_DIRECT[[[[.O_LARGEFILE]]]]?) = NNNN
   close(fd1);
   //staptest// close (NNNN) = 0
 
+#if GLIBC_SUPPORT
+  fd1 = openat(AT_FDCWD, "foobar2", O_DIRECT|O_RDWR);
+  //staptest// openat (AT_FDCWD, "foobar2", O_RDWR|O_DIRECT[[[[.O_LARGEFILE]]]]?) = NNNN
+  close(fd1);
+  //staptest// close (NNNN) = 0
+#endif
+
   fd1 = open("foobar2",O_NOATIME|O_SYNC|O_RDWR);
   //staptest// open ("foobar2", O_RDWR[[[[.O_LARGEFILE]]]]?|O_NOATIME|O_SYNC) = NNNN
   close(fd1);
   //staptest// close (NNNN) = 0
 
+#if GLIBC_SUPPORT
+  fd1 = openat(AT_FDCWD, "foobar2", O_NOATIME|O_SYNC|O_RDWR);
+  //staptest// openat (AT_FDCWD, "foobar2", O_RDWR[[[[.O_LARGEFILE]]]]?|O_NOATIME|O_SYNC) = NNNN
+  close(fd1);
+  //staptest// close (NNNN) = 0
+#endif
+
   /* Now test some bad opens */
   fd1 = open("/",O_WRONLY);
   //staptest// open ("/", O_WRONLY[[[[.O_LARGEFILE]]]]?) = -NNNN (EISDIR)
   close (fd1);
   //staptest// close (NNNN) = -NNNN (EBADF)
 
+#if GLIBC_SUPPORT
+  fd1 = openat(AT_FDCWD, "/", O_WRONLY);
+  //staptest// openat (AT_FDCWD, "/", O_WRONLY[[[[.O_LARGEFILE]]]]?) = -NNNN (EISDIR)
+  close (fd1);
+  //staptest// close (NNNN) = -NNNN (EBADF)
+#endif
+
   fd1 = open("foobar2",O_WRONLY|O_CREAT|O_EXCL, S_IRWXU);
   //staptest// open ("foobar2", O_WRONLY|O_CREAT|O_EXCL[[[[.O_LARGEFILE]]]]?, 0700) = -NNNN (EEXIST)
 
+#if GLIBC_SUPPORT
+  fd1 = openat(AT_FDCWD, "foobar2",O_WRONLY|O_CREAT|O_EXCL, S_IRWXU);
+  //staptest// openat (AT_FDCWD, "foobar2", O_WRONLY|O_CREAT|O_EXCL[[[[.O_LARGEFILE]]]]?, 0700) = -NNNN (EEXIST)
+#endif
+
   return 0;
 }
index 19d739a2681f092ed0dcb3d864b0e096d9496ca9..71b21e5edc0b83fb74444954c63c8eb479f6e235 100644 (file)
@@ -1,10 +1,21 @@
-/* COVERAGE: unlink */
+/* COVERAGE: unlink unlinkat */
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <unistd.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
 
+// To test for glibc support for unlinkat(), symlinkat(), readlinkat():
+//
+// Since glibc 2.10:
+//     _XOPEN_SOURCE >= 700 || _POSIX_C_SOURCE >= 200809L
+// Before glibc 2.10:
+//     _ATFILE_SOURCE
+
+#define GLIBC_SUPPORT \
+  (_XOPEN_SOURCE >= 700 || _POSIX_C_SOURCE >= 200809L \
+   || defined(_ATFILE_SOURCE))
 
 int main()
 {
@@ -13,23 +24,58 @@ int main()
   fd1 = creat("foobar1",S_IREAD|S_IWRITE);
   close (fd1);
   
+#if GLIBC_SUPPORT
+  fd1 = creat("foobar2", S_IREAD|S_IWRITE);
+  close (fd1);
+#endif
+
   unlink("foobar1");
   //staptest// unlink ("foobar1") = 0
 
+#if GLIBC_SUPPORT
+  unlinkat(AT_FDCWD, "foobar2", 0);
+  //staptest// unlinkat (AT_FDCWD, "foobar2", 0x0) = 0
+#endif
+
   unlink("foobar1");
   //staptest// unlink ("foobar1") = -NNNN (ENOENT)
 
+#if GLIBC_SUPPORT
+  unlinkat(AT_FDCWD, "foobar1", 0);
+  //staptest// unlinkat (AT_FDCWD, "foobar1", 0x0) = -NNNN (ENOENT)
+#endif
+
   unlink("foobar2");
   //staptest// unlink ("foobar2") = -NNNN (ENOENT)
 
+#if GLIBC_SUPPORT
+  unlinkat(AT_FDCWD, "foobar2", 0);
+  //staptest// unlinkat (AT_FDCWD, "foobar2", 0x0) = -NNNN (ENOENT)
+#endif
+
   unlink(0);
   //staptest// unlink ( *(null)) = -NNNN (EFAULT)
 
+#if GLIBC_SUPPORT
+  unlinkat(AT_FDCWD, 0, 0);
+  //staptest// unlinkat (AT_FDCWD, *(null), 0x0) = -NNNN (EFAULT)
+#endif
+
   unlink("..");
   //staptest// unlink ("..") = -NNNN (EISDIR)
 
+#if GLIBC_SUPPORT
+  unlinkat(AT_FDCWD, "..", 0);
+  //staptest// unlinkat (AT_FDCWD, "..", 0x0) = -NNNN (EISDIR)
+#endif
+
   unlink("");
   //staptest// unlink ("") = -NNNN (ENOENT)
 
+#if GLIBC_SUPPORT
+  unlinkat(AT_FDCWD, "", 0);
+  //staptest// unlinkat (AT_FDCWD, "", 0x0) = -NNNN (ENOENT)
+#endif
+
   return 0;
 }
This page took 0.031353 seconds and 5 git commands to generate.