tests: kernel: spinlock: move to new ztest API
Move test to use new ztest API.
Signed-off-by: Guo Lixin <lixinx.guo@intel.com>
diff --git a/tests/kernel/spinlock/prj.conf b/tests/kernel/spinlock/prj.conf
index d57293f..4ebad0e 100644
--- a/tests/kernel/spinlock/prj.conf
+++ b/tests/kernel/spinlock/prj.conf
@@ -1,2 +1,3 @@
CONFIG_ZTEST=y
CONFIG_SPIN_VALIDATE=y
+CONFIG_ZTEST_NEW_API=y
diff --git a/tests/kernel/spinlock/src/main.c b/tests/kernel/spinlock/src/main.c
index 278e6e5..6673175 100644
--- a/tests/kernel/spinlock/src/main.c
+++ b/tests/kernel/spinlock/src/main.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018 Intel Corporation.
+ * Copyright (c) 2018,2022 Intel Corporation.
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -37,7 +37,7 @@
*
* @see k_spin_lock(), k_spin_unlock()
*/
-void test_spinlock_basic(void)
+ZTEST(spinlock, test_spinlock_basic)
{
k_spinlock_key_t key;
static struct k_spinlock l;
@@ -111,7 +111,7 @@
*
* @see arch_start_cpu()
*/
-void test_spinlock_bounce(void)
+ZTEST(spinlock, test_spinlock_bounce)
{
int i;
@@ -140,7 +140,7 @@
*
* @see k_spin_lock(), k_spin_unlock()
*/
-void test_spinlock_mutual_exclusion(void)
+ZTEST(spinlock, test_spinlock_mutual_exclusion)
{
k_spinlock_key_t key;
static struct k_spinlock lock_runtime;
@@ -173,20 +173,4 @@
zassert_true(!lock_runtime.locked, "Spinlock failed to unlock");
}
-
-extern void test_spinlock_no_recursive(void);
-extern void test_spinlock_unlock_error(void);
-extern void test_spinlock_release_error(void);
-
-
-void test_main(void)
-{
- ztest_test_suite(spinlock,
- ztest_unit_test(test_spinlock_basic),
- ztest_unit_test(test_spinlock_bounce),
- ztest_unit_test(test_spinlock_mutual_exclusion),
- ztest_unit_test(test_spinlock_no_recursive),
- ztest_unit_test(test_spinlock_unlock_error),
- ztest_unit_test(test_spinlock_release_error));
- ztest_run_test_suite(spinlock);
-}
+ZTEST_SUITE(spinlock, NULL, NULL, NULL, NULL, NULL);
diff --git a/tests/kernel/spinlock/src/spinlock_error_case.c b/tests/kernel/spinlock/src/spinlock_error_case.c
index f3767a8..37b8211 100644
--- a/tests/kernel/spinlock/src/spinlock_error_case.c
+++ b/tests/kernel/spinlock/src/spinlock_error_case.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018 Intel Corporation.
+ * Copyright (c) 2018,2022 Intel Corporation.
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -70,7 +70,7 @@
*
* @see k_spin_lock()
*/
-void test_spinlock_no_recursive(void)
+ZTEST(spinlock, test_spinlock_no_recursive)
{
k_spinlock_key_t re;
@@ -91,7 +91,7 @@
*
* @see k_spin_unlock()
*/
-void test_spinlock_unlock_error(void)
+ZTEST(spinlock, test_spinlock_unlock_error)
{
key = k_spin_lock(&lock);
@@ -110,7 +110,7 @@
*
* @see k_spin_release()
*/
-void test_spinlock_release_error(void)
+ZTEST(spinlock, test_spinlock_release_error)
{
key = k_spin_lock(&lock);