1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

tests: fix portability issues for running the tests on OS X/BSD

This commit is contained in:
Steffen Vogel 2018-01-31 09:40:08 +01:00
parent 8847f45959
commit a1a4e0ea7e
4 changed files with 18 additions and 3 deletions

View file

@ -138,7 +138,7 @@ void cr_assert_eq_samples(struct io_format *f, struct sample *smps[], struct sam
cr_assert_float_eq(smps[i]->data[j].f, smpt[i]->data[j].f, 1e-3, "Sample data mismatch at index %d: %f != %f", j, smps[i]->data[j].f, smpt[i]->data[j].f);
break;
case SAMPLE_DATA_FORMAT_INT:
cr_assert_eq(smps[i]->data[j].i, smpt[i]->data[j].i, "Sample data mismatch at index %d: %d != %d", j, smps[i]->data[j].i, smpt[i]->data[j].i);
cr_assert_eq(smps[i]->data[j].i, smpt[i]->data[j].i, "Sample data mismatch at index %d: %lld != %lld", j, smps[i]->data[j].i, smpt[i]->data[j].i);
break;
}
}

View file

@ -25,6 +25,8 @@
#include "kernel/kernel.h"
#include "utils.h"
#ifdef __linux__
/* This test is not portable, but we currently support x86 only */
Test(kernel, sizes)
{
@ -84,3 +86,5 @@ Test(kernel, module, .disabled = true)
ret = kernel_module_loaded("does_not_exist");
cr_assert_neq(ret, 0);
}
#endif /* __linux__ */

View file

@ -39,7 +39,9 @@
static struct queue q = { .state = STATE_DESTROYED };
#if defined(_POSIX_BARRIERS) && _POSIX_BARRIERS > 0
static pthread_barrier_t barrier;
#endif
struct param {
int volatile start;
@ -87,6 +89,9 @@ static void * producer(void *ctx)
/** @todo Criterion cr_log() is broken for multi-threaded programs */
//cr_log_info("producer: tid = %lu", thread_get_id());
#ifdef __APPLE__
#define pthread_yield pthread_yield_np
#endif
/* Wait for global start signal */
while (p->start == 0)
pthread_yield();
@ -152,6 +157,7 @@ static void * consumer(void *ctx)
return NULL;
}
#if defined(_POSIX_BARRIERS) && _POSIX_BARRIERS > 0
void * producer_consumer(void *ctx)
{
struct param *p = ctx;
@ -226,6 +232,7 @@ void * producer_consumer_many(void *ctx)
return 0;
}
#endif /* _POSIX_BARRIERS */
Test(queue, single_threaded)
{
@ -248,6 +255,7 @@ Test(queue, single_threaded)
cr_assert_eq(ret, 0, "Failed to create queue");
}
#if defined(_POSIX_BARRIERS) && _POSIX_BARRIERS > 0
ParameterizedTestParameters(queue, multi_threaded)
{
static struct param params[] = {
@ -331,10 +339,11 @@ ParameterizedTest(struct param *p, queue, multi_threaded, .timeout = 20)
ret = queue_destroy(&p->queue);
cr_assert_eq(ret, 0, "Failed to destroy queue");
ret = pthread_barrier_destroy(&barrier);
cr_assert_eq(ret, 0, "Failed to destroy barrier");
}
#endif /* _POSIX_BARRIERS */
Test(queue, init_destroy)
{
@ -346,4 +355,4 @@ Test(queue, init_destroy)
ret = queue_destroy(&q);
cr_assert_eq(ret, 0); /* Should succeed */
}
}

View file

@ -55,6 +55,7 @@ Test(utils, box_muller)
cr_assert_float_eq((double) sigma[0] / iter, 0.682829, 1e-2);
}
#ifdef __linux__
Test(utils, cpuset)
{
int ret;
@ -78,6 +79,7 @@ Test(utils, cpuset)
cr_assert_eq(int1, int2);
}
#endif /* __linux__ */
Test(utils, memdup)
{