* tests/ipc_msg.c: Additional msgget (parameter format), msgctl
(parameter format, decoding of struct msqid_ds in IPC_SET/IPC_STAT
commands) checks.
* tests/ipc_sem.c: Additional semget, semctl checks.
* tests/ipc_shm.c: Additional shmctl checks.
* tests/semop.c: Additional semop checks. Added checks for semtimedop.
* tests/semop.test: Add explicit -e parameter in order to trace both
semop and semtimedop.
* tests/shmxt.c: Additional shmat/shmdt tests.
---
tests/ipc_msg.c | 51 +-
tests/ipc_sem.c | 27 +++
tests/ipc_shm.c | 23 +--
tests/semop.c| 65 ++
tests/semop.test |2 +-
tests/shmxt.c| 11 +
6 files changed, 170 insertions(+), 9 deletions(-)
diff --git a/tests/ipc_msg.c b/tests/ipc_msg.c
index 2fd7d4f..5bd6116 100644
--- a/tests/ipc_msg.c
+++ b/tests/ipc_msg.c
@@ -27,10 +27,15 @@
*/
#include "tests.h"
+#include
#include
#include
#include
#include
+#include
+
+#include "xlat.h"
+#include "xlat/resource_flags.h"
static int id = -1;
@@ -48,18 +53,43 @@ main(void)
int rc;
struct msqid_ds ds;
+ static const key_t bogus_key = (key_t)0xeca86420fdb97531ULL;
+ static const int bogus_msgid = 0xfdb97531;
+ static const int bogus_cmd = 0xdeadbeef;
+ static void * const bogus_addr = (void *) -1L;
+ static const int bogus_flags = 0xface1e55 & ~IPC_CREAT;
+
+ assert(msgget(bogus_key, bogus_flags) == -1);
+ printf("msgget\\(%#lx, %s%s%s%#x\\|%#04o\\) += %s\n",
+ (unsigned long)((sizeof(key_t) == sizeof(int)) ?
+ (unsigned)bogus_key : (unsigned long)bogus_key),
+ IPC_CREAT & bogus_flags ? "IPC_CREAT\\|" : "",
+ IPC_EXCL & bogus_flags ? "IPC_EXCL\\|" : "",
+ IPC_NOWAIT & bogus_flags ? "IPC_NOWAIT\\|" : "",
+ bogus_flags & ~(0777 | IPC_CREAT | IPC_EXCL | IPC_NOWAIT),
+ bogus_flags & 0777,
+ sprintrc_grep(-1));
+
id = msgget(IPC_PRIVATE, 0600);
if (id < 0)
perror_msg_and_skip("msgget");
printf("msgget\\(IPC_PRIVATE, 0600\\) += %d\n", id);
atexit(cleanup);
+ assert(msgctl(bogus_msgid, bogus_cmd, NULL) == -1);
+ printf("msgctl\\(%d, (IPC_64\\|)?%#x /\\* MSG_\\?\\?\\? \\*/, NULL\\) "
+ "+= %s\n", bogus_msgid, bogus_cmd, sprintrc_grep(-1));
+
+ assert(msgctl(bogus_msgid, IPC_SET, bogus_addr) == -1);
+ printf("msgctl\\(%d, (IPC_64\\|)?IPC_SET, %p\\) += %s\n",
+ bogus_msgid, bogus_addr, sprintrc_grep(-1));
+
if (msgctl(id, IPC_STAT, ))
perror_msg_and_skip("msgctl IPC_STAT");
- printf("msgctl\\(%d, (IPC_64\\|)?IPC_STAT, \\{msg_perm=\\{uid=%u,
gid=%u, "
- "mode=%#o, key=%u, cuid=%u, cgid=%u\\}, msg_stime=%u,
msg_rtime=%u, "
- "msg_ctime=%u, msg_qnum=%u, msg_qbytes=%u, msg_lspid=%u, "
- "msg_lrpid=%u\\}\\) += 0\n",
+ printf("msgctl\\(%d, (IPC_64\\|)?IPC_STAT, \\{msg_perm=\\{uid=%u, "
+ "gid=%u, mode=%#o, key=%u, cuid=%u, cgid=%u\\}, msg_stime=%u, "
+ "msg_rtime=%u, msg_ctime=%u, msg_qnum=%u, msg_qbytes=%u, "
+ "msg_lspid=%u, msg_lrpid=%u\\}\\) += 0\n",
id, (unsigned) ds.msg_perm.uid, (unsigned) ds.msg_perm.gid,
(unsigned) ds.msg_perm.mode, (unsigned) ds.msg_perm.__key,
(unsigned) ds.msg_perm.cuid, (unsigned) ds.msg_perm.cgid,
@@ -68,6 +98,13 @@ main(void)
(unsigned) ds.msg_qbytes, (unsigned) ds.msg_lspid,
(unsigned) ds.msg_lrpid);
+ if (msgctl(id, IPC_SET, ))
+ perror_msg_and_skip("msgctl IPC_SET");
+ printf("msgctl\\(%d, (IPC_64\\|)?IPC_SET, \\{msg_perm=\\{uid=%u, "
+ "gid=%u, mode=%#o\\}, ...\\}\\) += 0\n",
+ id, (unsigned) ds.msg_perm.uid, (unsigned) ds.msg_perm.gid,
+ (unsigned) ds.msg_perm.mode);
+
int max = msgctl(0, MSG_INFO, );
if (max < 0)
perror_msg_and_skip("msgctl MSG_INFO");
@@ -81,9 +118,11 @@ main(void)
*/
if (-1 != rc || EINVAL != errno)
perror_msg_and_skip("msgctl MSG_STAT");
- printf("msgctl\\(%d, (IPC_64\\|)?MSG_STAT, %p\\) += -1 EINVAL
\\(%m\\)\n", id, );
+ printf("msgctl\\(%d, (IPC_64\\|)?MSG_STAT, %p\\) += "
+ "-1 EINVAL \\(%m\\)\n", id, );
} else {
- printf("msgctl\\(%d, (IPC_64\\|)?MSG_STAT, %p\\) += %d\n", id,
, id);
+ printf("msgctl\\(%d, (IPC_64\\|)?MSG_STAT, %p\\) += %d\n",
+ id, , id);
}
return 0;
diff --git a/tests/ipc_sem.c b/tests/ipc_sem.c
index afe74d2..09f191d 100644
--- a/tests/ipc_sem.c
+++ b/tests/ipc_sem.c
@@ -27,11 +27,15 @@
*/
#include "tests.h"