Skip to content

Commit 213eaee

Browse files
Guo Lixinnashif
authored andcommitted
tests: kernel: spinlock: move to new ztest API
Move test to use new ztest API. Signed-off-by: Guo Lixin <[email protected]>
1 parent 82c6531 commit 213eaee

File tree

3 files changed

+10
-25
lines changed

3 files changed

+10
-25
lines changed

tests/kernel/spinlock/prj.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
CONFIG_ZTEST=y
22
CONFIG_SPIN_VALIDATE=y
3+
CONFIG_ZTEST_NEW_API=y

tests/kernel/spinlock/src/main.c

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018 Intel Corporation.
2+
* Copyright (c) 2018,2022 Intel Corporation.
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -37,7 +37,7 @@ volatile int bounce_owner, bounce_done;
3737
*
3838
* @see k_spin_lock(), k_spin_unlock()
3939
*/
40-
void test_spinlock_basic(void)
40+
ZTEST(spinlock, test_spinlock_basic)
4141
{
4242
k_spinlock_key_t key;
4343
static struct k_spinlock l;
@@ -111,7 +111,7 @@ void cpu1_fn(void *p1, void *p2, void *p3)
111111
*
112112
* @see arch_start_cpu()
113113
*/
114-
void test_spinlock_bounce(void)
114+
ZTEST(spinlock, test_spinlock_bounce)
115115
{
116116
int i;
117117

@@ -140,7 +140,7 @@ void test_spinlock_bounce(void)
140140
*
141141
* @see k_spin_lock(), k_spin_unlock()
142142
*/
143-
void test_spinlock_mutual_exclusion(void)
143+
ZTEST(spinlock, test_spinlock_mutual_exclusion)
144144
{
145145
k_spinlock_key_t key;
146146
static struct k_spinlock lock_runtime;
@@ -173,20 +173,4 @@ void test_spinlock_mutual_exclusion(void)
173173
zassert_true(!lock_runtime.locked, "Spinlock failed to unlock");
174174
}
175175

176-
177-
extern void test_spinlock_no_recursive(void);
178-
extern void test_spinlock_unlock_error(void);
179-
extern void test_spinlock_release_error(void);
180-
181-
182-
void test_main(void)
183-
{
184-
ztest_test_suite(spinlock,
185-
ztest_unit_test(test_spinlock_basic),
186-
ztest_unit_test(test_spinlock_bounce),
187-
ztest_unit_test(test_spinlock_mutual_exclusion),
188-
ztest_unit_test(test_spinlock_no_recursive),
189-
ztest_unit_test(test_spinlock_unlock_error),
190-
ztest_unit_test(test_spinlock_release_error));
191-
ztest_run_test_suite(spinlock);
192-
}
176+
ZTEST_SUITE(spinlock, NULL, NULL, NULL, NULL, NULL);

tests/kernel/spinlock/src/spinlock_error_case.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018 Intel Corporation.
2+
* Copyright (c) 2018,2022 Intel Corporation.
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -70,7 +70,7 @@ void assert_post_action(const char *file, unsigned int line)
7070
*
7171
* @see k_spin_lock()
7272
*/
73-
void test_spinlock_no_recursive(void)
73+
ZTEST(spinlock, test_spinlock_no_recursive)
7474
{
7575
k_spinlock_key_t re;
7676

@@ -91,7 +91,7 @@ void test_spinlock_no_recursive(void)
9191
*
9292
* @see k_spin_unlock()
9393
*/
94-
void test_spinlock_unlock_error(void)
94+
ZTEST(spinlock, test_spinlock_unlock_error)
9595
{
9696
key = k_spin_lock(&lock);
9797

@@ -110,7 +110,7 @@ void test_spinlock_unlock_error(void)
110110
*
111111
* @see k_spin_release()
112112
*/
113-
void test_spinlock_release_error(void)
113+
ZTEST(spinlock, test_spinlock_release_error)
114114
{
115115
key = k_spin_lock(&lock);
116116

0 commit comments

Comments
 (0)