Skip to contentSkip to conversation

lib/tst_kconfig.c: Add any kconfig to match the expected value function

PATCH Superseded Pengfei Xu 3 participants 13 messages Dec 19, 2019 – Dec 21, 2019 Library code

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Pengfei Xu

author
#0 lore raw

PATCH v4 1/4 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

---
 lib/tst_kconfig.c | 36 +++++++++++++++++++++++-------------
 1 file changed, 23 insertions(+), 13 deletions(-)
lib/tst_kconfig.c +23 -13
index 4b51413e5..74c46ebec 100644
@@ -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
author
#1 lore raw

PATCH v4 2/4 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.

---
 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
index 1baa26c52..24eca8890 100644
@@ -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
author
#2 lore raw

PATCH v4 3/4 lib: add any kconfig to match the expected value function into kconfig test

In reply to Pengfei Xu

config01/02/03/04 should be passed for UMIP kconfig All cases in config05 should be failed.

---
 lib/newlib_tests/config01       | 1 +
 lib/newlib_tests/config02       | 1 +
 lib/newlib_tests/config03       | 1 +
 lib/newlib_tests/config04       | 1 +
 lib/newlib_tests/config05       | 2 ++
 lib/newlib_tests/test_kconfig.c | 1 +
 6 files changed, 7 insertions(+)
lib/newlib_tests/config01 +1 -0
index 96d68d836..085c9368c 100644
@@ -2,3 +2,4 @@
 CONFIG_MMU=y
 CONFIG_EXT4_FS=m
 CONFIG_PGTABLE_LEVELS=4
+CONFIG_X86_UMIP=y
lib/newlib_tests/config02 +1 -0
index 2de45cff8..ca71d26c1 100644
@@ -2,3 +2,4 @@
 # CONFIG_MMU is not set
 CONFIG_EXT4_FS=m
 CONFIG_PGTABLE_LEVELS=4
+CONFIG_X86_INTEL_UMIP=y
lib/newlib_tests/config03 +1 -0
index 1a3b9e648..8a92def74 100644
@@ -2,3 +2,4 @@
 CONFIG_MMU=y
 CONFIG_EXT4_FS=m
 CONFIG_PGTABLE_LEVELS=44
+CONFIG_X86_UMIP=y
lib/newlib_tests/config04 +1 -0
index cce7051ae..424157fec 100644
@@ -1,4 +1,5 @@
 # Unexpected CONFIG_EXT4_FS compiled in
 CONFIG_MMU=y
 CONFIG_EXT4_FS=y
+CONFIG_X86_INTEL_UMIP=y
 CONFIG_PGTABLE_LEVELS=4
lib/newlib_tests/config05 +2 -0
index a9d7bab4d..e68fa8913 100644
@@ -1,3 +1,5 @@
 # Everything is wrong
 CONFIG_EXT4_FS=y
 CONFIG_PGTABLE_LEVELS=44
+CONFIG_X86_UMI=y
+CONFIG_X86_INT_UMIP=y
lib/newlib_tests/test_kconfig.c +1 -0
index d9c662fc5..9515b60e2 100644
@@ -14,6 +14,7 @@ static const char *kconfigs[] = {
 	"CONFIG_MMU",
 	"CONFIG_EXT4_FS=m",
 	"CONFIG_PGTABLE_LEVELS=4",
+	"CONFIG_X86_INTEL_UMIP|CONFIG_X86_UMIP=y",
 	NULL
 };
 
Signature · 1 line
2.14.1
author
#3 lore raw

PATCH v4 4/4 lib: add any kconfig to match the expected value function document

In reply to Pengfei Xu
---
 doc/test-writing-guidelines.txt | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
doc/test-writing-guidelines.txt +3 -1
index 79d857fea..e64ff8716 100644
@@ -1590,7 +1590,9 @@ aborted with 'TCONF' if any of the required options were not set.
 #include "tst_test.h"
 
 static const char *kconfigs[] = {
-	"CONFIG_X86_INTEL_UMIP",
+	"CONFIG_EXT4_FS=y",
+	"CONFIG_MMU",
+	"CONFIG_X86_INTEL_UMIP|CONFIG_X86_UMIP=y",
 	NULL
 };
 
Signature · 1 line
2.14.1
#4 lore raw

PATCH v4 4/4 lib: add any kconfig to match the expected value function document

Hi Pengfei

doc/test-writing-guidelines.txt aborted with 'TCONF' if any of the required options were not set.

