aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHanspeter Portner <dev@open-music-kontrollers.ch>2018-05-17 23:17:29 +0200
committerHanspeter Portner <dev@open-music-kontrollers.ch>2018-05-17 23:33:12 +0200
commitd148bbaa271ff8ad2ad4d128c6270313ef1aa79f (patch)
treecb04f0203194effa10bd46f4e89db9efad358437
parent8da759794da6eded891114789ee5a8046f689549 (diff)
downloadvarchunk-d148bbaa271ff8ad2ad4d128c6270313ef1aa79f.tar.xz
fix test on mingw.
-rw-r--r--.gitlab-ci.yml2
-rw-r--r--test_varchunk.c32
2 files changed, 20 insertions, 14 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 5cca800..0501fcc 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -34,7 +34,7 @@ stages:
.universal_w64_template: &universal_w64_definition
image: ventosus/universal-w64-mingw32
- <<: *test_definition
+ <<: *build_definition
.universal_apple_template: &universal_apple_definition
image: ventosus/universal-apple-darwin
diff --git a/test_varchunk.c b/test_varchunk.c
index e66edc7..1cce435 100644
--- a/test_varchunk.c
+++ b/test_varchunk.c
@@ -30,24 +30,16 @@
# include <fcntl.h>
# include <string.h>
# define VARCHUNK_USE_SHARED_MEM
-#endif
-
-static uint64_t iterations = 10000000;
-#define THRESHOLD (RAND_MAX / 256)
-#define PAD(SIZE) ( ( (size_t)(SIZE) + 7U ) & ( ~7U ) )
static const struct timespec req = {
.tv_sec = 0,
.tv_nsec = 1
};
+#endif
-typedef struct _varchunk_shm_t varchunk_shm_t;
-
-struct _varchunk_shm_t {
- char *name;
- int fd;
- varchunk_t *varchunk;
-};
+static uint64_t iterations = 10000000;
+#define THRESHOLD (RAND_MAX / 256)
+#define PAD(SIZE) ( ( (size_t)(SIZE) + 7U ) & ( ~7U ) )
static void *
producer_main(void *arg)
@@ -60,10 +52,12 @@ producer_main(void *arg)
while(cnt < iterations)
{
+#if !defined(_WIN32)
if(rand() < THRESHOLD)
{
nanosleep(&req, NULL);
}
+#endif
written = PAD(rand() * 1024.f / RAND_MAX);
@@ -100,10 +94,12 @@ consumer_main(void *arg)
while(cnt < iterations)
{
+#if !defined(_WIN32)
if(rand() < THRESHOLD)
{
nanosleep(&req, NULL);
}
+#endif
if( (ptr = varchunk_read_request(varchunk, &toread)) )
{
@@ -141,6 +137,15 @@ test_threaded()
varchunk_free(varchunk);
}
+#if defined(VARCHUNK_USE_SHARED_MEM)
+typedef struct _varchunk_shm_t varchunk_shm_t;
+
+struct _varchunk_shm_t {
+ char *name;
+ int fd;
+ varchunk_t *varchunk;
+};
+
static int
varchunk_shm_init(varchunk_shm_t *varchunk_shm, const char *name, size_t minimum, bool release_and_acquire)
{
@@ -195,7 +200,6 @@ varchunk_shm_deinit(varchunk_shm_t *varchunk_shm)
free(varchunk_shm->name);
}
-#if defined(VARCHUNK_USE_SHARED_MEM)
static void
test_shared()
{
@@ -228,8 +232,10 @@ test_shared()
int
main(int argc, char **argv)
{
+#if !defined(_WIN32)
const int seed = time(NULL);
srand(seed);
+#endif
if(argc >= 2)
{