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 #ifdef CONFIG_EXTENDED_VARIANT_BOARD_SETTING
10 #define EXTENDED_BOARD_A 1
11 #else
12 #define EXTENDED_BOARD_A 0
13 #endif
14 
15 #ifdef CONFIG_EXTENDED_VARIANT_BOARD_ONE_SETTING_PROMPTLESS
16 #define EXTENDED_BOARD_ONE_B 1
17 #else
18 #define EXTENDED_BOARD_ONE_B 0
19 #endif
20 
21 #ifdef CONFIG_EXTENDED_VARIANT_BOARD_TWO_SETTING_PROMPTLESS
22 #define EXTENDED_BOARD_TWO_C 1
23 #else
24 #define EXTENDED_BOARD_TWO_C 0
25 #endif
26 
27 #ifdef CONFIG_EXTENDED_VARIANT_BOARD_SETTING_DEFCONFIG
28 #define EXTENDED_BOARD_D 1
29 #else
30 #define EXTENDED_BOARD_D 0
31 #endif
32 
33 #ifdef CONFIG_BASE_BOARD_SETTING
34 #define BASE_BOARD_CONFIG 1
35 #else
36 #define BASE_BOARD_CONFIG 0
37 #endif
38 
39 #ifdef CONFIG_SOC_MPS2_AN521_CPUTEST
40 #define EXTENDED_SOC 1
41 #else
42 #define EXTENDED_SOC 0
43 #endif
44 
45 ZTEST_SUITE(soc_board_extend, NULL, NULL, NULL, NULL, NULL);
46 
47 #if CONFIG_BOARD_NATIVE_SIM
ZTEST(soc_board_extend,test_native_sim_extend)48 ZTEST(soc_board_extend, test_native_sim_extend)
49 {
50 #if CONFIG_BOARD_NATIVE_SIM_NATIVE_ONE
51 	zassert_true(EXTENDED_BOARD_A, "Expected extended board to be set");
52 	zassert_true(EXTENDED_BOARD_ONE_B, "Expected extended board to be set");
53 	zassert_false(EXTENDED_BOARD_TWO_C, "Did not expect extended board two to be set");
54 	zassert_true(EXTENDED_BOARD_D, "Expected extended board to be set");
55 	zassert_false(BASE_BOARD_CONFIG, "Did not expect base board to be set");
56 	zassert_true(DT_NODE_EXISTS(DT_PATH(added_by_native_one)));
57 	zassert_false(DT_NODE_EXISTS(DT_PATH(added_by_native_two)));
58 	zassert_false(DT_NODE_EXISTS(DT_PATH(adc)));
59 #elif CONFIG_BOARD_NATIVE_SIM_NATIVE_64_TWO
60 	zassert_true(EXTENDED_BOARD_A, "Expected extended board to be set");
61 	zassert_false(EXTENDED_BOARD_ONE_B, "Did not expect extended board one to be set");
62 	zassert_true(EXTENDED_BOARD_TWO_C, "Expected extended board to be set");
63 	zassert_true(EXTENDED_BOARD_D, "Expected extended board to be set");
64 	zassert_false(BASE_BOARD_CONFIG, "Did not expect base board to be set");
65 	zassert_false(DT_NODE_EXISTS(DT_PATH(added_by_native_one)));
66 	zassert_true(DT_NODE_EXISTS(DT_PATH(added_by_native_two)));
67 	zassert_false(DT_NODE_EXISTS(DT_PATH(adc)));
68 #else
69 	zassert_true(false, "Did not expect to build for a base native_sim board");
70 #endif
71 #elif CONFIG_BOARD_MPS2
72 ZTEST(soc_board_extend, test_an521_soc_extend)
73 {
74 #if CONFIG_BOARD_MPS2_AN521_CPUTEST
75 	zassert_true(EXTENDED_SOC, "Expected extended SoC to be set");
76 #elif CONFIG_BOARD_MPS2
77 	zassert_true(false, "Did not expect to build for a base mps2 board");
78 #endif
79 
80 #else
81 ZTEST(soc_board_extend, test_failure)
82 {
83 	zassert_true(false, "Did not expect to build for a regular board");
84 #endif
85 }
86