diff options
Diffstat (limited to 'sysvipc')
-rw-r--r-- | sysvipc/test-sysvipc.h | 25 | ||||
-rw-r--r-- | sysvipc/test-sysvmsg.c | 5 |
2 files changed, 30 insertions, 0 deletions
diff --git a/sysvipc/test-sysvipc.h b/sysvipc/test-sysvipc.h index d7ed496511..21ef6c6565 100644 --- a/sysvipc/test-sysvipc.h +++ b/sysvipc/test-sysvipc.h @@ -82,4 +82,29 @@ first_sem_invalid_cmd (void) return invalid; } +/* Return the first invalid command SysV IPC command for message queue. */ +static inline int +first_msg_invalid_cmd (void) +{ + const int msg_cmds[] = { + MSG_STAT, + MSG_INFO, +#ifdef MSG_STAT_ANY + MSG_STAT_ANY, +#endif + }; + + int invalid = first_common_invalid_cmd (); + for (int i = 0; i < array_length (msg_cmds); i++) + { + if (invalid == msg_cmds[i]) + { + invalid++; + i = 0; + } + } + + return invalid; +} + #endif /* _TEST_SYSV_H */ diff --git a/sysvipc/test-sysvmsg.c b/sysvipc/test-sysvmsg.c index 84efdade5e..ada2881065 100644 --- a/sysvipc/test-sysvmsg.c +++ b/sysvipc/test-sysvmsg.c @@ -24,6 +24,8 @@ #include <sys/ipc.h> #include <sys/msg.h> +#include <test-sysvipc.h> + #include <support/support.h> #include <support/check.h> #include <support/temp_file.h> @@ -86,6 +88,9 @@ do_test (void) FAIL_EXIT1 ("msgget failed (errno=%d)", errno); } + TEST_COMPARE (msgctl (msqid, first_msg_invalid_cmd (), NULL), -1); + TEST_COMPARE (errno, EINVAL); + /* Get message queue kernel information and do some sanity checks. */ struct msqid_ds msginfo; if (msgctl (msqid, IPC_STAT, &msginfo) == -1) |