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.
This commit is contained in:
parent
5f61f158c3
commit
a6e30c11d2
@ -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();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user