summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/bpf/test_progs.h
diff options
context:
space:
mode:
authorMykola Lysenko <mykolal@fb.com>2022-04-26 21:13:53 -0700
committerAndrii Nakryiko <andrii@kernel.org>2022-04-27 19:03:58 -0700
commit0925225956bbef863d51ee882d4d20c9a9c90db2 (patch)
tree9b4e346fafe58dbfa2e60031c669455fa68a743f /tools/testing/selftests/bpf/test_progs.h
parent50c6afabfd2ae91a4ff0e2feb14fe702b0688ec5 (diff)
bpf/selftests: Add granular subtest output for prog_test
Implement per subtest log collection for both parallel and sequential test execution. This allows granular per-subtest error output in the 'All error logs' section. Add subtest log transfer into the protocol during the parallel test execution. Move all test log printing logic into dump_test_log function. One exception is the output of test names when verbose printing is enabled. Move test name/result printing into separate functions to avoid repetition. Print all successful subtest results in the log. Print only failed test logs when test does not have subtests. Or only failed subtests' logs when test has subtests. Disable 'All error logs' output when verbose mode is enabled. This functionality was already broken and is causing confusion. Signed-off-by: Mykola Lysenko <mykolal@fb.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20220427041353.246007-1-mykolal@fb.com
Diffstat (limited to 'tools/testing/selftests/bpf/test_progs.h')
-rw-r--r--tools/testing/selftests/bpf/test_progs.h35
1 files changed, 27 insertions, 8 deletions
diff --git a/tools/testing/selftests/bpf/test_progs.h b/tools/testing/selftests/bpf/test_progs.h
index d3fee3b98888..dd1b91d7985a 100644
--- a/tools/testing/selftests/bpf/test_progs.h
+++ b/tools/testing/selftests/bpf/test_progs.h
@@ -64,23 +64,31 @@ struct test_selector {
int num_set_len;
};
+struct subtest_state {
+ char *name;
+ size_t log_cnt;
+ char *log_buf;
+ int error_cnt;
+ bool skipped;
+
+ FILE *stdout;
+};
+
struct test_state {
bool tested;
bool force_log;
int error_cnt;
int skip_cnt;
- int subtest_skip_cnt;
int sub_succ_cnt;
- char *subtest_name;
+ struct subtest_state *subtest_states;
int subtest_num;
- /* store counts before subtest started */
- int old_error_cnt;
-
size_t log_cnt;
char *log_buf;
+
+ FILE *stdout;
};
struct test_env {
@@ -96,7 +104,8 @@ struct test_env {
bool list_test_names;
struct prog_test_def *test; /* current running test */
- struct test_state *test_state; /* current running test result */
+ struct test_state *test_state; /* current running test state */
+ struct subtest_state *subtest_state; /* current running subtest state */
FILE *stdout;
FILE *stderr;
@@ -116,29 +125,39 @@ struct test_env {
};
#define MAX_LOG_TRUNK_SIZE 8192
+#define MAX_SUBTEST_NAME 1024
enum msg_type {
MSG_DO_TEST = 0,
MSG_TEST_DONE = 1,
MSG_TEST_LOG = 2,
+ MSG_SUBTEST_DONE = 3,
MSG_EXIT = 255,
};
struct msg {
enum msg_type type;
union {
struct {
- int test_num;
+ int num;
} do_test;
struct {
- int test_num;
+ int num;
int sub_succ_cnt;
int error_cnt;
int skip_cnt;
bool have_log;
+ int subtest_num;
} test_done;
struct {
char log_buf[MAX_LOG_TRUNK_SIZE + 1];
bool is_last;
} test_log;
+ struct {
+ int num;
+ char name[MAX_SUBTEST_NAME + 1];
+ int error_cnt;
+ bool skipped;
+ bool have_log;
+ } subtest_done;
};
};