fix ipc tests which cast time_t to long for printing
authorSzabolcs Nagy <nsz@port70.net>
Wed, 1 Jan 2020 16:12:40 +0000 (16:12 +0000)
committerSzabolcs Nagy <nsz@port70.net>
Wed, 1 Jan 2020 16:12:40 +0000 (16:12 +0000)
use long long so the correct time is printed with 64bit time_t on 32bit targets.

src/functional/ipc_msg.c
src/functional/ipc_sem.c
src/functional/ipc_shm.c

index 9752a44..b243d6d 100644 (file)
@@ -61,12 +61,12 @@ static void snd()
        EQ(qid_ds.msg_qnum, 0, "got %d, want %d");
        EQ(qid_ds.msg_lspid, 0, "got %d, want %d");
        EQ(qid_ds.msg_lrpid, 0, "got %d, want %d");
        EQ(qid_ds.msg_qnum, 0, "got %d, want %d");
        EQ(qid_ds.msg_lspid, 0, "got %d, want %d");
        EQ(qid_ds.msg_lrpid, 0, "got %d, want %d");
-       EQ((long)qid_ds.msg_stime, 0, "got %ld, want %d");
-       EQ((long)qid_ds.msg_rtime, 0, "got %ld, want %d");
+       EQ((long long)qid_ds.msg_stime, 0, "got %lld, want %d");
+       EQ((long long)qid_ds.msg_rtime, 0, "got %lld, want %d");
        if (qid_ds.msg_ctime < t)
        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 %lld, want >= %lld\n", (long long)qid_ds.msg_ctime, (long long)t);
        if (qid_ds.msg_ctime > t+5)
        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);
+               t_error("qid_ds.msg_ctime <= t+5 failed: got %lld, want <= %lld\n", (long long)qid_ds.msg_ctime, (long long)t+5);
        if (qid_ds.msg_qbytes <= 0)
                t_error("qid_ds.msg_qbytes > 0 failed: got %d, want > 0\n", qid_ds.msg_qbytes, t);
 
        if (qid_ds.msg_qbytes <= 0)
                t_error("qid_ds.msg_qbytes > 0 failed: got %d, want > 0\n", qid_ds.msg_qbytes, t);
 
@@ -76,9 +76,9 @@ static void snd()
        EQ(qid_ds.msg_qnum, 1, "got %d, want %d");
        EQ(qid_ds.msg_lspid, getpid(), "got %d, want %d");
        if (qid_ds.msg_stime < t)
        EQ(qid_ds.msg_qnum, 1, "got %d, want %d");
        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);
+               t_error("msg_stime is %lld want >= %lld\n", (long long)qid_ds.msg_stime, (long long)t);
        if (qid_ds.msg_stime > t+5)
        if (qid_ds.msg_stime > t+5)
-               t_error("msg_stime is %ld want <= %ld\n", (long)qid_ds.msg_stime, (long)t+5);
+               t_error("msg_stime is %lld want <= %lld\n", (long long)qid_ds.msg_stime, (long long)t+5);
 }
 
 static void rcv()
 }
 
 static void rcv()
index 1b7cbda..077ea5c 100644 (file)
@@ -62,11 +62,11 @@ static void inc()
        EQ(semid_ds.sem_perm.gid, getegid(), "got %d, want %d");
        EQ(semid_ds.sem_perm.mode & 0x1ff, 0666, "got %o, want %o");
        EQ(semid_ds.sem_nsems, 1, "got %d, want %d");
        EQ(semid_ds.sem_perm.gid, getegid(), "got %d, want %d");
        EQ(semid_ds.sem_perm.mode & 0x1ff, 0666, "got %o, want %o");
        EQ(semid_ds.sem_nsems, 1, "got %d, want %d");
-       EQ((long)semid_ds.sem_otime, 0, "got %ld, want %d");
+       EQ((long long)semid_ds.sem_otime, 0, "got %lld, want %d");
        if (semid_ds.sem_ctime < t)
        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 %lld, want >= %lld\n", (long long)semid_ds.sem_ctime, (long long)t);
        if (semid_ds.sem_ctime > t+5)
        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);
+               t_error("semid_ds.sem_ctime <= t+5 failed: got %lld, want <= %lld\n", (long long)semid_ds.sem_ctime, (long long)t+5);
 
        /* test sem_op > 0 */
        sops.sem_num = 0;
 
        /* test sem_op > 0 */
        sops.sem_num = 0;
index 9807436..e2374b8 100644 (file)
@@ -59,12 +59,12 @@ static void set()
        EQ(shmid_ds.shm_lpid, 0, "got %d, want %d");
        EQ(shmid_ds.shm_cpid, getpid(), "got %d, want %d");
        EQ((int)shmid_ds.shm_nattch, 0, "got %d, want %d");
        EQ(shmid_ds.shm_lpid, 0, "got %d, want %d");
        EQ(shmid_ds.shm_cpid, getpid(), "got %d, want %d");
        EQ((int)shmid_ds.shm_nattch, 0, "got %d, want %d");
-       EQ((long)shmid_ds.shm_atime, 0, "got %ld, want %d");
-       EQ((long)shmid_ds.shm_dtime, 0, "got %ld, want %d");
+       EQ((long long)shmid_ds.shm_atime, 0, "got %lld, want %d");
+       EQ((long long)shmid_ds.shm_dtime, 0, "got %lld, want %d");
        if (shmid_ds.shm_ctime < t)
        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 %lld, want >= %lld\n", (long long)shmid_ds.shm_ctime, (long long)t);
        if (shmid_ds.shm_ctime > t+5)
        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);
+               t_error("shmid_ds.shm_ctime <= t+5 failed: got %lld, want <= %lld\n", (long long)shmid_ds.shm_ctime, (long long)t+5);
 
        /* test attach */
        if ((p=shmat(shmid, 0, 0)) == 0)
 
        /* test attach */
        if ((p=shmat(shmid, 0, 0)) == 0)
@@ -73,9 +73,9 @@ static void set()
        EQ((int)shmid_ds.shm_nattch, 1, "got %d, want %d");
        EQ(shmid_ds.shm_lpid, getpid(), "got %d, want %d");
        if (shmid_ds.shm_atime < t)
        EQ((int)shmid_ds.shm_nattch, 1, "got %d, want %d");
        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);
+               t_error("shm_atime is %lld want >= %lld\n", (long long)shmid_ds.shm_atime, (long long)t);
        if (shmid_ds.shm_atime > t+5)
        if (shmid_ds.shm_atime > t+5)
-               t_error("shm_atime is %ld want <= %ld\n", (long)shmid_ds.shm_atime, (long)t+5);
+               t_error("shm_atime is %lld want <= %lld\n", (long long)shmid_ds.shm_atime, (long long)t+5);
        strcpy(p, "test data");
        T(shmdt(p));
 }
        strcpy(p, "test data");
        T(shmdt(p));
 }