]> granicus.if.org Git - strace/commitdiff
tests: add ipc_msgbuf.test
authorElvira Khabirova <lineprinter0@gmail.com>
Mon, 3 Aug 2015 09:40:46 +0000 (12:40 +0300)
committerDmitry V. Levin <ldv@altlinux.org>
Fri, 28 Aug 2015 08:46:23 +0000 (08:46 +0000)
* tests/ipc_msgbuf.c: New file.
* tests/ipc_msgbuf.expected: Likewise.
* tests/ipc_msgbuf.test: New test.
* tests/Makefile.am (check_PROGRAMS): Add ipc_msgbuf.
(TESTS): Add ipc_msgbuf.test.
(EXTRA_DIST): Add ipc_msgbuf.expected.
* tests/.gitignore: Add ipc_msgbuf.

tests/.gitignore
tests/Makefile.am
tests/ipc_msgbuf.c [new file with mode: 0644]
tests/ipc_msgbuf.expected [new file with mode: 0644]
tests/ipc_msgbuf.test [new file with mode: 0755]

index ba0bd3a53b2918ce96e86896c743f0e5c6b4b200..819b0a904e3525a6b76968c4abc0a84b618038e5 100644 (file)
@@ -12,6 +12,7 @@ inet-accept-connect-send-recv
 ioctl
 ip_mreq
 ipc_msg
+ipc_msgbuf
 ipc_sem
 ipc_shm
 memfd_create
index 678649871ad20f46806eacc51a0e4f5ea4d02cc9..bfebb39e76ca5fbcc2da09120e3b6157bce2ee07 100644 (file)
@@ -25,6 +25,7 @@ check_PROGRAMS = \
        ioctl \
        ip_mreq \
        ipc_msg \
+       ipc_msgbuf \
        ipc_sem \
        ipc_shm \
        memfd_create \
@@ -101,6 +102,7 @@ TESTS = \
        ioctl.test \
        ip_mreq.test \
        ipc_msg.test \
+       ipc_msgbuf.test \
        ipc_shm.test \
        ipc_sem.test \
        mq.test \
@@ -174,6 +176,7 @@ EXTRA_DIST = init.sh run.sh match.awk \
             ioctl.expected \
             ip_mreq.expected \
             ipc.sh \
+            ipc_msgbuf.expected \
             memfd_create.expected \
             mmsg.expected \
             mq.expected \
diff --git a/tests/ipc_msgbuf.c b/tests/ipc_msgbuf.c
new file mode 100644 (file)
index 0000000..b7de2c8
--- /dev/null
@@ -0,0 +1,33 @@
+#include <sys/ipc.h>
+#include <sys/msg.h>
+#include <sys/stat.h>
+
+#define text_string "STRACE_STRING"
+#define msgsz sizeof(text_string)
+
+int
+main (void)
+{
+       const long mtype = 0xdefaced;
+       struct {
+               long mtype;
+               char mtext[msgsz];
+       } msg = {
+               .mtype = mtype,
+               .mtext = text_string
+       };
+       int msqid = msgget(IPC_PRIVATE, IPC_CREAT | S_IRWXU);
+       if (msqid == -1)
+               return 77;
+       if (msgsnd(msqid, &msg, msgsz, 0) == -1)
+               goto cleanup;
+       if (msgrcv(msqid, &msg, msgsz, mtype, 0) != msgsz)
+               goto cleanup;
+       if (msgctl(msqid, IPC_RMID, 0) == -1)
+               return 77;
+       return 0;
+
+cleanup:
+       msgctl(msqid, IPC_RMID, 0);
+       return 77;
+}
diff --git a/tests/ipc_msgbuf.expected b/tests/ipc_msgbuf.expected
new file mode 100644 (file)
index 0000000..880424b
--- /dev/null
@@ -0,0 +1,4 @@
+msgget\(IPC_PRIVATE, IPC_CREAT\|0700\) += [0-9]*
+msgsnd\([0-9]*, \{233811181, "STRACE_STRING\\0"\}, 14, 0\) += 0
+msgrcv\([0-9]*, \{233811181, "STRACE_STRING\\0"\}, 14, 233811181, 0\) += 14
+msgctl\([0-9]*, (IPC_64\|)?IPC_RMID, NULL\) += 0
diff --git a/tests/ipc_msgbuf.test b/tests/ipc_msgbuf.test
new file mode 100755 (executable)
index 0000000..d0b65d1
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+# Check msgget, msgsnd, msgrcv, msgctl syscalls decoding.
+
+. "${srcdir=.}/init.sh"
+
+run_prog
+run_strace -v -e msgget,msgsnd,msgrcv,msgctl $args
+match_grep
+
+exit 0