Quoted 10 lines · Pengfei Xu
---
  doc/test-writing-guidelines.txt | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
doc/test-writing-guidelines.txt +0 -0
index 79d857fea..e64ff8716 100644
@@ -1590,7 +1590,9 @@ aborted with 'TCONF' if any of the required options were not set.

Before your patch, I know we can use the following two formats kconfigs CONFIG_A
CONFIG_A=y/m/v
after your patch set, we can use the following three formats kconfigs CONFIG_A
CONFIG_A=y/m/v
CONFIG_A|CONFIGB=y/m/v
As the usual extend logic, we think CONFIGA|CONFIGB is also ok. But in fact, we use "|" or "=" to delim string. So we can't parse CONFIGA|CONFIGB correctly. So, if we can tell user or developer about this in here, it will be better.

ps: we can add configA| config B test in your third patch.

Kind Regards
Yang Xu

Quoted 11 lines
doc/test-writing-guidelines.txt +3 -1
  #include "tst_test.h"
 
  static const char *kconfigs[] = {
-	"CONFIG_X86_INTEL_UMIP",
+	"CONFIG_EXT4_FS=y",
+	"CONFIG_MMU",
+	"CONFIG_X86_INTEL_UMIP|CONFIG_X86_UMIP=y",
  	NULL
  };
 
author
#5 lore raw

PATCH v4 4/4 lib: add any kconfig to match the expected value function document

Hi Xu,

Quoted 26 lines · Yang Xu

Hi Pengfei

doc/test-writing-guidelines.txt aborted with 'TCONF' if any of the required options were not set.

Quoted 10 lines · Pengfei Xu
---
  doc/test-writing-guidelines.txt | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
doc/test-writing-guidelines.txt +0 -0
index 79d857fea..e64ff8716 100644
@@ -1590,7 +1590,9 @@ aborted with 'TCONF' if any of the required options were not set.

Before your patch, I know we can use the following two formats kconfigs CONFIG_A
CONFIG_A=y/m/v
after your patch set, we can use the following three formats kconfigs CONFIG_A
CONFIG_A=y/m/v
CONFIG_A|CONFIGB=y/m/v
As the usual extend logic, we think CONFIGA|CONFIGB is also ok. But in fact, we use "|" or "=" to delim string. So we can't parse CONFIGA|CONFIGB correctly. So, if we can tell user or developer about this in here, it will be better.

Quoted 2 lines

ps: we can add configA| config B test in your third patch.

Actually present patch could support CONFIG_A|CONFIG_B style, and it works
well, you could change "CONFIG_X86_INTEL_UMIP|CONFIG_X86_UMIP=y" to "CONFIG_X86_INTEL_UMIP|CONFIG_X86_UMIP" in test_kconfig.c and have a try. : )

Thanks!

Quoted 13 lines

Kind Regards
Yang Xu

Quoted 9 lines
doc/test-writing-guidelines.txt +3 -1
  #include "tst_test.h"
  static const char *kconfigs[] = {
-	"CONFIG_X86_INTEL_UMIP",
+	"CONFIG_EXT4_FS=y",
+	"CONFIG_MMU",
+	"CONFIG_X86_INTEL_UMIP|CONFIG_X86_UMIP=y",
  	NULL
  };
 
#6 lore raw

PATCH v4 4/4 lib: add any kconfig to match the expected value function document

Hi Pengfei

Quoted 30 lines

Hi Xu,

Quoted 26 lines · Yang Xu

Hi Pengfei

doc/test-writing-guidelines.txt aborted with 'TCONF' if any of the required options were not set.

Quoted 10 lines · Pengfei Xu
---
   doc/test-writing-guidelines.txt | 4 +++-
   1 file changed, 3 insertions(+), 1 deletion(-)
doc/test-writing-guidelines.txt +0 -0
index 79d857fea..e64ff8716 100644
@@ -1590,7 +1590,9 @@ aborted with 'TCONF' if any of the required options were not set.

Before your patch, I know we can use the following two formats kconfigs CONFIG_A
CONFIG_A=y/m/v
after your patch set, we can use the following three formats kconfigs CONFIG_A
CONFIG_A=y/m/v
CONFIG_A|CONFIGB=y/m/v
As the usual extend logic, we think CONFIGA|CONFIGB is also ok. But in fact, we use "|" or "=" to delim string. So we can't parse CONFIGA|CONFIGB correctly. So, if we can tell user or developer about this in here, it will be better.

