1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /* Copyright (c) 2022 FUJITSU LIMITED. All rights reserved.*/
3
4 #include <stdio.h>
5 #include <string.h>
6 #include <stdlib.h>
7 #include "tst_kconfig.h"
8
main(int argc,char * argv[])9 int main(int argc, char *argv[])
10 {
11 char *str = argv[1];
12 char *delim = argv[2];
13 unsigned int i, cnt = 1, ret = 0;
14
15 switch(argc) {
16 case 2:
17 delim = ",";
18 break;
19 case 3:
20 if (strlen(delim) > 1) {
21 fprintf(stderr, "The delim must be a single character\n");
22 return 1;
23 }
24 break;
25 default:
26 fprintf(stderr, "Please provide kernel kconfig list and delim "
27 "(optinal, default value is ',')\n");
28 return 1;
29 }
30
31 for (i = 0; str[i]; i++) {
32 if (str[i] == delim[0])
33 cnt++;
34 }
35
36 char **kconfigs = malloc(++cnt * sizeof(char *));
37 if (!kconfigs) {
38 fprintf(stderr, "malloc failed\n");
39 return 1;
40 }
41
42 for (i = 0; i < cnt; i++)
43 kconfigs[i] = strtok_r(str, delim, &str);
44
45 if (tst_kconfig_check((const char * const*)kconfigs))
46 ret = 1;
47
48 free(kconfigs);
49 return ret;
50 }
51