]> granicus.if.org Git - strace/commitdiff
tests: check all bits of mtype in ipc_msgbuf test
authorEugene Syromyatnikov <evgsyr@gmail.com>
Fri, 6 Apr 2018 17:03:04 +0000 (19:03 +0200)
committerDmitry V. Levin <ldv@altlinux.org>
Mon, 7 May 2018 10:52:16 +0000 (10:52 +0000)
* tests/ipc_msgbuf.c: Include <unistd.h> and <asm/unistd.h>.
(sys_msgrcv): New function.
(msgrcv): Use it instead of msgrcv.  Add bits to mtype,
check for -mtype in msgrcv.

tests/ipc_msgbuf.c

index f228046a3df1b434145b72af19613e9403150d57..6789429f2b9d58716850d573c87b86d941dd2115 100644 (file)
@@ -30,6 +30,8 @@
 #include "tests.h"
 #include <stdio.h>
 #include <stdlib.h>
+#include <unistd.h>
+#include <asm/unistd.h>
 #include <sys/ipc.h>
 #include <sys/msg.h>
 #include <sys/stat.h>
@@ -54,10 +56,22 @@ cleanup(void)
        return 0;
 }
 
+int
+sys_msgrcv(int msqid, void *msgp, size_t sz, kernel_long_t msgtyp,
+          int msgflg)
+{
+#if defined __x86_64__ && defined __ILP32__
+       return syscall(__NR_msgrcv, msqid, msgp, sz, msgtyp, msgflg);
+#else
+       return msgrcv(msqid, msgp, sz, msgtyp, msgflg);
+#endif
+}
+
 int
 main(void)
 {
-       const long mtype = 0xdefaced;
+       /* mtype has to be positive */
+       const kernel_long_t mtype = (kernel_long_t) 0x7facefed5adc0dedULL;
        struct {
                kernel_long_t mtype;
                char mtext[msgsz];
@@ -78,11 +92,12 @@ main(void)
               msqid, (long long) mtype);
        if (msgsnd(msqid, &msg, msgsz, 0) == -1)
                perror_msg_and_skip("msgsnd");
-       if (msgrcv(msqid, &msg, msgsz, mtype, 0) != msgsz)
+
+       if (sys_msgrcv(msqid, &msg, msgsz, -mtype, 0) != msgsz)
                perror_msg_and_skip("msgrcv");
        printf("msgrcv\\(%d, \\{%lld, \"" text_string "\\\\0\"\\}, 14, %lld"
               ", 0\\) = 14\n",
-              msqid, (long long) mtype, (long long) mtype);
+              msqid, (long long) mtype, -(long long) mtype);
 
        return cleanup();
 }