Quoted 5 lines
Quoted 2 lines

ps: we can add configA| config B test in your third patch.

Actually present patch could support CONFIG_A|CONFIG_B style, and it works
well, you could change "CONFIG_X86_INTEL_UMIP|CONFIG_X86_UMIP=y" to "CONFIG_X86_INTEL_UMIP|CONFIG_X86_UMIP" in test_kconfig.c and have a try. : )

"CONFIG_X86_INTEL_UMIP|CONFIG_X86_UMIP" is useful because CONFIG_X86_INTEL_UMIP is in our kernel configs . If you use "CONFIG_X86_UMIP|CONFIG_X86_INTEL_UMIP", it will report error.

Kind Regards
Yang Xu

Quoted 17 lines

Thanks!

Quoted 13 lines

Kind Regards
Yang Xu

Quoted 9 lines
doc/test-writing-guidelines.txt +3 -1
   #include "tst_test.h"
   static const char *kconfigs[] = {
-	"CONFIG_X86_INTEL_UMIP",
+	"CONFIG_EXT4_FS=y",
+	"CONFIG_MMU",
+	"CONFIG_X86_INTEL_UMIP|CONFIG_X86_UMIP=y",
   	NULL
   };
 
author
#7 lore raw

PATCH v4 4/4 lib: add any kconfig to match the expected value function document

Hi Xu,
Thanks for your comment.
I will try to fix it and send the patch.

Thanks!
BR.

Quoted 61 lines · Yang Xu

Hi Pengfei

Quoted 30 lines

Hi Xu,

Quoted 26 lines · Yang Xu

Hi Pengfei

doc/test-writing-guidelines.txt aborted with 'TCONF' if any of the required options were not set.

Quoted 10 lines · Pengfei Xu
---
   doc/test-writing-guidelines.txt | 4 +++-
   1 file changed, 3 insertions(+), 1 deletion(-)
doc/test-writing-guidelines.txt +0 -0
index 79d857fea..e64ff8716 100644
@@ -1590,7 +1590,9 @@ aborted with 'TCONF' if any of the required options were not set.

Before your patch, I know we can use the following two formats kconfigs CONFIG_A
CONFIG_A=y/m/v
after your patch set, we can use the following three formats kconfigs CONFIG_A
CONFIG_A=y/m/v
CONFIG_A|CONFIGB=y/m/v
As the usual extend logic, we think CONFIGA|CONFIGB is also ok. But in fact, we use "|" or "=" to delim string. So we can't parse CONFIGA|CONFIGB correctly. So, if we can tell user or developer about this in here, it will be better.

Quoted 5 lines
Quoted 2 lines

ps: we can add configA| config B test in your third patch.

Actually present patch could support CONFIG_A|CONFIG_B style, and it works
well, you could change "CONFIG_X86_INTEL_UMIP|CONFIG_X86_UMIP=y" to "CONFIG_X86_INTEL_UMIP|CONFIG_X86_UMIP" in test_kconfig.c and have a try. : )

"CONFIG_X86_INTEL_UMIP|CONFIG_X86_UMIP" is useful because CONFIG_X86_INTEL_UMIP is in our kernel configs . If you use "CONFIG_X86_UMIP|CONFIG_X86_INTEL_UMIP", it will report error.

Kind Regards
Yang Xu

Quoted 17 lines

Thanks!

Quoted 13 lines

Kind Regards
Yang Xu

Quoted 9 lines
doc/test-writing-guidelines.txt +3 -1
   #include "tst_test.h"
   static const char *kconfigs[] = {
-	"CONFIG_X86_INTEL_UMIP",
+	"CONFIG_EXT4_FS=y",
+	"CONFIG_MMU",
+	"CONFIG_X86_INTEL_UMIP|CONFIG_X86_UMIP=y",
   	NULL
   };
 
author
#8 lore raw

PATCH v4 4/4 lib: add any kconfig to match the expected value function document

In reply to Yang Xu

Hi Xu,
Due to memory copy, there is some bit and display issue in last string.

So for your question, for CONFIG_A|CONFIG_B without expect value, maybe y or m.
We could add it with below style:
"CONFIG_A|CONFIG_B|NA", and add it into guidelines, NA will not be solved, actually you could fill with any string after last '|'.
Is it ok?

Thanks!

Quoted 46 lines · Yang Xu

Hi Pengfei

Quoted 15 lines

Hi Xu,

Quoted 12 lines

