From a6e30c11d24c3387d60df668d951ea5af390ea11 Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Sat, 2 Dec 2017 22:01:34 +0000 Subject: [PATCH] tests: robustify ipc_msgbuf.test against broken libc 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 | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/tests/ipc_msgbuf.c b/tests/ipc_msgbuf.c index d1083899..c4af1bef 100644 --- a/tests/ipc_msgbuf.c +++ b/tests/ipc_msgbuf.c @@ -38,11 +38,16 @@ 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(); } -- 2.40.0