1 // SPDX-License-Identifier: BSD-3-Clause
2 //
3 // Copyright(c) 2018 Intel Corporation. All rights reserved.
4 //
5 // Author: Janusz Jankowski <janusz.jankowski@linux.intel.com>
6 
7 #include <sof/list.h>
8 
9 #include <stdarg.h>
10 #include <stddef.h>
11 #include <setjmp.h>
12 #include <stdint.h>
13 #include <cmocka.h>
14 
test_list_list_init_prev_equal_to_root(void ** state)15 static void test_list_list_init_prev_equal_to_root(void **state)
16 {
17 	(void) state; /* unused */
18 
19 	struct list_item list = {.prev = NULL, .next = NULL};
20 
21 	list_init(&list);
22 
23 	assert_ptr_equal(&list, list.prev);
24 }
25 
test_list_list_init_next_equal_to_root(void ** state)26 static void test_list_list_init_next_equal_to_root(void **state)
27 {
28 	(void) state; /* unused */
29 
30 	struct list_item list = {.prev = NULL, .next = NULL};
31 
32 	list_init(&list);
33 
34 	assert_ptr_equal(&list, list.next);
35 }
36 
main(void)37 int main(void)
38 {
39 	const struct CMUnitTest tests[] = {
40 		cmocka_unit_test(test_list_list_init_prev_equal_to_root),
41 		cmocka_unit_test(test_list_list_init_next_equal_to_root),
42 	};
43 
44 	cmocka_set_message_output(CM_OUTPUT_TAP);
45 
46 	return cmocka_run_group_tests(tests, NULL, NULL);
47 }
48