xref: /aosp_15_r20/external/ltp/lib/newlib_tests/test_kconfig03.c (revision 49cdfc7efb34551c7342be41a7384b9c40d7cab7)
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * Copyright (c) 2024 Li Wang <[email protected]>
4  */
5 
6 #include "tst_test.h"
7 #include "tst_kconfig.h"
8 
9 static struct tst_kcmdline_var params[] = {
10 	TST_KCMDLINE_INIT("BOOT_IMAGE"),
11 	TST_KCMDLINE_INIT("root"),
12 	TST_KCMDLINE_INIT("foo")
13 };
14 
do_test(void)15 static void do_test(void)
16 {
17 	int i, N;
18 
19 	N = (int) ARRAY_SIZE(params);
20 
21 	tst_kcmdline_parse(params, N);
22 
23 	for (i = 0; i < N; i++) {
24 		if (params[i].found) {
25 			tst_res(TPASS, "params[%d] = {%s, %s}", i, params[i].key, params[i].value);
26 		} else {
27 			if (!strcmp(params[i].key, "foo"))
28 				tst_res(TPASS, "%s is not found in /proc/cmdline", params[i].key);
29 			else
30 				tst_res(TFAIL, "%s is not found in /proc/cmdline", params[i].key);
31 		}
32 	}
33 }
34 
35 static struct tst_test test = {
36 	.test_all = do_test,
37 };
38