Skip to content

Commit 42d3631

Browse files
xuyang0410metan-ucw
authored andcommitted
syscalls/msgsnd01: Add check for msg_lspid and msg_stime
Signed-off-by: Yang Xu <[email protected]> Signed-off-by: Cyril Hrubis <[email protected]>
1 parent 934c12c commit 42d3631

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

testcases/kernel/syscalls/ipc/msgsnd/msgsnd01.c

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include "libnewipc.h"
1919

2020
static key_t msgkey;
21-
static int queue_id = -1;
21+
static int queue_id = -1, pid;
2222
static struct buf {
2323
long type;
2424
char text[MSGSIZE];
@@ -27,12 +27,15 @@ static struct buf {
2727
static void verify_msgsnd(void)
2828
{
2929
struct msqid_ds qs_buf;
30+
time_t before_snd, after_snd;
3031

32+
time(&before_snd);
3133
TEST(msgsnd(queue_id, &snd_buf, MSGSIZE, 0));
3234
if (TST_RET == -1) {
3335
tst_res(TFAIL | TTERRNO, "msgsnd() failed");
3436
return;
3537
}
38+
time(&after_snd);
3639

3740
SAFE_MSGCTL(queue_id, IPC_STAT, &qs_buf);
3841

@@ -41,14 +44,29 @@ static void verify_msgsnd(void)
4144
else
4245
tst_res(TFAIL, "queue bytes or number of queues mismatched");
4346

47+
if (qs_buf.msg_lspid == pid)
48+
tst_res(TPASS, "PID of last msgsnd(2) matched");
49+
else
50+
tst_res(TFAIL, "PID of last msgsnd(2) mismatched");
51+
52+
if (qs_buf.msg_stime >= before_snd && qs_buf.msg_stime <= after_snd) {
53+
tst_res(TPASS, "msg_stime = %lu in [%lu, %lu]",
54+
(unsigned long)qs_buf.msg_stime,
55+
(unsigned long)before_snd, (unsigned long)after_snd);
56+
} else {
57+
tst_res(TFAIL, "msg_stime = %lu out of [%lu, %lu]",
58+
(unsigned long)qs_buf.msg_stime,
59+
(unsigned long)before_snd, (unsigned long)after_snd);
60+
}
61+
4462
SAFE_MSGRCV(queue_id, &rcv_buf, MSGSIZE, 1, 0);
4563
}
4664

4765
static void setup(void)
4866
{
4967
msgkey = GETIPCKEY();
50-
5168
queue_id = SAFE_MSGGET(msgkey, IPC_CREAT | IPC_EXCL | MSG_RW);
69+
pid = getpid();
5270
}
5371

5472
static void cleanup(void)

0 commit comments

Comments
 (0)