From b938c939cdfc858c64bfe3be043c314de46da316 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Mon, 13 Aug 2018 15:23:14 +0200 Subject: [PATCH] tests: added some more unit tests --- tests/unit/kernel.c | 12 ++++++++++++ tests/unit/utils.c | 13 +++++++++++++ 2 files changed, 25 insertions(+) diff --git a/tests/unit/kernel.c b/tests/unit/kernel.c index b2812f299..e4f05ddfe 100644 --- a/tests/unit/kernel.c +++ b/tests/unit/kernel.c @@ -87,4 +87,16 @@ Test(kernel, module, .disabled = true) cr_assert_neq(ret, 0); } +Test(kernel, frequency) +{ + int ret; + uint64_t freq; + + ret = kernel_get_cpu_frequency(&freq); + cr_assert_eq(ret, 0); + + /* Check for plausability only */ + cr_assert(freq > 1e9 && freq < 5e9); +} + #endif /* __linux__ */ diff --git a/tests/unit/utils.c b/tests/unit/utils.c index 758a12710..5faa58d3e 100644 --- a/tests/unit/utils.c +++ b/tests/unit/utils.c @@ -129,6 +129,19 @@ Test(utils, is_pow2) cr_assert(!IS_POW2(-1)); } +Test(utils, strf) +{ + char *buf = NULL; + + buf = strf("Hallo %s", "Steffen."); + cr_assert_str_eq(buf, "Hallo Steffen."); + + strcatf(&buf, " Its Monday %uth %s %u.", 13, "August", 2018); + cr_assert_str_eq(buf, "Hallo Steffen. Its Monday 13th August 2018."); + + free(buf); +} + struct version_param { const char *v1, *v2; int result;