X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Ffunctional%2Fipc_sem.c;h=1b7cbda9b3a78fd032882342d24b4027cde9a3e2;hb=2064be16d307b6409cd518303897cd0763cfdb97;hp=8f695865adfe5e15ec24e75d0600d6ebeb436aa3;hpb=2cf89517c5b25c2524fe0c0c01ed277d7307a852;p=libc-test diff --git a/src/functional/ipc_sem.c b/src/functional/ipc_sem.c index 8f69586..1b7cbda 100644 --- a/src/functional/ipc_sem.c +++ b/src/functional/ipc_sem.c @@ -12,16 +12,16 @@ #include "test.h" static const char path[] = "."; -static const int id = 'x'; +static const int id = 's'; #define T(f) do{ \ if ((f)+1 == 0) \ - error("%s failed: %s\n", #f, strerror(errno)); \ + t_error("%s failed: %s\n", #f, strerror(errno)); \ }while(0) #define EQ(a,b,fmt) do{ \ if ((a) != (b)) \ - error("%s == %s failed: " fmt "\n", #a, #b, a, b); \ + t_error("%s == %s failed: " fmt "\n", #a, #b, a, b); \ }while(0) static void inc() @@ -45,13 +45,13 @@ static void inc() T(semctl(semid, 0, IPC_RMID)); T(semid = semget(k, 1, IPC_CREAT|IPC_EXCL|0666)); - if (test_status) - exit(test_status); + if (t_status) + exit(t_status); /* check IPC_EXCL */ errno = 0; if (semget(k, 1, IPC_CREAT|IPC_EXCL|0666) != -1 || errno != EEXIST) - error("semget(IPC_CREAT|IPC_EXCL) should have failed with EEXIST, got %s\n", strerror(errno)); + t_error("semget(IPC_CREAT|IPC_EXCL) should have failed with EEXIST, got %s\n", strerror(errno)); /* check if msgget initilaized the msqid_ds structure correctly */ arg.buf = &semid_ds; @@ -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) - 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; @@ -110,14 +112,14 @@ int main(void) inc(); p = fork(); if (p == -1) - error("fork failed: %s\n", strerror(errno)); + t_error("fork failed: %s\n", strerror(errno)); else if (p == 0) dec(); else { T(waitpid(p, &status, 0)); if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) - error("child exit status: %d\n", status); + t_error("child exit status: %d\n", status); } - return test_status; + return t_status; }