]> granicus.if.org Git - strace/commitdiff
tests: robustify ipc_msgbuf.test against broken libc
authorDmitry V. Levin <ldv@altlinux.org>
Sat, 2 Dec 2017 22:01:34 +0000 (22:01 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Sun, 3 Dec 2017 00:25:43 +0000 (00:25 +0000)
glibc between commits glibc-2.25~130 and glibc-2.26~740 had broken
msgctl(IPC_RMID) on hppa: this operation always failed with EINVAL
because of inappropriate use of IPC_64 flag.  Similar issues were
fixed on other niche architectures.  Let's workaround these issues
by skipping the test in case of msgctl(IPC_RMID) failure.

* tests/ipc_msgbuf.c (cleanup): Change return type to int,
return 77 in case of msgctl(IPC_RMID) failure.
(main): Explicitly invoke cleanup() at the end.

tests/ipc_msgbuf.c

index d1083899b53845cc93a0eef2d5cbf467b29527d3..c4af1bef3e909fb6f249e6325de8f8fdd85fbfc2 100644 (file)
 
 static int msqid = -1;
 
-static void
+static int
 cleanup(void)
 {
-       msgctl(msqid, IPC_RMID, 0);
-       msqid = -1;
+       if (msqid != -1) {
+               int rc = msgctl(msqid, IPC_RMID, 0);
+               msqid = -1;
+               if (rc == -1)
+                       return 77;
+       }
+       return 0;
 }
 
 int
@@ -59,10 +64,11 @@ main(void)
        msqid = msgget(IPC_PRIVATE, IPC_CREAT | S_IRWXU);
        if (msqid == -1)
                perror_msg_and_skip("msgget");
-       atexit(cleanup);
+       typedef void (*atexit_func)(void);
+       atexit((atexit_func) cleanup);
        if (msgsnd(msqid, &msg, msgsz, 0) == -1)
                perror_msg_and_skip("msgsnd");
        if (msgrcv(msqid, &msg, msgsz, mtype, 0) != msgsz)
                perror_msg_and_skip("msgrcv");
-       return 0;
+       return cleanup();
 }