aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/bpf/test_progs.h
diff options
context:
space:
mode:
authorStanislav Fomichev <sdf@google.com>2019-08-21 16:44:25 -0700
committerDaniel Borkmann <daniel@iogearbox.net>2019-08-28 00:35:40 +0200
commitd38835b75f67df16cef65c14aa64796a1832e6b4 (patch)
tree2ec02d43503dcbcde612f61821e5baa1f8ae25b8 /tools/testing/selftests/bpf/test_progs.h
parentselftests/bpf: test_progs: test__skip (diff)
downloadlinux-dev-d38835b75f67df16cef65c14aa64796a1832e6b4.tar.xz
linux-dev-d38835b75f67df16cef65c14aa64796a1832e6b4.zip
selftests/bpf: test_progs: remove global fail/success counts
Now that we have a global per-test/per-environment state, there is no longer need to have global fail/success counters (and there is no need to save/get the diff before/after the test). Introduce CHECK_FAIL macro (suggested by Andrii) and covert existing tests to it. CHECK_FAIL uses new test__fail() to record the failure. Cc: Andrii Nakryiko <andriin@fb.com> Signed-off-by: Stanislav Fomichev <sdf@google.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Diffstat (limited to 'tools/testing/selftests/bpf/test_progs.h')
-rw-r--r--tools/testing/selftests/bpf/test_progs.h17
1 files changed, 11 insertions, 6 deletions
diff --git a/tools/testing/selftests/bpf/test_progs.h b/tools/testing/selftests/bpf/test_progs.h
index 9defd35cb6c0..33da849cb765 100644
--- a/tools/testing/selftests/bpf/test_progs.h
+++ b/tools/testing/selftests/bpf/test_progs.h
@@ -38,8 +38,6 @@ typedef __u16 __sum16;
#include "trace_helpers.h"
#include "flow_dissector_load.h"
-struct prog_test_def;
-
struct test_selector {
const char *name;
bool *num_set;
@@ -67,13 +65,12 @@ struct test_env {
int skip_cnt; /* skipped tests */
};
-extern int error_cnt;
-extern int pass_cnt;
extern struct test_env env;
extern void test__force_log();
extern bool test__start_subtest(const char *name);
extern void test__skip(void);
+extern void test__fail(void);
#define MAGIC_BYTES 123
@@ -96,17 +93,25 @@ extern struct ipv6_packet pkt_v6;
#define _CHECK(condition, tag, duration, format...) ({ \
int __ret = !!(condition); \
if (__ret) { \
- error_cnt++; \
+ test__fail(); \
printf("%s:FAIL:%s ", __func__, tag); \
printf(format); \
} else { \
- pass_cnt++; \
printf("%s:PASS:%s %d nsec\n", \
__func__, tag, duration); \
} \
__ret; \
})
+#define CHECK_FAIL(condition) ({ \
+ int __ret = !!(condition); \
+ if (__ret) { \
+ test__fail(); \
+ printf("%s:FAIL:%d ", __func__, __LINE__); \
+ } \
+ __ret; \
+})
+
#define CHECK(condition, tag, format...) \
_CHECK(condition, tag, duration, format)
#define CHECK_ATTR(condition, tag, format...) \