[PATCH 2/3] tests: add shmxt.test

Fei Jie feij.fnst at cn.fujitsu.com
Tue Apr 12 06:57:46 UTC 2016


* tests/shmxt.c: New file.
* tests/shmxt.test: New test.
* tests/.gitignore: Add shmxt.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add shmxt.test.
---
 tests/.gitignore  |  1 +
 tests/Makefile.am |  2 ++
 tests/shmxt.c     | 27 +++++++++++++++++++++++++++
 tests/shmxt.test  |  6 ++++++
 4 files changed, 36 insertions(+)
 create mode 100644 tests/shmxt.c
 create mode 100755 tests/shmxt.test

diff --git a/tests/.gitignore b/tests/.gitignore
index 35db0da..aee70a4 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -137,6 +137,7 @@ sendfile
 sendfile64
 set_ptracer_any
 sethostname
+shmxt
 sigaction
 sigaltstack
 signalfd
diff --git a/tests/Makefile.am b/tests/Makefile.am
index c3138eb..9446ce8 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -186,6 +186,7 @@ check_PROGRAMS = \
 	sendfile64 \
 	set_ptracer_any \
 	sethostname \
+	shmxt \
 	sigaction \
 	sigaltstack \
 	signalfd \
@@ -386,6 +387,7 @@ DECODER_TESTS = \
 	sendfile.test \
 	sendfile64.test \
 	sethostname.test \
+	shmxt.test \
 	sigaction.test \
 	sigaltstack.test \
 	signalfd.test \
diff --git a/tests/shmxt.c b/tests/shmxt.c
new file mode 100644
index 0000000..b2b3166
--- /dev/null
+++ b/tests/shmxt.c
@@ -0,0 +1,27 @@
+#include "tests.h"
+#include <errno.h>
+#include <stdio.h>
+#include <sys/shm.h>
+
+int
+main(void)
+{
+	int id = shmget(IPC_PRIVATE, 1, 0600);
+	if (id < 0)
+		perror_msg_and_fail("shmget");
+
+	void *shmaddr = shmat(id, NULL, 0);
+	if (shmaddr == (void *)(-1))
+		perror_msg_and_fail("shmat");
+	printf("shmat(%d, NULL, 0) = %p\n", id, shmaddr);
+
+	if (shmdt(shmaddr) < 0)
+		perror_msg_and_fail("shmdt");
+	printf("shmdt(%p) = 0\n", shmaddr);
+
+	if (shmctl(id, IPC_RMID, NULL) < 0)
+		perror_msg_and_fail("shmctl");
+
+	puts("+++ exited with 0 +++");
+	return 0;
+}
diff --git a/tests/shmxt.test b/tests/shmxt.test
new file mode 100755
index 0000000..59df835
--- /dev/null
+++ b/tests/shmxt.test
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+# Check shmat and shmdt syscalls decoding.
+
+. "${srcdir=.}/init.sh"
+run_strace_match_diff -e trace=shmat,shmdt -a11
-- 
1.8.3.1







More information about the Strace-devel mailing list