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