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