Before your patch, I know we can use the following two formats kconfigs CONFIG_A
CONFIG_A=y/m/v
after your patch set, we can use the following three formats kconfigs CONFIG_A
CONFIG_A=y/m/v
CONFIG_A|CONFIGB=y/m/v
As the usual extend logic, we think CONFIGA|CONFIGB is also ok. But in fact, we use "|" or "=" to delim string. So we can't parse CONFIGA|CONFIGB correctly. So, if we can tell user or developer about this in here, it will be better.

Quoted 5 lines
Quoted 2 lines

ps: we can add configA| config B test in your third patch.

Actually present patch could support CONFIG_A|CONFIG_B style, and it works
well, you could change "CONFIG_X86_INTEL_UMIP|CONFIG_X86_UMIP=y" to "CONFIG_X86_INTEL_UMIP|CONFIG_X86_UMIP" in test_kconfig.c and have a try. : )

"CONFIG_X86_INTEL_UMIP|CONFIG_X86_UMIP" is useful because CONFIG_X86_INTEL_UMIP is in our kernel configs . If you use "CONFIG_X86_UMIP|CONFIG_X86_INTEL_UMIP", it will report error.

Kind Regards
Yang Xu

Quoted 17 lines

Thanks!

Quoted 13 lines

Kind Regards
Yang Xu

Quoted 9 lines
   #include "tst_test.h"
   static const char *kconfigs[] = {
doc/test-writing-guidelines.txt +3 -1
-	"CONFIG_X86_INTEL_UMIP",
+	"CONFIG_EXT4_FS=y",
+	"CONFIG_MMU",
+	"CONFIG_X86_INTEL_UMIP|CONFIG_X86_UMIP=y",
   	NULL
   };
#9 lore raw

PATCH v4 4/4 lib: add any kconfig to match the expected value function document

Hi Pengfei

Quoted 9 lines

Hi Xu,
Due to memory copy, there is some bit and display issue in last string.

So for your question, for CONFIG_A|CONFIG_B without expect value, maybe y or m.
We could add it with below style:
"CONFIG_A|CONFIG_B|NA", and add it into guidelines, NA will not be solved, actually you could fill with any string after last '|'.
Is it ok?

It sounds reasonable. I think it is ok.

Kind Regards
Yang Xu

Quoted 52 lines

Thanks!

Quoted 46 lines · Yang Xu

Hi Pengfei

Quoted 15 lines

Hi Xu,

Quoted 12 lines

Before your patch, I know we can use the following two formats kconfigs CONFIG_A
CONFIG_A=y/m/v
after your patch set, we can use the following three formats kconfigs CONFIG_A
CONFIG_A=y/m/v
CONFIG_A|CONFIGB=y/m/v
As the usual extend logic, we think CONFIGA|CONFIGB is also ok. But in fact, we use "|" or "=" to delim string. So we can't parse CONFIGA|CONFIGB correctly. So, if we can tell user or developer about this in here, it will be better.

Quoted 5 lines
Quoted 2 lines

ps: we can add configA| config B test in your third patch.

Actually present patch could support CONFIG_A|CONFIG_B style, and it works
well, you could change "CONFIG_X86_INTEL_UMIP|CONFIG_X86_UMIP=y" to "CONFIG_X86_INTEL_UMIP|CONFIG_X86_UMIP" in test_kconfig.c and have a try. : )

"CONFIG_X86_INTEL_UMIP|CONFIG_X86_UMIP" is useful because CONFIG_X86_INTEL_UMIP is in our kernel configs . If you use "CONFIG_X86_UMIP|CONFIG_X86_INTEL_UMIP", it will report error.

Kind Regards
Yang Xu

Quoted 17 lines

Thanks!

Quoted 13 lines

Kind Regards
Yang Xu

Quoted 9 lines
    #include "tst_test.h"
    static const char *kconfigs[] = {
doc/test-writing-guidelines.txt +3 -1
-	"CONFIG_X86_INTEL_UMIP",
+	"CONFIG_EXT4_FS=y",
+	"CONFIG_MMU",
+	"CONFIG_X86_INTEL_UMIP|CONFIG_X86_UMIP=y",
    	NULL
    };
#10 lore raw

PATCH v4 4/4 lib: add any kconfig to match the expected value function document

Thanks Xu! :)

BR.

Quoted 65 lines

? 2019?12?20??15:20?Yang Xu <[email protected]> ???

?Hi Pengfei

