Thread (40 messages) flat view 40 messages, 4 authors, 2020-07-30

Re: [PATCH v8 bpf-next 12/13] selftests/bpf: Add test for d_path helper

From: Jiri Olsa <hidden>
Date: 2020-07-29 11:25:33
Also in: bpf

On Tue, Jul 28, 2020 at 12:53:00PM -0700, Andrii Nakryiko wrote:

SNIP
quoted
+       if (CHECK_FAIL(ret < 0))
+               goto out_close;
+       ret = set_pathname(procfd, pid);
+       if (CHECK_FAIL(ret < 0))
+               goto out_close;
+       ret = set_pathname(devfd, pid);
+       if (CHECK_FAIL(ret < 0))
+               goto out_close;
+       ret = set_pathname(localfd, pid);
+       if (CHECK_FAIL(ret < 0))
+               goto out_close;
+       ret = set_pathname(indicatorfd, pid);
+       if (CHECK_FAIL(ret < 0))
+               goto out_close;
Please use CHECK instead of CHECK_FAIL. Thanks.
ok
quoted
diff --git a/tools/testing/selftests/bpf/progs/test_d_path.c b/tools/testing/selftests/bpf/progs/test_d_path.c
new file mode 100644
index 000000000000..e02dce614256
--- /dev/null
+++ b/tools/testing/selftests/bpf/progs/test_d_path.c
@@ -0,0 +1,64 @@
+// SPDX-License-Identifier: GPL-2.0
+
+#include "vmlinux.h"
+#include <bpf/bpf_helpers.h>
+#include <bpf/bpf_tracing.h>
+
+#define MAX_PATH_LEN           128
+#define MAX_EVENT_NUM          16
+
+pid_t my_pid;
+__u32 cnt_stat;
+__u32 cnt_close;
+char paths_stat[MAX_EVENT_NUM][MAX_PATH_LEN];
+char paths_close[MAX_EVENT_NUM][MAX_PATH_LEN];
+int rets_stat[MAX_EVENT_NUM];
+int rets_close[MAX_EVENT_NUM];
+
please zero-initialize all of these, it causes issues on some Clang versions
ook

jirka
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help