Blob Blame History Raw
commit 79d10dfc20985225e4ea044d3875c4cea09053d7
Author: Eugene Syromyatnikov <evgsyr@gmail.com>
Date:   Wed Jan 24 09:55:50 2018 -0500

    Update futex test in accordance with kernel's v4.15-rc7-202-gfbe0e83
    
    * futex.c (VALP, VALP_PR, VAL2P, VAL2P_PR): New macro definitions.
    (main): Allow EINVAL on *REQUEUE* checks with VAL/VAL2 with higher bit
    being set, check that the existing behaviour preserved with VALP/VAL2P
    where higher bit is unset.

diff -rup a/tests/futex.c b/tests/futex.c
--- a/tests/futex.c	2017-05-22 13:33:51.000000000 -0400
+++ b/tests/futex.c	2018-04-03 12:12:08.445383018 -0400
@@ -150,14 +150,20 @@ void invalid_op(int *val, int op, uint32
 	} while (0)
 
 /* Value which differs from one stored in int *val */
-# define VAL     ((unsigned long) 0xbadda7a0facefeedLLU)
-# define VAL_PR  ((unsigned) VAL)
+# define VAL      ((unsigned long) 0xbadda7a0facefeedLLU)
+# define VAL_PR   ((unsigned) VAL)
 
-# define VAL2    ((unsigned long) 0xbadda7a0ca7b100dLLU)
-# define VAL2_PR ((unsigned) VAL2)
+# define VALP     ((unsigned long) 0xbadda7a01acefeedLLU)
+# define VALP_PR  ((unsigned) VALP)
 
-# define VAL3    ((unsigned long) 0xbadda7a09caffee1LLU)
-# define VAL3_PR ((unsigned) VAL3)
+# define VAL2     ((unsigned long) 0xbadda7a0ca7b100dLLU)
+# define VAL2_PR  ((unsigned) VAL2)
+
+# define VAL2P    ((unsigned long) 0xbadda7a07a7b100dLLU)
+# define VAL2P_PR ((unsigned) VAL2P)
+
+# define VAL3     ((unsigned long) 0xbadda7a09caffee1LLU)
+# define VAL3_PR  ((unsigned) VAL3)
 
 int
 main(int argc, char *argv[])
@@ -417,16 +423,26 @@ main(int argc, char *argv[])
 
 	/* Trying to re-queue some processes but there's nothing to re-queue */
 	CHECK_FUTEX(uaddr, FUTEX_REQUEUE, VAL, VAL2, uaddr2, VAL3,
-		(rc == 0));
+		(rc == 0) || ((rc == -1) && (errno == EINVAL)));
 	printf("futex(%p, FUTEX_REQUEUE, %u, %u, %p) = %s\n",
 		uaddr, VAL_PR, VAL2_PR, uaddr2, sprintrc(rc));
 
+	CHECK_FUTEX(uaddr, FUTEX_REQUEUE, VALP, VAL2P, uaddr2, VAL3,
+		(rc == 0));
+	printf("futex(%p, FUTEX_REQUEUE, %u, %u, %p) = %s\n",
+		uaddr, VALP_PR, VAL2P_PR, uaddr2, sprintrc(rc));
+
 	/* Trying to re-queue some processes but there's nothing to re-queue */
 	CHECK_FUTEX_ENOSYS(uaddr, FUTEX_PRIVATE_FLAG | FUTEX_REQUEUE, VAL, VAL2,
-		uaddr2, VAL3, (rc == 0));
+		uaddr2, VAL3, (rc == 0) || ((rc == -1) && (errno == EINVAL)));
 	printf("futex(%p, FUTEX_REQUEUE_PRIVATE, %u, %u, %p) = %s\n",
 		uaddr, VAL_PR, VAL2_PR, uaddr2, sprintrc(rc));
 
+	CHECK_FUTEX_ENOSYS(uaddr, FUTEX_PRIVATE_FLAG | FUTEX_REQUEUE, VALP,
+		VAL2P, uaddr2, VAL3, (rc == 0));
+	printf("futex(%p, FUTEX_REQUEUE_PRIVATE, %u, %u, %p) = %s\n",
+		uaddr, VALP_PR, VAL2P_PR, uaddr2, sprintrc(rc));
+
 	CHECK_INVALID_CLOCKRT(FUTEX_REQUEUE, ARG3 | ARG4 | ARG5, "%u", "%u",
 		"%#lx");
 
