* 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.
32 lines
575 B
C
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;
|
|
}
|