tests: unit: move the math_extra test to new ztest API
Migrate the testsuite tests/unit/math_extra to the new ztest API. Signed-off-by: Enjia Mai <enjia.mai@intel.com>
This commit is contained in:
parent
7133f34c1b
commit
513cd6989a
4 changed files with 86 additions and 38 deletions
|
@ -3,5 +3,5 @@
|
|||
cmake_minimum_required(VERSION 3.20.0)
|
||||
|
||||
project(math_extras)
|
||||
set(SOURCES main.c portable.c)
|
||||
set(SOURCES main.c)
|
||||
find_package(Zephyr COMPONENTS unittest REQUIRED HINTS $ENV{ZEPHYR_BASE})
|
||||
|
|
|
@ -5,27 +5,50 @@
|
|||
*/
|
||||
|
||||
/* Test the normal version of the math_extras.h functions */
|
||||
#define VNAME(N) test_##N
|
||||
#define VNAME(N) run_##N
|
||||
#include "tests.inc"
|
||||
|
||||
extern void test_portable_math_extras(void);
|
||||
|
||||
void test_main(void)
|
||||
{
|
||||
/* clang-format off */
|
||||
ztest_test_suite(test_math_extras,
|
||||
ztest_unit_test(test_u32_add),
|
||||
ztest_unit_test(test_u32_mul),
|
||||
ztest_unit_test(test_u64_add),
|
||||
ztest_unit_test(test_u64_mul),
|
||||
ztest_unit_test(test_size_add),
|
||||
ztest_unit_test(test_size_mul),
|
||||
ztest_unit_test(test_u32_clz),
|
||||
ztest_unit_test(test_u64_clz),
|
||||
ztest_unit_test(test_u32_ctz),
|
||||
ztest_unit_test(test_u64_ctz));
|
||||
ztest_run_test_suite(test_math_extras);
|
||||
/* clang-format on */
|
||||
|
||||
test_portable_math_extras();
|
||||
/* clang-format off */
|
||||
ZTEST(math_extras, test_u32_add) {
|
||||
run_u32_add();
|
||||
}
|
||||
|
||||
ZTEST(math_extras, test_u32_mul) {
|
||||
run_u32_mul();
|
||||
}
|
||||
|
||||
ZTEST(math_extras, test_u64_add) {
|
||||
run_u64_add();
|
||||
}
|
||||
|
||||
ZTEST(math_extras, test_u64_mul) {
|
||||
run_u64_mul();
|
||||
}
|
||||
|
||||
ZTEST(math_extras, test_size_add) {
|
||||
run_size_add();
|
||||
}
|
||||
|
||||
ZTEST(math_extras, test_size_mul) {
|
||||
run_size_mul();
|
||||
}
|
||||
|
||||
ZTEST(math_extras, test_u32_clz) {
|
||||
run_u32_clz();
|
||||
}
|
||||
|
||||
ZTEST(math_extras, test_u64_clz) {
|
||||
run_u64_clz();
|
||||
}
|
||||
|
||||
ZTEST(math_extras, test_u32_ctz) {
|
||||
run_u32_ctz();
|
||||
}
|
||||
|
||||
ZTEST(math_extras, test_u64_ctz) {
|
||||
run_u64_ctz();
|
||||
}
|
||||
|
||||
/* clang-format on */
|
||||
|
||||
ZTEST_SUITE(math_extras, NULL, NULL, NULL, NULL, NULL);
|
||||
|
|
|
@ -9,20 +9,44 @@
|
|||
#define VNAME(N) test_portable_##N
|
||||
#include "tests.inc"
|
||||
|
||||
void test_portable_math_extras(void)
|
||||
{
|
||||
/* clang-format off */
|
||||
ztest_test_suite(test_portable_math_extras,
|
||||
ztest_unit_test(test_portable_u32_add),
|
||||
ztest_unit_test(test_portable_u32_mul),
|
||||
ztest_unit_test(test_portable_u64_add),
|
||||
ztest_unit_test(test_portable_u64_mul),
|
||||
ztest_unit_test(test_portable_size_add),
|
||||
ztest_unit_test(test_portable_size_mul),
|
||||
ztest_unit_test(test_portable_u32_clz),
|
||||
ztest_unit_test(test_portable_u64_clz),
|
||||
ztest_unit_test(test_portable_u32_ctz),
|
||||
ztest_unit_test(test_portable_u64_ctz));
|
||||
ztest_run_test_suite(test_portable_math_extras);
|
||||
/* clang-format on */
|
||||
ZTEST(math_extras_portable, test_portable_u32_add) {
|
||||
run_portable_u32_add();
|
||||
}
|
||||
|
||||
ZTEST(math_extras_portable, test_portable_u32_mul) {
|
||||
run_portable_u32_mul();
|
||||
}
|
||||
|
||||
ZTEST(math_extras_portable, test_portable_u64_add) {
|
||||
run_portable_u64_add();
|
||||
}
|
||||
|
||||
ZTEST(math_extras_portable, test_portable_u64_mul) {
|
||||
run_portable_u64_mul();
|
||||
}
|
||||
|
||||
ZTEST(math_extras_portable, test_portable_size_add) {
|
||||
run_portable_size_add();
|
||||
}
|
||||
|
||||
ZTEST(math_extras_portable, test_portable_size_mul) {
|
||||
run_portable_size_mul();
|
||||
}
|
||||
|
||||
ZTEST(math_extras_portable, test_portable_u32_clz) {
|
||||
run_portable_u32_clz();
|
||||
}
|
||||
|
||||
ZTEST(math_extras_portable, test_portable_u64_clz) {
|
||||
run_portable_u64_clz();
|
||||
}
|
||||
|
||||
ZTEST(math_extras_portable, test_portable_u32_ctz) {
|
||||
run_portable_u32_ctz();
|
||||
}
|
||||
|
||||
ZTEST(math_extras_portable, test_portable_u64_ctz) {
|
||||
run_portable_u64_ctz();
|
||||
}
|
||||
|
||||
ZTEST_SUITE(math_extras_portable, NULL, NULL, NULL, NULL, NULL);
|
||||
|
|
1
tests/unit/math_extras/prj.conf
Normal file
1
tests/unit/math_extras/prj.conf
Normal file
|
@ -0,0 +1 @@
|
|||
CONFIG_ZTEST_NEW_API=y
|
Loading…
Add table
Add a link
Reference in a new issue