]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
selftests/bpf: Make reg_bounds test more robust
authorAlexei Starovoitov <ast@kernel.org>
Wed, 25 Mar 2026 01:22:42 +0000 (18:22 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 25 Mar 2026 15:50:33 +0000 (08:50 -0700)
The verifier log output may contain multiple lines that start with
18: (bf) r0 = r6
teach reg_bounds to look for lines that have ';' in them,
since reg_bounds test is looking for:
18: (bf) r0 = r6       ; R0=... R6=...

Reviewed-by: Emil Tsalapatis <emil@etsalapatis.com>
Link: https://lore.kernel.org/r/20260325012242.45606-1-alexei.starovoitov@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/prog_tests/reg_bounds.c

index cb8dd2f63296b826491c8a010f4ece4aa20c0560..569ae09bdd76c7a0bffee34e8203ae44cb7d5148 100644 (file)
@@ -1217,7 +1217,23 @@ static int parse_range_cmp_log(const char *log_buf, struct case_spec spec,
                        spec.compare_subregs ? "w0" : "r0",
                        spec.compare_subregs ? "w" : "r", specs[i].reg_idx);
 
-               q = strstr(p, buf);
+               /*
+                * In the verifier log look for lines:
+                *   18: (bf) r0 = r6       ; R0=... R6=...
+                * Different verifier passes may print
+                *   18: (bf) r0 = r6
+                * as well, but never followed by ';'.
+                */
+               q = p;
+               while ((q = strstr(q, buf)) != NULL) {
+                       const char *s = q + strlen(buf);
+
+                       while (*s == ' ' || *s == '\t')
+                               s++;
+                       if (*s == ';')
+                               break;
+                       q = s;
+               }
                if (!q) {
                        *specs[i].state = (struct reg_state){.valid = false};
                        continue;