strace/SOURCES/0161-tests-disable-tests-fo...

281 lines
7.8 KiB
Diff

From 268b9341ef6397cc337f612563af88ccb5752ca7 Mon Sep 17 00:00:00 2001
From: "Dmitry V. Levin" <ldv@altlinux.org>
Date: Sun, 6 Dec 2020 08:00:00 +0000
Subject: [PATCH 161/162] tests: disable tests for invalid shmctl commands on
glibc >= 2.32
Starting with commit glibc-2.32.9000-207-g9ebaabeaac1a96b0d91f,
glibc skips shmctl syscall invocations and returns EINVAL
for invalid shmctl commands.
* tests/ipc_shm.c [GLIBC_PREREQ_GE(2, 32)] (TEST_SHMCTL_BOGUS_CMD):
Define to 0.
[!TEST_SHMCTL_BOGUS_CMD] (TEST_SHMCTL_BOGUS_CMD): Define to 1.
(main) [!TEST_SHMCTL_BOGUS_CMD] (bogus_cmd): Do not define and do not
use.
---
tests/ipc_shm.c | 49 ++++++++++++++++++++++++++++++++++---------------
1 file changed, 34 insertions(+), 15 deletions(-)
diff --git a/tests/ipc_shm.c b/tests/ipc_shm.c
index 695fd94..350bde5 100644
--- a/tests/ipc_shm.c
+++ b/tests/ipc_shm.c
@@ -29,6 +29,34 @@
# define SHM_NORESERVE 010000
#endif
+#undef TEST_SHMCTL_BOGUS_ADDR
+#undef TEST_SHMCTL_BOGUS_CMD
+
+/*
+ * Starting with commit glibc-2.32~80, on every 32-bit architecture
+ * where 32-bit time_t support is enabled, glibc tries to retrieve
+ * the data provided in the third argument of shmctl call.
+ */
+#if GLIBC_PREREQ_GE(2, 32) && defined __TIMESIZE && __TIMESIZE != 64
+# define TEST_SHMCTL_BOGUS_ADDR 0
+#endif
+
+/*
+ * Starting with commit glibc-2.32.9000-207-g9ebaabeaac1a96b0d91f,
+ * glibc skips shmctl syscall invocations and returns EINVAL
+ * for invalid shmctl commands.
+ */
+#if GLIBC_PREREQ_GE(2, 32)
+# define TEST_SHMCTL_BOGUS_CMD 0
+#endif
+
+#ifndef TEST_SHMCTL_BOGUS_ADDR
+# define TEST_SHMCTL_BOGUS_ADDR 1
+#endif
+#ifndef TEST_SHMCTL_BOGUS_CMD
+# define TEST_SHMCTL_BOGUS_CMD 1
+#endif
+
#include "xlat.h"
#include "xlat/shm_resource_flags.h"
@@ -73,21 +101,6 @@
# define str_bogus_cmd "0xdefaced2 /\\* SHM_\\?\\?\\? \\*/"
#endif
-#undef TEST_SHMCTL_BOGUS_ADDR
-
-/*
- * Starting with commit glibc-2.32~80, on every 32-bit architecture
- * where 32-bit time_t support is enabled, glibc tries to retrieve
- * the data provided in the third argument of shmctl call.
- */
-#if GLIBC_PREREQ_GE(2, 32) && defined __TIMESIZE && __TIMESIZE != 64
-# define TEST_SHMCTL_BOGUS_ADDR 0
-#endif
-
-#ifndef TEST_SHMCTL_BOGUS_ADDR
-# define TEST_SHMCTL_BOGUS_ADDR 1
-#endif
-
static int id = -1;
static void
@@ -105,8 +118,12 @@ main(void)
static const key_t private_key =
(key_t) (0xffffffff00000000ULL | IPC_PRIVATE);
static const key_t bogus_key = (key_t) 0xeca86420fdb97531ULL;
+#if TEST_SHMCTL_BOGUS_CMD || TEST_SHMCTL_BOGUS_ADDR
static const int bogus_id = 0xdefaced1;
+#endif
+#if TEST_SHMCTL_BOGUS_CMD
static const int bogus_cmd = 0xdefaced2;
+#endif
#if TEST_SHMCTL_BOGUS_ADDR
static void * const bogus_addr = (void *) -1L;
#endif
@@ -173,9 +190,11 @@ main(void)
printf("shmget\\(%s, 1, 0600\\) = %d\n", str_ipc_private, id);
atexit(cleanup);
+#if TEST_SHMCTL_BOGUS_CMD
rc = shmctl(bogus_id, bogus_cmd, NULL);
printf("shmctl\\(%d, (%s\\|)?%s, NULL\\) = %s\n",
bogus_id, str_ipc_64, str_bogus_cmd, sprintrc_grep(rc));
+#endif
#if TEST_SHMCTL_BOGUS_ADDR
rc = shmctl(bogus_id, IPC_STAT, bogus_addr);
diff --git a/tests-m32/ipc_shm.c b/tests-m32/ipc_shm.c
index 695fd94..350bde5 100644
--- a/tests-m32/ipc_shm.c
+++ b/tests-m32/ipc_shm.c
@@ -29,6 +29,34 @@
# define SHM_NORESERVE 010000
#endif
+#undef TEST_SHMCTL_BOGUS_ADDR
+#undef TEST_SHMCTL_BOGUS_CMD
+
+/*
+ * Starting with commit glibc-2.32~80, on every 32-bit architecture
+ * where 32-bit time_t support is enabled, glibc tries to retrieve
+ * the data provided in the third argument of shmctl call.
+ */
+#if GLIBC_PREREQ_GE(2, 32) && defined __TIMESIZE && __TIMESIZE != 64
+# define TEST_SHMCTL_BOGUS_ADDR 0
+#endif
+
+/*
+ * Starting with commit glibc-2.32.9000-207-g9ebaabeaac1a96b0d91f,
+ * glibc skips shmctl syscall invocations and returns EINVAL
+ * for invalid shmctl commands.
+ */
+#if GLIBC_PREREQ_GE(2, 32)
+# define TEST_SHMCTL_BOGUS_CMD 0
+#endif
+
+#ifndef TEST_SHMCTL_BOGUS_ADDR
+# define TEST_SHMCTL_BOGUS_ADDR 1
+#endif
+#ifndef TEST_SHMCTL_BOGUS_CMD
+# define TEST_SHMCTL_BOGUS_CMD 1
+#endif
+
#include "xlat.h"
#include "xlat/shm_resource_flags.h"
@@ -73,21 +101,6 @@
# define str_bogus_cmd "0xdefaced2 /\\* SHM_\\?\\?\\? \\*/"
#endif
-#undef TEST_SHMCTL_BOGUS_ADDR
-
-/*
- * Starting with commit glibc-2.32~80, on every 32-bit architecture
- * where 32-bit time_t support is enabled, glibc tries to retrieve
- * the data provided in the third argument of shmctl call.
- */
-#if GLIBC_PREREQ_GE(2, 32) && defined __TIMESIZE && __TIMESIZE != 64
-# define TEST_SHMCTL_BOGUS_ADDR 0
-#endif
-
-#ifndef TEST_SHMCTL_BOGUS_ADDR
-# define TEST_SHMCTL_BOGUS_ADDR 1
-#endif
-
static int id = -1;
static void
@@ -105,8 +118,12 @@ main(void)
static const key_t private_key =
(key_t) (0xffffffff00000000ULL | IPC_PRIVATE);
static const key_t bogus_key = (key_t) 0xeca86420fdb97531ULL;
+#if TEST_SHMCTL_BOGUS_CMD || TEST_SHMCTL_BOGUS_ADDR
static const int bogus_id = 0xdefaced1;
+#endif
+#if TEST_SHMCTL_BOGUS_CMD
static const int bogus_cmd = 0xdefaced2;
+#endif
#if TEST_SHMCTL_BOGUS_ADDR
static void * const bogus_addr = (void *) -1L;
#endif
@@ -173,9 +190,11 @@ main(void)
printf("shmget\\(%s, 1, 0600\\) = %d\n", str_ipc_private, id);
atexit(cleanup);
+#if TEST_SHMCTL_BOGUS_CMD
rc = shmctl(bogus_id, bogus_cmd, NULL);
printf("shmctl\\(%d, (%s\\|)?%s, NULL\\) = %s\n",
bogus_id, str_ipc_64, str_bogus_cmd, sprintrc_grep(rc));
+#endif
#if TEST_SHMCTL_BOGUS_ADDR
rc = shmctl(bogus_id, IPC_STAT, bogus_addr);
diff --git a/tests-mx32/ipc_shm.c b/tests-mx32/ipc_shm.c
index 695fd94..350bde5 100644
--- a/tests-mx32/ipc_shm.c
+++ b/tests-mx32/ipc_shm.c
@@ -29,6 +29,34 @@
# define SHM_NORESERVE 010000
#endif
+#undef TEST_SHMCTL_BOGUS_ADDR
+#undef TEST_SHMCTL_BOGUS_CMD
+
+/*
+ * Starting with commit glibc-2.32~80, on every 32-bit architecture
+ * where 32-bit time_t support is enabled, glibc tries to retrieve
+ * the data provided in the third argument of shmctl call.
+ */
+#if GLIBC_PREREQ_GE(2, 32) && defined __TIMESIZE && __TIMESIZE != 64
+# define TEST_SHMCTL_BOGUS_ADDR 0
+#endif
+
+/*
+ * Starting with commit glibc-2.32.9000-207-g9ebaabeaac1a96b0d91f,
+ * glibc skips shmctl syscall invocations and returns EINVAL
+ * for invalid shmctl commands.
+ */
+#if GLIBC_PREREQ_GE(2, 32)
+# define TEST_SHMCTL_BOGUS_CMD 0
+#endif
+
+#ifndef TEST_SHMCTL_BOGUS_ADDR
+# define TEST_SHMCTL_BOGUS_ADDR 1
+#endif
+#ifndef TEST_SHMCTL_BOGUS_CMD
+# define TEST_SHMCTL_BOGUS_CMD 1
+#endif
+
#include "xlat.h"
#include "xlat/shm_resource_flags.h"
@@ -73,21 +101,6 @@
# define str_bogus_cmd "0xdefaced2 /\\* SHM_\\?\\?\\? \\*/"
#endif
-#undef TEST_SHMCTL_BOGUS_ADDR
-
-/*
- * Starting with commit glibc-2.32~80, on every 32-bit architecture
- * where 32-bit time_t support is enabled, glibc tries to retrieve
- * the data provided in the third argument of shmctl call.
- */
-#if GLIBC_PREREQ_GE(2, 32) && defined __TIMESIZE && __TIMESIZE != 64
-# define TEST_SHMCTL_BOGUS_ADDR 0
-#endif
-
-#ifndef TEST_SHMCTL_BOGUS_ADDR
-# define TEST_SHMCTL_BOGUS_ADDR 1
-#endif
-
static int id = -1;
static void
@@ -105,8 +118,12 @@ main(void)
static const key_t private_key =
(key_t) (0xffffffff00000000ULL | IPC_PRIVATE);
static const key_t bogus_key = (key_t) 0xeca86420fdb97531ULL;
+#if TEST_SHMCTL_BOGUS_CMD || TEST_SHMCTL_BOGUS_ADDR
static const int bogus_id = 0xdefaced1;
+#endif
+#if TEST_SHMCTL_BOGUS_CMD
static const int bogus_cmd = 0xdefaced2;
+#endif
#if TEST_SHMCTL_BOGUS_ADDR
static void * const bogus_addr = (void *) -1L;
#endif
@@ -173,9 +190,11 @@ main(void)
printf("shmget\\(%s, 1, 0600\\) = %d\n", str_ipc_private, id);
atexit(cleanup);
+#if TEST_SHMCTL_BOGUS_CMD
rc = shmctl(bogus_id, bogus_cmd, NULL);
printf("shmctl\\(%d, (%s\\|)?%s, NULL\\) = %s\n",
bogus_id, str_ipc_64, str_bogus_cmd, sprintrc_grep(rc));
+#endif
#if TEST_SHMCTL_BOGUS_ADDR
rc = shmctl(bogus_id, IPC_STAT, bogus_addr);
--
2.1.4