lib/tst_kconfig.c: Add any kconfig to match the expected value function
PATCH v2 1/2 lib/tst_kconfig.c: Add any kconfig to match the expected value function
Example: CONFIG_X86_INTEL_UMIP=y for umip kconfig before and v5.4
mainline kernel.
CONFIG_X86_UMIP=y for umip kconfig after v5.5 mainline kernel.
Format: CONFIG_X86_INTEL_UMIP|CONFIG_X86_UMIP=y
Signed-off-by Pengfei Xu <[email protected]>
--- lib/tst_kconfig.c | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-)
lib/tst_kconfig.c +23 -13
@@ -167,7 +167,8 @@ void tst_kconfig_read(const char *const *kconfigs,struct match matches[cnt];FILE *fp;unsigned int i, j; -char buf[1024 ]; +char buf[1024 ], kconfig_multi[100 ]; +char *kconfig_token =NULL , *p_left =NULL ;for (i =0 ; i < cnt; i++) {const char *val =strchr (kconfigs[i],'=' );
@@ -176,12 +177,9 @@ void tst_kconfig_read(const char *const *kconfigs,tst_brk (TBROK ,"Invalid config string '%s'" , kconfigs[i]); matches[i].match =0 ; - matches[i].len =strlen (kconfigs[i]); -if (val) { +if (val) matches[i].val = val +1 ; - matches[i].len -=strlen (val); - } results[i].match =0 ; results[i].value =NULL ;
@@ -193,17 +191,29 @@ void tst_kconfig_read(const char *const *kconfigs,while (fgets (buf,sizeof (buf), fp)) {for (i =0 ; i < cnt; i++) { -if (match (&matches[i], kconfigs[i], &results[i], buf)) { -for (j =0 ; j < cnt; j++) { -if (matches[j].match) -break ; +memset (kconfig_multi,0 ,sizeof (kconfig_multi)); +/* strtok_r will split kconfigs[i] to multi string, so copy it */ +memcpy (kconfig_multi, kconfigs[i],strlen (kconfigs[i])); + kconfig_token =strtok_r (kconfig_multi,"|=" , &p_left); + +while (kconfig_token !=NULL ) { +if (strncmp ("CONFIG_" , kconfig_token,7 )) +tst_brk (TBROK ,"Invalid config string '%s'" , kconfig_token); + matches[i].len =strlen (kconfig_token); +if (match (&matches[i], kconfig_token, &results[i], buf)) { +for (j =0 ; j < cnt; j++) { +if (matches[j].match) +break ; + } } - -if (j == cnt) - goto exit; + kconfig_token =strtok_r (NULL ,"|=" , &p_left); +/* avoid to use after "=" string */ +if (strlen (p_left) ==0 ) +break ; } +if (j == cnt) + goto exit; } - } exit:
Signature · 1 line
2.14.1
PATCH v2 2/2 umip_basic_test.c: improve kconfig check to avoid umip wrong abort case
From v5.5 main line, umip kconfig changed from "CONFIG_X86_INTEL_UMIP=y" to "CONFIG_X86_UMIP=y".
We could use "CONFIG_X86_INTEL_UMIP|CONFIG_X86_UMIP=y" to check kconfig CONFIG_X86_INTEL_UMIP=y(old kernel) or CONFIG_X86_UMIP=y(new kernel) for umip.
Signed-off-by Pengfei Xu <[email protected]>
--- testcases/kernel/security/umip/umip_basic_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
testcases/kernel/security/umip/umip_basic_test.c +1 -1
@@ -171,7 +171,7 @@ static struct tst_test test = { .forks_child = 1, .test = verify_umip_instruction, .needs_kconfigs = (const char *[]){ -"CONFIG_X86_INTEL_UMIP=y" , +"CONFIG_X86_INTEL_UMIP|CONFIG_X86_UMIP=y" ,NULL }, .needs_root = 1,
Signature · 1 line
2.14.1