diff options
| author | Bastien Curutchet (eBPF Foundation) <bastien.curutchet@bootlin.com> | 2025-01-31 08:21:40 +0100 |
|---|---|---|
| committer | Alexei Starovoitov <ast@kernel.org> | 2025-02-03 03:33:51 -0800 |
| commit | 723f1b9ce332ae50dede24daa7a1abc0c87a6f83 (patch) | |
| tree | e67e34caa7e52efcca61a4966dd730893a954712 /tools/testing/selftests/bpf/network_helpers.c | |
| parent | 12fdd29d5d71d2987a1aec434b704d850a4d7fcb (diff) | |
selftests/bpf: helpers: Add append_tid()
Some tests can't be run in parallel because they use same namespace
names or veth names.
Create an helper that appends the thread ID to a given string. 8
characters are used for it (7 digits + '\0')
Signed-off-by: Bastien Curutchet (eBPF Foundation) <bastien.curutchet@bootlin.com>
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
Link: https://patch.msgid.link/20250131-redirect-multi-v4-1-970b33678512@bootlin.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'tools/testing/selftests/bpf/network_helpers.c')
| -rw-r--r-- | tools/testing/selftests/bpf/network_helpers.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/network_helpers.c b/tools/testing/selftests/bpf/network_helpers.c index 80844a5fb1fe..a4252e000428 100644 --- a/tools/testing/selftests/bpf/network_helpers.c +++ b/tools/testing/selftests/bpf/network_helpers.c @@ -446,6 +446,23 @@ char *ping_command(int family) return "ping"; } +int append_tid(char *str, size_t sz) +{ + size_t end; + + if (!str) + return -1; + + end = strlen(str); + if (end + 8 > sz) + return -1; + + sprintf(&str[end], "%07d", gettid()); + str[end + 7] = '\0'; + + return 0; +} + int remove_netns(const char *name) { char *cmd; |