[PATCH 1/6] tests/bpf-success-long-y: skip when no /proc
Alyssa Ross
hi at alyssa.is
Tue May 4 19:40:53 UTC 2021
---
tests/bpf-success-long-y.c | 2 ++
tests/bpf-success-long-y.test | 4 ++++
tests/bpf.c | 6 ++++++
3 files changed, 12 insertions(+)
diff --git a/tests/bpf-success-long-y.c b/tests/bpf-success-long-y.c
index d0e9b2a9..02c9466d 100644
--- a/tests/bpf-success-long-y.c
+++ b/tests/bpf-success-long-y.c
@@ -1,3 +1,5 @@
#define INJECT_RETVAL ((long) 0xbadc0de1e55beefULL)
#define FD0_PATH "</dev/full>"
+#define SKIP_IF_PROC_IS_UNAVAILABLE skip_if_unavailable("/proc/self/fd/")
+
#include "bpf.c"
diff --git a/tests/bpf-success-long-y.test b/tests/bpf-success-long-y.test
index 0ecc7e01..e78c9978 100755
--- a/tests/bpf-success-long-y.test
+++ b/tests/bpf-success-long-y.test
@@ -12,5 +12,9 @@ case "$SIZEOF_LONG" in
8) rval=841540765612359407;;
esac
+../bpf-success-long-y || if [ $? -eq 77 ]; then
+ skip_ "bpf-success-long-y exited with code 77"
+fi
+
run_strace -a20 -y -e trace=bpf -e inject=bpf:retval="${rval}" ../bpf-success-long-y < /dev/full > "$EXP"
match_diff "$LOG" "$EXP"
diff --git a/tests/bpf.c b/tests/bpf.c
index 9b33e5d8..d5fed4dc 100644
--- a/tests/bpf.c
+++ b/tests/bpf.c
@@ -57,6 +57,10 @@ struct bpf_insn {
};
#endif
+#ifndef SKIP_IF_PROC_IS_UNAVAILABLE
+# define SKIP_IF_PROC_IS_UNAVAILABLE
+#endif
+
#define BPF_ATTR_DATA_FIELD(cmd_) struct cmd_ ## _struct cmd_ ## _data
union bpf_attr_data {
@@ -1449,6 +1453,8 @@ static const struct bpf_attr_check BPF_LINK_UPDATE_checks[] = {
int
main(void)
{
+ SKIP_IF_PROC_IS_UNAVAILABLE;
+
static const struct bpf_check checks[] = {
CHK(BPF_MAP_CREATE),
CHK(BPF_MAP_LOOKUP_ELEM),
--
2.31.0
More information about the Strace-devel
mailing list