Commit c4d3b488 authored by Manu Bretelle's avatar Manu Bretelle Committed by Andrii Nakryiko

selftests/bpf: Reset err when symbol name already exist in kprobe_multi_test

When trying to add a name to the hashmap, an error code of EEXIST is
returned and we continue as names are possibly duplicated in the sys
file.

If the last name in the file is a duplicate, we will continue to the
next iteration of the while loop, and exit the loop with a value of err
set to EEXIST and enter the error label with err set, which causes the
test to fail when it should not.

This change reset err to 0 before continue-ing into the next iteration,
this way, if there is no more data to read from the file we iterate
through, err will be set to 0.

Behaviour prior to this change:
```
test_kprobe_multi_bench_attach:FAIL:get_syms unexpected error: -17
(errno 2)

All error logs:
test_kprobe_multi_bench_attach:FAIL:get_syms unexpected error: -17
(errno 2)
Summary: 0/1 PASSED, 0 SKIPPED, 1 FAILED
```

After this change:
```
Summary: 1/2 PASSED, 0 SKIPPED, 0 FAILED
```
Signed-off-by: default avatarManu Bretelle <chantr4@gmail.com>
Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20230408022919.54601-1-chantr4@gmail.com
parent 5855b099
...@@ -381,8 +381,10 @@ static int get_syms(char ***symsp, size_t *cntp, bool kernel) ...@@ -381,8 +381,10 @@ static int get_syms(char ***symsp, size_t *cntp, bool kernel)
continue; continue;
err = hashmap__add(map, name, 0); err = hashmap__add(map, name, 0);
if (err == -EEXIST) if (err == -EEXIST) {
err = 0;
continue; continue;
}
if (err) if (err)
goto error; goto error;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment