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 enum bst_result_t bst_result;
16 
17 unsigned long runtime_log_level = LOG_LEVEL_INF;
18 
test_args(int argc,char * argv[])19 static void test_args(int argc, char *argv[])
20 {
21 	size_t argn = 0;
22 	const char *arg = argv[argn];
23 
24 	if (strcmp(arg, "log_level") == 0) {
25 
26 		runtime_log_level = strtoul(argv[++argn], NULL, 10);
27 
28 		if (runtime_log_level >= LOG_LEVEL_NONE &&
29 			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 has not passed.");
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 	BSTEST_END_MARKER,
54 };
55 
install(struct bst_test_list * tests)56 static struct bst_test_list *install(struct bst_test_list *tests)
57 {
58 	return bst_add_tests(tests, entrypoints);
59 };
60 
61 bst_test_install_t test_installers[] = {install, NULL};
62 
main(void)63 int main(void)
64 {
65 	bst_main();
66 
67 	return 0;
68 }
69