@@ -443,22 +459,38 @@ main(int argc, char *argv[])
 
 	/* Comparison re-queue with wrong val value */
 	CHECK_FUTEX(uaddr, FUTEX_CMP_REQUEUE, VAL, VAL2, uaddr2, VAL3,
-		(rc == -1) && (errno == EAGAIN));
+		(rc == -1) && (errno == EAGAIN || errno == EINVAL));
 	printf("futex(%p, FUTEX_CMP_REQUEUE, %u, %u, %p, %u) = %s\n",
 		uaddr, VAL_PR, VAL2_PR, uaddr2, VAL3_PR, sprintrc(rc));
 
+	CHECK_FUTEX(uaddr, FUTEX_CMP_REQUEUE, VALP, VAL2P, uaddr2, VAL3,
+		(rc == -1) && (errno == EAGAIN));
+	printf("futex(%p, FUTEX_CMP_REQUEUE, %u, %u, %p, %u) = %s\n",
+		uaddr, VALP_PR, VAL2P_PR, uaddr2, VAL3_PR, sprintrc(rc));
+
 	/* Successful comparison re-queue */
 	CHECK_FUTEX(uaddr, FUTEX_CMP_REQUEUE, VAL, VAL2, uaddr2, *uaddr,
-		(rc == 0));
+		(rc == 0) || ((rc == -1) && (errno == EINVAL)));
 	printf("futex(%p, FUTEX_CMP_REQUEUE, %u, %u, %p, %u) = %s\n",
 		uaddr, VAL_PR, VAL2_PR, uaddr2, *uaddr, sprintrc(rc));
 
+	CHECK_FUTEX(uaddr, FUTEX_CMP_REQUEUE, VALP, VAL2P, uaddr2, *uaddr,
+		(rc == 0));
+	printf("futex(%p, FUTEX_CMP_REQUEUE, %u, %u, %p, %u) = %s\n",
+		uaddr, VALP_PR, VAL2P_PR, uaddr2, *uaddr, sprintrc(rc));
+
 	/* Successful comparison re-queue */
 	CHECK_FUTEX_ENOSYS(uaddr, FUTEX_PRIVATE_FLAG | FUTEX_CMP_REQUEUE, VAL,
-		VAL2, uaddr2, *uaddr, (rc == 0));
+		VAL2, uaddr2, *uaddr,
+		(rc == 0) || ((rc == -1) && (errno == EINVAL)));
 	printf("futex(%p, FUTEX_CMP_REQUEUE_PRIVATE, %u, %u, %p, %u) = %s\n",
 		uaddr, VAL_PR, VAL2_PR, uaddr2, *uaddr, sprintrc(rc));
 
+	CHECK_FUTEX_ENOSYS(uaddr, FUTEX_PRIVATE_FLAG | FUTEX_CMP_REQUEUE, VALP,
+		VAL2P, uaddr2, *uaddr, (rc == 0));
+	printf("futex(%p, FUTEX_CMP_REQUEUE_PRIVATE, %u, %u, %p, %u) = %s\n",
+		uaddr, VALP_PR, VAL2P_PR, uaddr2, *uaddr, sprintrc(rc));
+
 	CHECK_INVALID_CLOCKRT(FUTEX_CMP_REQUEUE, ARG3 | ARG4 | ARG5 | ARG6,
 		"%u", "%u", "%#lx", "%u");
 
diff -rup a/tests-m32/futex.c b/tests-m32/futex.c
--- a/tests-m32/futex.c	2017-05-22 13:33:51.000000000 -0400
+++ b/tests-m32/futex.c	2018-04-03 12:13:23.219848033 -0400
@@ -150,14 +150,20 @@ void invalid_op(int *val, int op, uint32
 	} while (0)
 
 /* Value which differs from one stored in int *val */
-# define VAL     ((unsigned long) 0xbadda7a0facefeedLLU)
-# define VAL_PR  ((unsigned) VAL)
+# define VAL      ((unsigned long) 0xbadda7a0facefeedLLU)
+# define VAL_PR   ((unsigned) VAL)
 
-# define VAL2    ((unsigned long) 0xbadda7a0ca7b100dLLU)
-# define VAL2_PR ((unsigned) VAL2)
+# define VALP     ((unsigned long) 0xbadda7a01acefeedLLU)
+# define VALP_PR  ((unsigned) VALP)
 
