[PATCH 4/7] tests: Additional shmget decoder checks

Eugene Syromyatnikov evgsyr at gmail.com
Tue Sep 6 02:08:36 UTC 2016


* tests/ipc_shm.c: Additional checks for shmget syscall decoding.
---
 tests/ipc_shm.c |   20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/tests/ipc_shm.c b/tests/ipc_shm.c
index 54723e2..80a8f0f 100644
--- a/tests/ipc_shm.c
+++ b/tests/ipc_shm.c
@@ -27,11 +27,15 @@
  */
 
 #include "tests.h"
+#include <assert.h>
 #include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <sys/shm.h>
 
+#include "xlat.h"
+#include "xlat/shm_resource_flags.h"
+
 static int id = -1;
 
 static void
@@ -45,9 +49,25 @@ cleanup(void)
 int
 main(void)
 {
+	static const key_t bogus_key = (key_t)0xeca86420fdb97531LLU;
+	static const size_t bogus_size = 0xdec0ded1dec0ded2LLU;
+	static const int bogus_flags = 0xface1e55;
+
 	int rc;
 	struct shmid_ds ds;
 
+	assert(shmget(bogus_key, bogus_size, bogus_flags) == -1);
+	printf("shmget\\(%#lx, %lu, %s%s%s%#x\\|%#04o\\) += %s\n",
+		(unsigned long)((sizeof(key_t) == sizeof(int)) ?
+		(unsigned)bogus_key : (unsigned long)bogus_key),
+		bogus_size,
+		IPC_CREAT & bogus_flags ? "IPC_CREAT\\|" : "",
+		IPC_EXCL & bogus_flags ? "IPC_EXCL\\|" : "",
+		SHM_HUGETLB & bogus_flags ? "SHM_HUGETLB\\|" : "",
+		bogus_flags & ~(0777 | IPC_CREAT | IPC_EXCL | SHM_HUGETLB),
+		bogus_flags & 0777,
+		sprintrc_grep(-1));
+
 	id = shmget(IPC_PRIVATE, 1, 0600);
 	if (id < 0)
 		perror_msg_and_skip("shmget");
-- 
1.7.10.4





More information about the Strace-devel mailing list