Quoted 8 lines

Hi Xu,
Due to memory copy, there is some bit and display issue in last string. So for your question, for CONFIG_A|CONFIG_B without expect value, maybe y or m.
We could add it with below style:
"CONFIG_A|CONFIG_B|NA", and add it into guidelines, NA will not be solved, actually you could fill with any string after last '|'.
Is it ok?

It sounds reasonable. I think it is ok.

Kind Regards
Yang Xu

Quoted 48 lines

Thanks!

Quoted 47 lines · Yang Xu

Hi Pengfei

Quoted 15 lines

Hi Xu,

Quoted 12 lines

Before your patch, I know we can use the following two formats kconfigs CONFIG_A
CONFIG_A=y/m/v
after your patch set, we can use the following three formats kconfigs CONFIG_A
CONFIG_A=y/m/v
CONFIG_A|CONFIGB=y/m/v
As the usual extend logic, we think CONFIGA|CONFIGB is also ok. But in fact, we use "|" or "=" to delim string. So we can't parse CONFIGA|CONFIGB correctly. So, if we can tell user or developer about this in here, it will be better.

Quoted 5 lines
Quoted 2 lines

ps: we can add configA| config B test in your third patch.

Actually present patch could support CONFIG_A|CONFIG_B style, and it works
well, you could change "CONFIG_X86_INTEL_UMIP|CONFIG_X86_UMIP=y" to "CONFIG_X86_INTEL_UMIP|CONFIG_X86_UMIP" in test_kconfig.c and have a try. : )

"CONFIG_X86_INTEL_UMIP|CONFIG_X86_UMIP" is useful because CONFIG_X86_INTEL_UMIP is in our kernel configs . If you use "CONFIG_X86_UMIP|CONFIG_X86_INTEL_UMIP", it will report error.

Kind Regards
Yang Xu

Quoted 17 lines

Thanks!

Quoted 13 lines

Kind Regards
Yang Xu

Quoted 9 lines
   #include "tst_test.h"
   static const char *kconfigs[] = {
doc/test-writing-guidelines.txt +3 -1
-    "CONFIG_X86_INTEL_UMIP",
+    "CONFIG_EXT4_FS=y",
+    "CONFIG_MMU",
+    "CONFIG_X86_INTEL_UMIP|CONFIG_X86_UMIP=y",
       NULL
   };
#11 lore raw

PATCH v4 1/4 lib/tst_kconfig.c: Add any kconfig to match the expected value function

In reply to Pengfei Xu

Hi Pengfei

This patch set looks good to me, only a samll comment.

Quoted 53 lines · Pengfei Xu

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

---
  lib/tst_kconfig.c | 36 +++++++++++++++++++++++-------------
  1 file changed, 23 insertions(+), 13 deletions(-)
lib/tst_kconfig.c +10 -9
index 4b51413e5..74c46ebec 100644
@@ -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))

lib/tst_kconfig.c void tst_kconfig_read(const char *const *kconfigs, · line 202

Quoted 10 lines
lib/tst_kconfig.c +7 -2
+					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)

It will report ?j? may be used uninitialized in this function when compile. But I think it can be modified by maintainer when it is merged.

Quoted 14 lines
lib/tst_kconfig.c +6 -2
-					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:
author
#12 lore raw

PATCH v4 1/4 lib/tst_kconfig.c: Add any kconfig to match the expected value function

Hi Xu,
Thanks for your advice!
I will send the new patch to solve the warning.

Thanks!
BR.

Quoted 44 lines · Yang Xu

Hi Pengfei

This patch set looks good to me, only a samll comment.

Quoted 15 lines · Pengfei Xu

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

---
  lib/tst_kconfig.c | 36 +++++++++++++++++++++++-------------
  1 file changed, 23 insertions(+), 13 deletions(-)
lib/tst_kconfig.c +0 -0
index 4b51413e5..74c46ebec 100644

lib/tst_kconfig.c void tst_kconfig_read(const char *const *kconfigs, · line 170

Quoted 6 lines
lib/tst_kconfig.c +2 -2
@@ -167,7 +167,8 @@ void tst_kconfig_read(const char *const *kconfigs,
  	struct match matches[cnt];
+							break;
+					}
  				}
-
-				if (j == cnt)

It will report ?j? may be used uninitialized in this function when compile. But I think it can be modified by maintainer when it is merged.

Quoted 13 lines
lib/tst_kconfig.c +6 -2
-					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: