[PATCH v2 3/3] tests: add acct.test

Fei Jie feij.fnst at cn.fujitsu.com
Mon Mar 7 03:32:03 UTC 2016


* tests/acct.c: New file.
* tests/acct.test: New test.
* tests/.gitignore: Add acct.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(TESTS): Add acct.test.
---
 tests/.gitignore  |  1 +
 tests/Makefile.am |  2 ++
 tests/acct.c      | 37 +++++++++++++++++++++++++++++++++++++
 tests/acct.test   | 11 +++++++++++
 4 files changed, 51 insertions(+)
 create mode 100644 tests/acct.c
 create mode 100755 tests/acct.test

diff --git a/tests/.gitignore b/tests/.gitignore
index 0ad62fb..16d23f7 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -6,6 +6,7 @@
 *.tmp.*
 *.trs
 _newselect
+acct
 adjtimex
 aio
 alarm
diff --git a/tests/Makefile.am b/tests/Makefile.am
index deb3ecb..bda5482 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -56,6 +56,7 @@ LDADD = libtests.a
 
 check_PROGRAMS = \
 	_newselect \
+	acct \
 	adjtimex \
 	aio \
 	alarm \
@@ -224,6 +225,7 @@ TESTS = \
 	ksysent.test \
 	\
 	_newselect.test \
+	acct.test \
 	adjtimex.test \
 	aio.test \
 	alarm.test \
diff --git a/tests/acct.c b/tests/acct.c
new file mode 100644
index 0000000..70c6acb
--- /dev/null
+++ b/tests/acct.c
@@ -0,0 +1,37 @@
+#include "tests.h"
+#include <sys/syscall.h>
+
+#ifdef __NR_acct
+
+# define TMP_FILE "acct_tmpfile"
+
+# include <errno.h>
+# include <stdio.h>
+# include <unistd.h>
+int
+main(void)
+{
+	int rc = syscall(__NR_acct, TMP_FILE);
+	const char *errno_text;
+	switch(errno) {
+		case EPERM:
+			errno_text = "EPERM";
+			break;
+		case ENOSYS:
+			errno_text = "ENOSYS";
+			break;
+		default:
+			errno_text = "ENOENT";
+	}
+	printf("acct(\"%s\") = %d %s (%m)\n",
+	       TMP_FILE, rc, errno_text);
+
+	puts("+++ exited with 0 +++");
+	return 0;
+}
+
+#else
+
+SKIP_MAIN_UNDEFINED("__NR__acct")
+
+#endif
diff --git a/tests/acct.test b/tests/acct.test
new file mode 100755
index 0000000..d258389
--- /dev/null
+++ b/tests/acct.test
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+# Check acct syscall decoding.
+
+. "${srcdir=.}/init.sh"
+
+run_prog > /dev/null
+OUT="$LOG.out"
+run_strace -eacct -a21 $args > "$OUT"
+match_diff "$LOG" "$OUT"
+rm -f "$OUT"
-- 
1.8.3.1







More information about the Strace-devel mailing list