From: Elvira Khabirova Date: Mon, 3 Aug 2015 09:40:46 +0000 (+0300) Subject: tests: add ipc_msgbuf.test X-Git-Tag: v4.11~231 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b7699b55ddef3b7926b67cfb4429a277d47ca7f4;p=strace tests: add ipc_msgbuf.test * 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. --- diff --git a/tests/.gitignore b/tests/.gitignore index ba0bd3a5..819b0a90 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -12,6 +12,7 @@ inet-accept-connect-send-recv ioctl ip_mreq ipc_msg +ipc_msgbuf ipc_sem ipc_shm memfd_create diff --git a/tests/Makefile.am b/tests/Makefile.am index 67864987..bfebb39e 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -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 index 00000000..b7de2c8c --- /dev/null +++ b/tests/ipc_msgbuf.c @@ -0,0 +1,33 @@ +#include +#include +#include + +#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 index 00000000..880424bf --- /dev/null +++ b/tests/ipc_msgbuf.expected @@ -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 index 00000000..d0b65d1a --- /dev/null +++ b/tests/ipc_msgbuf.test @@ -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