aboutsummaryrefslogtreecommitdiff
path: root/tests/semtest.c
diff options
context:
space:
mode:
authortoni <matzeton@googlemail.com>2015-11-16 23:56:07 +0100
committertoni <matzeton@googlemail.com>2015-11-17 01:04:39 +0100
commitcb8ac81c8c538f4a02edb5c2762cfbc5f5adef88 (patch)
tree8a305bfa89f406a89e6b3e4fbd286bf242a72920 /tests/semtest.c
parent089551924a7c6bae2b03bee9999e5563f9267571 (diff)
better tests
Diffstat (limited to 'tests/semtest.c')
-rw-r--r--tests/semtest.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/tests/semtest.c b/tests/semtest.c
index f462a6e..fdecf2d 100644
--- a/tests/semtest.c
+++ b/tests/semtest.c
@@ -6,6 +6,7 @@
#include <sys/types.h>
#include <sys/wait.h>
#include <fcntl.h>
+#include <assert.h>
#include "semconfig.h"
@@ -19,11 +20,11 @@ int main(int argc, char **argv) {
if ( (mysem = sem_open(TESTSEM, O_CREAT | O_EXCL, S_IRUSR | S_IWUSR, 0)) != NULL ) {
if ( (child = fork()) == 0 ) {
/* child */
- sleep(1);
+ usleep(250);
LOG("child: sempost");
sem_post(mysem);
LOG("child: done");
- sleep(1);
+ usleep(250);
exit(0);
} else if (child > 0) {
/* parent */
@@ -38,6 +39,11 @@ int main(int argc, char **argv) {
sem_close(mysem);
exit(1);
}
+
+ int sval;
+ assert ( sem_getvalue(mysem, &sval) == 0 );
+ assert (sval == 0);
+
sem_unlink(TESTSEM);
exit(0);
}