strace/tests/ipc_msg.c
Dmitry V. Levin 12e2442784 tests: add tests for ipc syscalls decoding
* tests/ipc_msg.c: New file.
* tests/ipc_sem.c: Likewise.
* tests/ipc_shm.c: Likewise.
* tests/ipc_msg.test: New test.
* tests/ipc_sem.test: Likewise.
* tests/ipc_shm.test: Likewise.
* tests/Makefile.am (check_PROGRAMS): Add ipc_msg, ipc_sem, and ipc_shm.
(TESTS): Add ipc_msg.test, ipc_sem.test, and ipc_shm.test.
* tests/.gitignore: Add ipc_msg, ipc_sem, and ipc_shm.
2015-01-12 16:24:20 +00:00

32 lines
575 B
C

#include <stdio.h>
#include <sys/msg.h>
int
main(void)
{
int id = msgget(IPC_PRIVATE, 0600);
if (id < 0)
return 77;
printf("msgget\\(IPC_PRIVATE, 0600\\) += %d\n", id);
int rc = 1;
struct msqid_ds ds;
int max = msgctl(0, MSG_INFO, &ds);
if (max < 0)
goto fail;
printf("msgctl\\(0, MSG_INFO, %p\\) += %d\n", &ds, max);
if (msgctl(id, MSG_STAT, &ds) != id)
goto fail;
printf("msgctl\\(%d, MSG_STAT, %p\\) += %d\n", id, &ds, id);
rc = 0;
fail:
if (msgctl(id, IPC_RMID, 0) < 0)
return 1;
printf("msgctl\\(%d, IPC_RMID, 0\\) += 0\n", id);
return rc;
}