bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf-next v2] test_bpf: add module parameter test_type
@ 2021-09-30 14:07 Tiezhu Yang
  0 siblings, 0 replies; only message in thread
From: Tiezhu Yang @ 2021-09-30 14:07 UTC (permalink / raw)
  To: ast, daniel, andrii
  Cc: kafai, songliubraving, yhs, john.fastabend, kpsingh,
	johan.almbladh, lixuefeng, netdev, bpf, linux-kernel

From: Tiezhu Yang <yangtiezhu@loongson.cn>

After commit 9298e63eafea ("bpf/tests: Add exhaustive tests of ALU
operand magnitudes"), when modprobe test_bpf.ko with jit on mips64,
there exists segment fault due to the following reason:

test_bpf: #616 ALU64_MOV_X: all register value magnitudes jited:1
Break instruction in kernel code[#1]

It seems that the related jit implementations of some test cases
in test_bpf() have problems. At this moment, I do not care about
the segment fault while I just want to verify the test cases of
tail calls.

Based on the above background and motivation, add the following
module parameter test_type to the test_bpf.ko:
test_type=<string>: only the specified type will be run, the string
can be "test_bpf", "test_tail_calls" or "test_skb_segment".

This is useful to only test the corresponding test type when specify
the valid test_type string.

Any invalid test type will result in -EINVAL being returned and no
tests being run. If the test_type is not specified or specified as
empty string, it does not change the current logic, all of the test
cases will be run.

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---

v2:
  -- Fix typo in the commit message
  -- Use my private email to send

 lib/test_bpf.c | 48 +++++++++++++++++++++++++++++++++---------------
 1 file changed, 33 insertions(+), 15 deletions(-)

diff --git a/lib/test_bpf.c b/lib/test_bpf.c
index 21ea1ab..9428fec 100644
--- a/lib/test_bpf.c
+++ b/lib/test_bpf.c
@@ -11866,6 +11866,9 @@ module_param(test_id, int, 0);
 static int test_range[2] = { 0, ARRAY_SIZE(tests) - 1 };
 module_param_array(test_range, int, NULL, 0);
 
+static char test_type[32];
+module_param_string(test_type, test_type, sizeof(test_type), 0);
+
 static __init int find_test_index(const char *test_name)
 {
 	int i;
@@ -12518,24 +12521,39 @@ static int __init test_bpf_init(void)
 	struct bpf_array *progs = NULL;
 	int ret;
 
-	ret = prepare_bpf_tests();
-	if (ret < 0)
-		return ret;
+	if (strlen(test_type) &&
+	    strcmp(test_type, "test_bpf") &&
+	    strcmp(test_type, "test_tail_calls") &&
+	    strcmp(test_type, "test_skb_segment")) {
+		pr_err("test_bpf: invalid test_type '%s' specified.\n", test_type);
+		return -EINVAL;
+	}
+
+	if (!strlen(test_type) || !strcmp(test_type, "test_bpf")) {
+		ret = prepare_bpf_tests();
+		if (ret < 0)
+			return ret;
+
+		ret = test_bpf();
+		destroy_bpf_tests();
+		if (ret)
+			return ret;
+	}
 
-	ret = test_bpf();
-	destroy_bpf_tests();
-	if (ret)
-		return ret;
+	if (!strlen(test_type) || !strcmp(test_type, "test_tail_calls")) {
+		ret = prepare_tail_call_tests(&progs);
+		if (ret)
+			return ret;
+		ret = test_tail_calls(progs);
+		destroy_tail_call_tests(progs);
+		if (ret)
+			return ret;
+	}
 
-	ret = prepare_tail_call_tests(&progs);
-	if (ret)
-		return ret;
-	ret = test_tail_calls(progs);
-	destroy_tail_call_tests(progs);
-	if (ret)
-		return ret;
+	if (!strlen(test_type) || !strcmp(test_type, "test_skb_segment"))
+		return test_skb_segment();
 
-	return test_skb_segment();
+	return 0;
 }
 
 static void __exit test_bpf_exit(void)
-- 
2.1.0

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2021-09-30 14:39 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-30 14:07 [PATCH bpf-next v2] test_bpf: add module parameter test_type Tiezhu Yang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).