-# define VAL3    ((unsigned long) 0xbadda7a09caffee1LLU)
-# define VAL3_PR ((unsigned) VAL3)
+# define VAL2     ((unsigned long) 0xbadda7a0ca7b100dLLU)
+# define VAL2_PR  ((unsigned) VAL2)
+
+# define VAL2P    ((unsigned long) 0xbadda7a07a7b100dLLU)
+# define VAL2P_PR ((unsigned) VAL2P)
+
+# define VAL3     ((unsigned long) 0xbadda7a09caffee1LLU)
+# define VAL3_PR  ((unsigned) VAL3)
 
 int
 main(int argc, char *argv[])
@@ -417,16 +423,26 @@ main(int argc, char *argv[])
 
 	/* Trying to re-queue some processes but there's nothing to re-queue */
 	CHECK_FUTEX(uaddr, FUTEX_REQUEUE, VAL, VAL2, uaddr2, VAL3,
-		(rc == 0));
+		(rc == 0) || ((rc == -1) && (errno == EINVAL)));
 	printf("futex(%p, FUTEX_REQUEUE, %u, %u, %p) = %s\n",
 		uaddr, VAL_PR, VAL2_PR, uaddr2, sprintrc(rc));
 
+	CHECK_FUTEX(uaddr, FUTEX_REQUEUE, VALP, VAL2P, uaddr2, VAL3,
+		(rc == 0));
+	printf("futex(%p, FUTEX_REQUEUE, %u, %u, %p) = %s\n",
+		uaddr, VALP_PR, VAL2P_PR, uaddr2, sprintrc(rc));
+
 	/* Trying to re-queue some processes but there's nothing to re-queue */
 	CHECK_FUTEX_ENOSYS(uaddr, FUTEX_PRIVATE_FLAG | FUTEX_REQUEUE, VAL, VAL2,
-		uaddr2, VAL3, (rc == 0));
+		uaddr2, VAL3, (rc == 0) || ((rc == -1) && (errno == EINVAL)));
 	printf("futex(%p, FUTEX_REQUEUE_PRIVATE, %u, %u, %p) = %s\n",
 		uaddr, VAL_PR, VAL2_PR, uaddr2, sprintrc(rc));
 
+	CHECK_FUTEX_ENOSYS(uaddr, FUTEX_PRIVATE_FLAG | FUTEX_REQUEUE, VALP,
+		VAL2P, uaddr2, VAL3, (rc == 0));
+	printf("futex(%p, FUTEX_REQUEUE_PRIVATE, %u, %u, %p) = %s\n",
+		uaddr, VALP_PR, VAL2P_PR, uaddr2, sprintrc(rc));
+
 	CHECK_INVALID_CLOCKRT(FUTEX_REQUEUE, ARG3 | ARG4 | ARG5, "%u", "%u",
 		"%#lx");
 
@@ -443,22 +459,38 @@ main(int argc, char *argv[])
 
 	/* Comparison re-queue with wrong val value */
 	CHECK_FUTEX(uaddr, FUTEX_CMP_REQUEUE, VAL, VAL2, uaddr2, VAL3,
-		(rc == -1) && (errno == EAGAIN));
+		(rc == -1) && (errno == EAGAIN || errno == EINVAL));
 	printf("futex(%p, FUTEX_CMP_REQUEUE, %u, %u, %p, %u) = %s\n",
 		uaddr, VAL_PR, VAL2_PR, uaddr2, VAL3_PR, sprintrc(rc));
 
+	CHECK_FUTEX(uaddr, FUTEX_CMP_REQUEUE, VALP, VAL2P, uaddr2, VAL3,
+		(rc == -1) && (errno == EAGAIN));
+	printf("futex(%p, FUTEX_CMP_REQUEUE, %u, %u, %p, %u) = %s\n",
+		uaddr, VALP_PR, VAL2P_PR, uaddr2, VAL3_PR, sprintrc(rc));
+
 	/* Successful comparison re-queue */
 	CHECK_FUTEX(uaddr, FUTEX_CMP_REQUEUE, VAL, VAL2, uaddr2, *uaddr,
-		(rc == 0));
+		(rc == 0) || ((rc == -1) && (errno == EINVAL)));
 	printf("futex(%p, FUTEX_CMP_REQUEUE, %u, %u, %p, %u) = %s\n",
 		uaddr, VAL_PR, VAL2_PR, uaddr2, *uaddr, sprintrc(rc));
 
