18
18
#include "libnewipc.h"
19
19
20
20
static key_t msgkey ;
21
- static int queue_id = -1 ;
21
+ static int queue_id = -1 , pid ;
22
22
static struct buf {
23
23
long type ;
24
24
char text [MSGSIZE ];
@@ -27,12 +27,15 @@ static struct buf {
27
27
static void verify_msgsnd (void )
28
28
{
29
29
struct msqid_ds qs_buf ;
30
+ time_t before_snd , after_snd ;
30
31
32
+ time (& before_snd );
31
33
TEST (msgsnd (queue_id , & snd_buf , MSGSIZE , 0 ));
32
34
if (TST_RET == -1 ) {
33
35
tst_res (TFAIL | TTERRNO , "msgsnd() failed" );
34
36
return ;
35
37
}
38
+ time (& after_snd );
36
39
37
40
SAFE_MSGCTL (queue_id , IPC_STAT , & qs_buf );
38
41
@@ -41,14 +44,29 @@ static void verify_msgsnd(void)
41
44
else
42
45
tst_res (TFAIL , "queue bytes or number of queues mismatched" );
43
46
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
+
44
62
SAFE_MSGRCV (queue_id , & rcv_buf , MSGSIZE , 1 , 0 );
45
63
}
46
64
47
65
static void setup (void )
48
66
{
49
67
msgkey = GETIPCKEY ();
50
-
51
68
queue_id = SAFE_MSGGET (msgkey , IPC_CREAT | IPC_EXCL | MSG_RW );
69
+ pid = getpid ();
52
70
}
53
71
54
72
static void cleanup (void )
0 commit comments