mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
tests: improve several unit tests
This commit is contained in:
parent
b938c939cd
commit
62fbb55e2c
3 changed files with 28 additions and 13 deletions
|
@ -28,9 +28,8 @@
|
|||
#include <villas/config_helper.h>
|
||||
|
||||
struct param {
|
||||
const char *desc;
|
||||
const char *json;
|
||||
char *argv[32];
|
||||
const char *json;
|
||||
};
|
||||
|
||||
ParameterizedTestParameters(json, json_load_cli)
|
||||
|
|
|
@ -27,19 +27,32 @@
|
|||
|
||||
#ifdef __linux__
|
||||
|
||||
#if defined(__x86_64__) || defined(__i386__)
|
||||
#define PAGESIZE (1 << 12)
|
||||
#define CACHELINESIZE 64
|
||||
|
||||
#if defined(__x86_64__)
|
||||
#define HUGEPAGESIZE (1 << 21)
|
||||
#elif defined(__i386__)
|
||||
#define HUGEPAGESIZE (1 << 22)
|
||||
#endif
|
||||
#else
|
||||
#error "Unsupported architecture"
|
||||
#endif
|
||||
|
||||
/* This test is not portable, but we currently support x86 only */
|
||||
Test(kernel, sizes)
|
||||
{
|
||||
int sz;
|
||||
|
||||
sz = kernel_get_page_size();
|
||||
cr_assert_eq(sz, 1 << 12);
|
||||
cr_assert_eq(sz, PAGESIZE);
|
||||
|
||||
sz = kernel_get_hugepage_size();
|
||||
cr_assert(sz == 1 << 22 || sz == 1 << 21);
|
||||
cr_assert(sz == HUGEPAGESIZE);
|
||||
|
||||
sz = kernel_get_cacheline_size();
|
||||
cr_assert_eq(sz, 64);
|
||||
cr_assert_eq(sz, CACHELINESIZE);
|
||||
}
|
||||
|
||||
Test(kernel, hugepages)
|
||||
|
@ -57,7 +70,6 @@ Test(kernel, hugepages)
|
|||
|
||||
ret = kernel_get_nr_hugepages();
|
||||
cr_assert_eq(ret, 10);
|
||||
|
||||
}
|
||||
|
||||
Test(kernel, version)
|
||||
|
|
|
@ -27,13 +27,17 @@
|
|||
|
||||
#include <villas/memory.h>
|
||||
#include <villas/utils.h>
|
||||
#include <villas/log.h>
|
||||
|
||||
#define HUGEPAGESIZE (1 << 22)
|
||||
extern void init_memory();
|
||||
|
||||
#define PAGESIZE (1 << 12)
|
||||
#define HUGEPAGESIZE (1 << 21)
|
||||
|
||||
TheoryDataPoints(memory, aligned) = {
|
||||
DataPoints(size_t, 1, 32, 55, 1 << 10, 1 << 20),
|
||||
DataPoints(size_t, 1, 8, 1 << 12),
|
||||
DataPoints(struct memory_type *, &memory_type_heap, &memory_hugepage)
|
||||
DataPoints(size_t, 1, 32, 55, 1 << 10, PAGESIZE, HUGEPAGESIZE),
|
||||
DataPoints(size_t, 1, 8, PAGESIZE, PAGESIZE),
|
||||
DataPoints(struct memory_type *, &memory_heap, &memory_hugepage, &memory_hugepage)
|
||||
};
|
||||
|
||||
Theory((size_t len, size_t align, struct memory_type *m), memory, aligned, .init = init_memory) {
|
||||
|
@ -41,12 +45,12 @@ Theory((size_t len, size_t align, struct memory_type *m), memory, aligned, .init
|
|||
void *ptr;
|
||||
|
||||
ptr = memory_alloc_aligned(m, len, align);
|
||||
cr_assert_neq(ptr, NULL, "Failed to allocate memory");
|
||||
cr_assert_not_null(ptr, "Failed to allocate memory");
|
||||
|
||||
cr_assert(IS_ALIGNED(ptr, align));
|
||||
cr_assert(IS_ALIGNED(ptr, align), "Memory at %p is not alligned to %#zx byte bounary", ptr, align);
|
||||
|
||||
if (m == &memory_hugepage) {
|
||||
cr_assert(IS_ALIGNED(ptr, HUGEPAGESIZE));
|
||||
cr_assert(IS_ALIGNED(ptr, HUGEPAGESIZE), "Memory at %p is not alligned to %#x byte bounary", ptr, HUGEPAGESIZE);
|
||||
}
|
||||
|
||||
ret = memory_free(ptr);
|
||||
|
|
Loading…
Add table
Reference in a new issue