ipc tests: check time intervals (with upper bound)
authorSzabolcs Nagy <nsz@port70.net>
Thu, 15 Aug 2013 18:16:42 +0000 (18:16 +0000)
committerSzabolcs Nagy <nsz@port70.net>
Thu, 15 Aug 2013 18:16:42 +0000 (18:16 +0000)
src/functional/ipc_msg.c
src/functional/ipc_sem.c
src/functional/ipc_shm.c

index c387362..9752a44 100644 (file)
@@ -64,9 +64,11 @@ static void snd()
        EQ((long)qid_ds.msg_stime, 0, "got %ld, want %d");
        EQ((long)qid_ds.msg_rtime, 0, "got %ld, want %d");
        if (qid_ds.msg_ctime < t)
        EQ((long)qid_ds.msg_stime, 0, "got %ld, want %d");
        EQ((long)qid_ds.msg_rtime, 0, "got %ld, want %d");
        if (qid_ds.msg_ctime < t)
-               t_error("qid_ds.msg_ctime >= t failed: got %ld, want %ld\n", (long)qid_ds.msg_ctime, (long)t);
+               t_error("qid_ds.msg_ctime >= t failed: got %ld, want >= %ld\n", (long)qid_ds.msg_ctime, (long)t);
+       if (qid_ds.msg_ctime > t+5)
+               t_error("qid_ds.msg_ctime <= t+5 failed: got %ld, want <= %ld\n", (long)qid_ds.msg_ctime, (long)t+5);
        if (qid_ds.msg_qbytes <= 0)
        if (qid_ds.msg_qbytes <= 0)
-               t_error("qid_ds.msg_qbytes > 0 failed: got %d, want 0\n", qid_ds.msg_qbytes, t);
+               t_error("qid_ds.msg_qbytes > 0 failed: got %d, want 0\n", qid_ds.msg_qbytes, t);
 
        /* test send */
        T(msgsnd(qid, &msg, sizeof msg.data, IPC_NOWAIT));
 
        /* test send */
        T(msgsnd(qid, &msg, sizeof msg.data, IPC_NOWAIT));
@@ -75,6 +77,8 @@ static void snd()
        EQ(qid_ds.msg_lspid, getpid(), "got %d, want %d");
        if (qid_ds.msg_stime < t)
                t_error("msg_stime is %ld want >= %ld\n", (long)qid_ds.msg_stime, (long)t);
        EQ(qid_ds.msg_lspid, getpid(), "got %d, want %d");
        if (qid_ds.msg_stime < t)
                t_error("msg_stime is %ld want >= %ld\n", (long)qid_ds.msg_stime, (long)t);
+       if (qid_ds.msg_stime > t+5)
+               t_error("msg_stime is %ld want <= %ld\n", (long)qid_ds.msg_stime, (long)t+5);
 }
 
 static void rcv()
 }
 
 static void rcv()
index 7c979f4..1b7cbda 100644 (file)
@@ -64,7 +64,9 @@ static void inc()
        EQ(semid_ds.sem_nsems, 1, "got %d, want %d");
        EQ((long)semid_ds.sem_otime, 0, "got %ld, want %d");
        if (semid_ds.sem_ctime < t)
        EQ(semid_ds.sem_nsems, 1, "got %d, want %d");
        EQ((long)semid_ds.sem_otime, 0, "got %ld, want %d");
        if (semid_ds.sem_ctime < t)
-               t_error("semid_ds.sem_ctime >= t failed: got %ld, want %ld\n", (long)semid_ds.sem_ctime, (long)t);
+               t_error("semid_ds.sem_ctime >= t failed: got %ld, want >= %ld\n", (long)semid_ds.sem_ctime, (long)t);
+       if (semid_ds.sem_ctime > t+5)
+               t_error("semid_ds.sem_ctime <= t+5 failed: got %ld, want <= %ld\n", (long)semid_ds.sem_ctime, (long)t+5);
 
        /* test sem_op > 0 */
        sops.sem_num = 0;
 
        /* test sem_op > 0 */
        sops.sem_num = 0;
index 2c87e2c..9807436 100644 (file)
@@ -62,7 +62,9 @@ static void set()
        EQ((long)shmid_ds.shm_atime, 0, "got %ld, want %d");
        EQ((long)shmid_ds.shm_dtime, 0, "got %ld, want %d");
        if (shmid_ds.shm_ctime < t)
        EQ((long)shmid_ds.shm_atime, 0, "got %ld, want %d");
        EQ((long)shmid_ds.shm_dtime, 0, "got %ld, want %d");
        if (shmid_ds.shm_ctime < t)
-               t_error("shmid_ds.shm_ctime >= t failed: got %ld, want %ld\n", (long)shmid_ds.shm_ctime, (long)t);
+               t_error("shmid_ds.shm_ctime >= t failed: got %ld, want >= %ld\n", (long)shmid_ds.shm_ctime, (long)t);
+       if (shmid_ds.shm_ctime > t+5)
+               t_error("shmid_ds.shm_ctime <= t+5 failed: got %ld, want <= %ld\n", (long)shmid_ds.shm_ctime, (long)t+5);
 
        /* test attach */
        if ((p=shmat(shmid, 0, 0)) == 0)
 
        /* test attach */
        if ((p=shmat(shmid, 0, 0)) == 0)
@@ -72,6 +74,8 @@ static void set()
        EQ(shmid_ds.shm_lpid, getpid(), "got %d, want %d");
        if (shmid_ds.shm_atime < t)
                t_error("shm_atime is %ld want >= %ld\n", (long)shmid_ds.shm_atime, (long)t);
        EQ(shmid_ds.shm_lpid, getpid(), "got %d, want %d");
        if (shmid_ds.shm_atime < t)
                t_error("shm_atime is %ld want >= %ld\n", (long)shmid_ds.shm_atime, (long)t);
+       if (shmid_ds.shm_atime > t+5)
+               t_error("shm_atime is %ld want <= %ld\n", (long)shmid_ds.shm_atime, (long)t+5);
        strcpy(p, "test data");
        T(shmdt(p));
 }
        strcpy(p, "test data");
        T(shmdt(p));
 }