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