diff options
Diffstat (limited to 'source/tests')
-rw-r--r-- | source/tests/test_interprocess.c | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/source/tests/test_interprocess.c b/source/tests/test_interprocess.c index 30a8779..fece68f 100644 --- a/source/tests/test_interprocess.c +++ b/source/tests/test_interprocess.c @@ -3,24 +3,20 @@ #include <stdio.h> -#ifdef _WIN32 -int main() { - return 0; -} -#else -# define NAME "kit_test_interprocess" +#define NAME "kit_test_interprocess" enum { SIZE = 64 }; enum { STATE_INIT, STATE_READY, STATE_DONE }; int run_writer() { - kit_shared_memory_t mem = kit_shared_memory_create(SZ(NAME), SIZE); + kit_shared_memory_t mem = kit_shared_memory_open( + SZ(NAME), SIZE, KIT_SHARED_MEMORY_CREATE); if (mem.status != KIT_OK) { - printf("%s: kit_shared_memory_create failed.\n", __FUNCTION__); + printf("%s: kit_shared_memory_open failed.\n", __FUNCTION__); fflush(stdout); - return mem.status; + return 1; } mem.bytes[0] = STATE_INIT; @@ -33,12 +29,19 @@ int run_writer() { } int run_reader() { - kit_shared_memory_t mem = kit_shared_memory_open(SZ(NAME), SIZE); + kit_shared_memory_t mem; + for (;;) { + mem = kit_shared_memory_open(SZ(NAME), SIZE, + KIT_SHARED_MEMORY_OPEN); + if (mem.status == KIT_OK) + break; + thrd_yield(); + } if (mem.status != KIT_OK) { printf("%s: kit_shared_memory_open failed.\n", __FUNCTION__); fflush(stdout); - return mem.status; + return 1; } while (mem.bytes[0] != STATE_READY) thrd_yield(); @@ -54,7 +57,8 @@ int run_reader() { mem.bytes[0] = STATE_DONE; - status |= kit_shared_memory_close(&mem); + if (kit_shared_memory_close(&mem) != KIT_OK) + status = 1; return status; } @@ -90,4 +94,3 @@ int main(int argc, char **argv) { printf("Invalid command line argument \"%s\"\n", argv[1]); return 1; } -#endif |