Commit 513cd698 authored by Enjia Mai's avatar Enjia Mai Committed by Carles Cufi
Browse files

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: default avatarEnjia Mai <enjia.mai@intel.com>
parent 7133f34c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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})
+44 −21
Original line number Diff line number Diff line
@@ -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 */
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();
}

	test_portable_math_extras();
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);
+40 −16
Original line number Diff line number Diff line
@@ -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 −0
Original line number Diff line number Diff line
CONFIG_ZTEST_NEW_API=y