1 /*
2 * Copyright (c) 2024 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7 #include <zephyr/kernel.h>
8
9 #include "bs_tracing.h"
10 #include "bstests.h"
11 #include "babblekit/testcase.h"
12 #include "testlib/log_utils.h"
13
14 extern void entrypoint_dut(void);
15 extern void entrypoint_peer(void);
16 extern enum bst_result_t bst_result;
17
18 unsigned long runtime_log_level = LOG_LEVEL_INF;
19
test_args(int argc,char * argv[])20 static void test_args(int argc, char *argv[])
21 {
22 size_t argn = 0;
23 const char *arg = argv[argn];
24
25 if (strcmp(arg, "log_level") == 0) {
26
27 runtime_log_level = strtoul(argv[++argn], NULL, 10);
28
29 if (runtime_log_level >= LOG_LEVEL_NONE && runtime_log_level <= LOG_LEVEL_DBG) {
30 TEST_PRINT("Runtime log level configuration: %d", runtime_log_level);
31 } else {
32 TEST_FAIL("Invalid arguments to set log level: %d", runtime_log_level);
33 }
34 } else {
35 TEST_PRINT("Default runtime log level configuration: INFO");
36 }
37 }
38
test_end_cb(void)39 static void test_end_cb(void)
40 {
41 if (bst_result != Passed) {
42 TEST_PRINT("Test failed.");
43 }
44 }
45
46 static const struct bst_test_instance entrypoints[] = {
47 {
48 .test_id = "dut",
49 .test_delete_f = test_end_cb,
50 .test_main_f = entrypoint_dut,
51 .test_args_f = test_args,
52 },
53 {
54 .test_id = "peer",
55 .test_delete_f = test_end_cb,
56 .test_main_f = entrypoint_peer,
57 .test_args_f = test_args,
58 },
59 BSTEST_END_MARKER,
60 };
61
install(struct bst_test_list * tests)62 static struct bst_test_list *install(struct bst_test_list *tests)
63 {
64 return bst_add_tests(tests, entrypoints);
65 };
66
67 bst_test_install_t test_installers[] = {install, NULL};
68
main(void)69 int main(void)
70 {
71 bst_main();
72
73 return 0;
74 }
75