diff options
author | Dmitry V. Levin <ldv@altlinux.org> | 2017-12-02 22:01:34 +0000 |
---|---|---|
committer | Dmitry V. Levin <ldv@altlinux.org> | 2017-12-03 00:25:43 +0000 |
commit | a6e30c11d24c3387d60df668d951ea5af390ea11 (patch) | |
tree | b57b91d311b6c3e68f9801dff20fc45fe0815e9b | |
parent | 5f61f158c3680e003b81bb9e311358ab842b0de1 (diff) | |
download | strace-a6e30c11d24c3387d60df668d951ea5af390ea11.tar.gz |
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.
-rw-r--r-- | tests/ipc_msgbuf.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/tests/ipc_msgbuf.c b/tests/ipc_msgbuf.c index d1083899b..c4af1bef3 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(); } |