+	CHECK_FUTEX(uaddr, FUTEX_CMP_REQUEUE, VALP, VAL2P, uaddr2, *uaddr,
+		(rc == 0));
+	printf("futex(%p, FUTEX_CMP_REQUEUE, %u, %u, %p, %u) = %s\n",
+		uaddr, VALP_PR, VAL2P_PR, uaddr2, *uaddr, sprintrc(rc));
+
 	/* Successful comparison re-queue */
 	CHECK_FUTEX_ENOSYS(uaddr, FUTEX_PRIVATE_FLAG | FUTEX_CMP_REQUEUE, VAL,
-		VAL2, uaddr2, *uaddr, (rc == 0));
+		VAL2, uaddr2, *uaddr,
+		(rc == 0) || ((rc == -1) && (errno == EINVAL)));
 	printf("futex(%p, FUTEX_CMP_REQUEUE_PRIVATE, %u, %u, %p, %u) = %s\n",
 		uaddr, VAL_PR, VAL2_PR, uaddr2, *uaddr, sprintrc(rc));
 
+	CHECK_FUTEX_ENOSYS(uaddr, FUTEX_PRIVATE_FLAG | FUTEX_CMP_REQUEUE, VALP,
+		VAL2P, uaddr2, *uaddr, (rc == 0));
+	printf("futex(%p, FUTEX_CMP_REQUEUE_PRIVATE, %u, %u, %p, %u) = %s\n",
+		uaddr, VALP_PR, VAL2P_PR, uaddr2, *uaddr, sprintrc(rc));
+
 	CHECK_INVALID_CLOCKRT(FUTEX_CMP_REQUEUE, ARG3 | ARG4 | ARG5 | ARG6,
 		"%u", "%u", "%#lx", "%u");
 
diff -rup a/tests-mx32/futex.c b/tests-mx32/futex.c
--- a/tests-mx32/futex.c	2017-05-22 13:33:51.000000000 -0400
+++ b/tests-mx32/futex.c	2018-04-03 12:13:25.235860501 -0400
@@ -150,14 +150,20 @@ void invalid_op(int *val, int op, uint32
 	} while (0)
 
 /* Value which differs from one stored in int *val */
-# define VAL     ((unsigned long) 0xbadda7a0facefeedLLU)
-# define VAL_PR  ((unsigned) VAL)
+# define VAL      ((unsigned long) 0xbadda7a0facefeedLLU)
+# define VAL_PR   ((unsigned) VAL)
 
-# define VAL2    ((unsigned long) 0xbadda7a0ca7b100dLLU)
-# define VAL2_PR ((unsigned) VAL2)
+# define VALP     ((unsigned long) 0xbadda7a01acefeedLLU)
+# define VALP_PR  ((unsigned) VALP)
 
-# define VAL3    ((unsigned long) 0xbadda7a09caffee1LLU)
-# define VAL3_PR ((unsigned) VAL3)
+# define VAL2     ((unsigned long) 0xbadda7a0ca7b100dLLU)
+# define VAL2_PR  ((unsigned) VAL2)
+
+# define VAL2P    ((unsigned long) 0xbadda7a07a7b100dLLU)
+# define VAL2P_PR ((unsigned) VAL2P)
+
+# define VAL3     ((unsigned long) 0xbadda7a09caffee1LLU)
+# define VAL3_PR  ((unsigned) VAL3)
 
 int
 main(int argc, char *argv[])
@@ -417,16 +423,26 @@ main(int argc, char *argv[])
 
 	/* Trying to re-queue some processes but there's nothing to re-queue */
 	CHECK_FUTEX(uaddr, FUTEX_REQUEUE, VAL, VAL2, uaddr2, VAL3,
-		(rc == 0));
+		(rc == 0) || ((rc == -1) && (errno == EINVAL)));
 	printf("futex(%p, FUTEX_REQUEUE, %u, %u, %p) = %s\n",
 		uaddr, VAL_PR, VAL2_PR, uaddr2, sprintrc(rc));
 
+	CHECK_FUTEX(uaddr, FUTEX_REQUEUE, VALP, VAL2P, uaddr2, VAL3,
+		(rc == 0));
+	printf("futex(%p, FUTEX_REQUEUE, %u, %u, %p) = %s\n",
+		uaddr, VALP_PR, VAL2P_PR, uaddr2, sprintrc(rc));
+
 	/* Trying to re-queue some processes but there's nothing to re-queue */
 	CHECK_FUTEX_ENOSYS(uaddr, FUTEX_PRIVATE_FLAG | FUTEX_REQUEUE, VAL, VAL2,
-		uaddr2, VAL3, (rc == 0));
+		uaddr2, VAL3, (rc == 0) || ((rc == -1) && (errno == EINVAL)));
 	printf("futex(%p, FUTEX_REQUEUE_PRIVATE, %u, %u, %p) = %s\n",
 		uaddr, VAL_PR, VAL2_PR, uaddr2, sprintrc(rc));
 
