1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * Copyright (c) 2020 Viresh Kumar <viresh.kumar@linaro.org>
4 *
5 * Description:
6 * Cross verify the _high fields being set to 0 by the kernel.
7 */
8 #include <sys/msg.h>
9 #include "lapi/msgbuf.h"
10 #include "libnewipc.h"
11 #include "tst_test.h"
12 #include "tst_safe_sysv_ipc.h"
13
14 #ifdef HAVE_MSQID64_DS_TIME_HIGH
15
run(void)16 static void run(void)
17 {
18 struct msqid64_ds buf_ds = {
19 .msg_stime_high = 0x0A0A,
20 .msg_rtime_high = 0x0A0A,
21 .msg_ctime_high = 0x0A0A,
22 };
23 int msqid;
24 key_t key;
25
26 key = GETIPCKEY();
27
28 msqid = SAFE_MSGGET(key, IPC_CREAT | IPC_EXCL | MSG_RW | 0600);
29
30 TEST(msgctl(msqid, IPC_STAT, (struct msqid_ds *)&buf_ds));
31 if (TST_RET == -1)
32 tst_brk(TFAIL | TTERRNO, "msqctl() failed");
33
34 if (buf_ds.msg_stime_high || buf_ds.msg_rtime_high || buf_ds.msg_ctime_high)
35 tst_res(TFAIL, "time_high fields aren't cleared by the kernel");
36 else
37 tst_res(TPASS, "time_high fields cleared by the kernel");
38
39 SAFE_MSGCTL(msqid, IPC_RMID, NULL);
40 }
41
42 static struct tst_test test = {
43 .test_all = run,
44 .needs_tmpdir = 1,
45 };
46 #else
47 TST_TEST_TCONF("test requires struct msqid64_ds to have the time_high fields");
48 #endif
49