1 /*
2  * Copyright (c) 2024 Nordic Semiconductor ASA
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #include <zephyr/ztest.h>
8 
9 #ifndef CONFIG_TEST_TYPE
10 #error "Invalid test configuration"
11 #endif
12 
13 #ifdef CONFIG_SOC_FOLDER_TEST_INCLUDE_APP
14 #define INCLUDED_APP 1
15 #else
16 #define INCLUDED_APP 0
17 #endif
18 
19 #ifdef CONFIG_SOC_FOLDER_TEST_INCLUDE_BOARD
20 #define INCLUDED_BOARD 1
21 #else
22 #define INCLUDED_BOARD 0
23 #endif
24 
25 #ifdef CONFIG_SOC_FOLDER_TEST_INCLUDE_BOARD_SUFFIX
26 #define INCLUDED_BOARD_SUFFIX 1
27 #else
28 #define INCLUDED_BOARD_SUFFIX 0
29 #endif
30 
31 #ifdef CONFIG_SOC_FOLDER_TEST_INCLUDE_BOARD_QUALIFIERS
32 #define INCLUDED_BOARD_QUALIFIERS 1
33 #else
34 #define INCLUDED_BOARD_QUALIFIERS 0
35 #endif
36 
37 #ifdef CONFIG_SOC_FOLDER_TEST_INCLUDE_SOC
38 #define INCLUDED_SOC 1
39 #else
40 #define INCLUDED_SOC 0
41 #endif
42 
43 #ifdef CONFIG_SOC_FOLDER_TEST_INCLUDE_SOC_SUFFIX
44 #define INCLUDED_SOC_SUFFIX 1
45 #else
46 #define INCLUDED_SOC_SUFFIX 0
47 #endif
48 
49 #if CONFIG_TEST_TYPE == 0
50 /* Default test */
ZTEST(soc_folder_overlay,test_default)51 ZTEST(soc_folder_overlay, test_default)
52 {
53 	zassert_false(INCLUDED_APP, "Did not expect app overlay to be present");
54 	zassert_false(INCLUDED_BOARD_SUFFIX, "Did not expect board suffix overlay to be present");
55 
56 #ifdef CONFIG_BOARD_NATIVE_SIM_NATIVE_64
57 	zassert_false(INCLUDED_BOARD, "Did not expect board overlay to be present");
58 	zassert_true(INCLUDED_BOARD_QUALIFIERS, "Expected board qualifier overlay to be present");
59 #else
60 	zassert_true(INCLUDED_BOARD, "Expected board overlay to be present");
61 	zassert_false(INCLUDED_BOARD_QUALIFIERS,
62 		      "Did not expect board qualifier overlay to be present");
63 #endif
64 
65 	zassert_true(INCLUDED_SOC, "Expect soc overlay to be present");
66 	zassert_false(INCLUDED_SOC_SUFFIX, "Did not expect soc suffix overlay to be present");
67 }
68 #elif CONFIG_TEST_TYPE == 1
69 /* File suffix test */
ZTEST(soc_folder_overlay,test_suffix)70 ZTEST(soc_folder_overlay, test_suffix)
71 {
72 	zassert_false(INCLUDED_APP, "Did not expect app overlay to be present");
73 	zassert_true(INCLUDED_BOARD_SUFFIX, "Expected board suffix overlay to be present");
74 	zassert_false(INCLUDED_BOARD, "Did not expect board overlay to be present");
75 	zassert_false(INCLUDED_BOARD_QUALIFIERS,
76 		      "Did not expect board qualifier overlay to be present");
77 	zassert_false(INCLUDED_SOC, "Did not expect soc overlay to be present");
78 	zassert_true(INCLUDED_SOC_SUFFIX, "Expected soc suffix overlay to be present");
79 }
80 #elif CONFIG_TEST_TYPE == 2
81 /* App overlay test */
ZTEST(soc_folder_overlay,test_app)82 ZTEST(soc_folder_overlay, test_app)
83 {
84 	zassert_true(INCLUDED_APP, "Expected app overlay to be present");
85 	zassert_false(INCLUDED_BOARD_SUFFIX, "Did not expect board suffix overlay to be present");
86 	zassert_false(INCLUDED_BOARD, "Did not expect board overlay to be present");
87 	zassert_false(INCLUDED_BOARD_QUALIFIERS,
88 		      "Did not expect board qualifier overlay to be present");
89 	zassert_false(INCLUDED_SOC, "Did not expect soc overlay to be present");
90 	zassert_false(INCLUDED_SOC_SUFFIX, "Did not epect soc suffix overlay to be present");
91 }
92 #else
93 #error "Invalid test type"
94 #endif
95 
96 ZTEST_SUITE(soc_folder_overlay, NULL, NULL, NULL, NULL, NULL);
97