+	CHECK_FUTEX_ENOSYS(uaddr, FUTEX_PRIVATE_FLAG | FUTEX_REQUEUE, VALP,
+		VAL2P, uaddr2, VAL3, (rc == 0));
+	printf("futex(%p, FUTEX_REQUEUE_PRIVATE, %u, %u, %p) = %s\n",
+		uaddr, VALP_PR, VAL2P_PR, uaddr2, sprintrc(rc));
+
 	CHECK_INVALID_CLOCKRT(FUTEX_REQUEUE, ARG3 | ARG4 | ARG5, "%u", "%u",
 		"%#lx");
 
@@ -443,22 +459,38 @@ main(int argc, char *argv[])
 
 	/* Comparison re-queue with wrong val value */
 	CHECK_FUTEX(uaddr, FUTEX_CMP_REQUEUE, VAL, VAL2, uaddr2, VAL3,
-		(rc == -1) && (errno == EAGAIN));
+		(rc == -1) && (errno == EAGAIN || errno == EINVAL));
 	printf("futex(%p, FUTEX_CMP_REQUEUE, %u, %u, %p, %u) = %s\n",
 		uaddr, VAL_PR, VAL2_PR, uaddr2, VAL3_PR, sprintrc(rc));
 
+	CHECK_FUTEX(uaddr, FUTEX_CMP_REQUEUE, VALP, VAL2P, uaddr2, VAL3,
+		(rc == -1) && (errno == EAGAIN));
+	printf("futex(%p, FUTEX_CMP_REQUEUE, %u, %u, %p, %u) = %s\n",
+		uaddr, VALP_PR, VAL2P_PR, uaddr2, VAL3_PR, sprintrc(rc));
+
 	/* Successful comparison re-queue */
 	CHECK_FUTEX(uaddr, FUTEX_CMP_REQUEUE, VAL, VAL2, uaddr2, *uaddr,
-		(rc == 0));
+		(rc == 0) || ((rc == -1) && (errno == EINVAL)));
 	printf("futex(%p, FUTEX_CMP_REQUEUE, %u, %u, %p, %u) = %s\n",
 		uaddr, VAL_PR, VAL2_PR, uaddr2, *uaddr, sprintrc(rc));
 
+	CHECK_FUTEX(uaddr, FUTEX_CMP_REQUEUE, VALP, VAL2P, uaddr2, *uaddr,
+		(rc == 0));
+	printf("futex(%p, FUTEX_CMP_REQUEUE, %u, %u, %p, %u) = %s\n",
+		uaddr, VALP_PR, VAL2P_PR, uaddr2, *uaddr, sprintrc(rc));
+
 	/* Successful comparison re-queue */
 	CHECK_FUTEX_ENOSYS(uaddr, FUTEX_PRIVATE_FLAG | FUTEX_CMP_REQUEUE, VAL,
-		VAL2, uaddr2, *uaddr, (rc == 0));
+		VAL2, uaddr2, *uaddr,
+		(rc == 0) || ((rc == -1) && (errno == EINVAL)));
 	printf("futex(%p, FUTEX_CMP_REQUEUE_PRIVATE, %u, %u, %p, %u) = %s\n",
 		uaddr, VAL_PR, VAL2_PR, uaddr2, *uaddr, sprintrc(rc));
 
+	CHECK_FUTEX_ENOSYS(uaddr, FUTEX_PRIVATE_FLAG | FUTEX_CMP_REQUEUE, VALP,
+		VAL2P, uaddr2, *uaddr, (rc == 0));
+	printf("futex(%p, FUTEX_CMP_REQUEUE_PRIVATE, %u, %u, %p, %u) = %s\n",
+		uaddr, VALP_PR, VAL2P_PR, uaddr2, *uaddr, sprintrc(rc));
+
 	CHECK_INVALID_CLOCKRT(FUTEX_CMP_REQUEUE, ARG3 | ARG4 | ARG5 | ARG6,
 		"%u", "%u", "%#lx", "%u");