tests: add umount.test and umount2.test
* tests/umount.c: New file.
* tests/umount2.c: Likewise.
* tests/umount.test: New test.
* tests/umount2.test: Likewise.
* tests/Makefile.am (check_PROGRAMS): Add umount and umount2.
(TESTS): Add umount.test and umount2.test.
* tests/.gitignore: Add umount and umount2.
diff --git a/tests/.gitignore b/tests/.gitignore
index ca3eb2b..3cdfc65 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -83,6 +83,8 @@
uid16
uid32
uio
+umount
+umount2
umovestr
umovestr2
unix-pair-send-recv
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 56e64ab..71c8130 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -96,6 +96,8 @@
uid16 \
uid32 \
uio \
+ umount \
+ umount2 \
umovestr \
umovestr2 \
unix-pair-send-recv \
@@ -210,6 +212,8 @@
times-fail.test \
truncate.test \
truncate64.test \
+ umount.test \
+ umount2.test \
umovestr.test \
umovestr2.test \
unix-yy.test \
diff --git a/tests/umount.c b/tests/umount.c
new file mode 100644
index 0000000..380417d
--- /dev/null
+++ b/tests/umount.c
@@ -0,0 +1,44 @@
+#include <errno.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <sys/mount.h>
+#include <sys/syscall.h>
+
+#ifdef __NR_oldumount
+# define TEST_SYSCALL_STR "oldumount"
+#else
+# if defined __NR_umount && defined __NR_umount2
+# define __NR_oldumount __NR_umount
+# define TEST_SYSCALL_STR "umount"
+# endif
+#endif
+
+int
+main(void)
+{
+#ifdef __NR_oldumount
+ static const char sample[] = "umount.sample";
+ if (mkdir(sample, 0700)) {
+ perror(sample);
+ return 77;
+ }
+ (void) syscall(__NR_oldumount, sample);
+ printf("%s(\"%s\") = -1 ", TEST_SYSCALL_STR, sample);
+ switch (errno) {
+ case ENOSYS:
+ printf("ENOSYS (%m)\n");
+ break;
+ case EPERM:
+ printf("EPERM (%m)\n");
+ break;
+ default:
+ printf("EINVAL (%m)\n");
+ }
+ (void) rmdir(sample);
+ puts("+++ exited with 0 +++");
+ return 0;
+#else
+ return 77;
+#endif
+}
diff --git a/tests/umount.test b/tests/umount.test
new file mode 100755
index 0000000..bcabd09
--- /dev/null
+++ b/tests/umount.test
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+# Check umount syscall decoding.
+
+. "${srcdir=.}/init.sh"
+
+run_prog > /dev/null
+case "$STRACE_ARCH" in
+ alpha) syscall=oldumount ;;
+ *) syscall=umount ;;
+esac
+OUT="$LOG.out"
+run_strace -a24 -s6 -e$syscall $args > "$OUT"
+match_diff "$LOG" "$OUT"
+rm -f "$OUT"
+
+exit 0
diff --git a/tests/umount2.c b/tests/umount2.c
new file mode 100644
index 0000000..141e383
--- /dev/null
+++ b/tests/umount2.c
@@ -0,0 +1,28 @@
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <sys/mount.h>
+#include <sys/syscall.h>
+
+#ifdef __NR_umount2
+# define TEST_SYSCALL_STR "umount2"
+#else
+# define __NR_umount2 __NR_umount
+# define TEST_SYSCALL_STR "umount"
+#endif
+
+int
+main(void)
+{
+ static const char sample[] = "umount2.sample";
+ if (mkdir(sample, 0700)) {
+ perror(sample);
+ return 77;
+ }
+ (void) syscall(__NR_umount2, sample, 31);
+ printf("%s(\"%s\", MNT_FORCE|MNT_DETACH|MNT_EXPIRE|UMOUNT_NOFOLLOW|0x10)"
+ " = -1 EINVAL (%m)\n", TEST_SYSCALL_STR, sample);
+ (void) rmdir(sample);
+ puts("+++ exited with 0 +++");
+ return 0;
+}
diff --git a/tests/umount2.test b/tests/umount2.test
new file mode 100755
index 0000000..ad4b25f
--- /dev/null
+++ b/tests/umount2.test
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+# Check umount2 syscall decoding.
+
+. "${srcdir=.}/init.sh"
+
+run_prog > /dev/null
+case "$STRACE_ARCH" in
+ alpha|ia64) syscall=umount ;;
+ *) syscall=umount2 ;;
+esac
+OUT="$LOG.out"
+run_strace -s7 -e$syscall $args > "$OUT"
+match_diff "$LOG" "$OUT"
+rm -f "$OUT"
+
+exit 0