Skip to contentSkip to conversation

selftests/bpf: move sockopt tests under test_progs

PATCH Applied Stanislav Fomichev 4 participants 12 messages Sep 4, 2019 – Sep 6, 2019

Subsystems (5)

v1 of 2 Applied Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover selftests/bpf: move sockopt tests under test_progs

Now that test_progs is shaping into more generic test framework, let's convert sockopt tests to it. This requires adding a helper to create and join a cgroup first (test__join_cgroup). Since we already hijack stdout/stderr that shouldn't be a problem (cgroup helpers log to stderr).

The rest of the patches just move sockopt tests files under prog_tests/ and do the required small adjustments.

Stanislav Fomichev (6):
selftests/bpf: test_progs: add test__join_cgroup helper selftests/bpf: test_progs: convert test_sockopt selftests/bpf: test_progs: convert test_sockopt_sk selftests/bpf: test_progs: convert test_sockopt_multi selftests/bpf: test_progs: convert test_sockopt_inherit selftests/bpf: test_progs: convert test_tcp_rtt

 tools/testing/selftests/bpf/.gitignore        |   5 -
 tools/testing/selftests/bpf/Makefile          |  12 +--
 .../{test_sockopt.c => prog_tests/sockopt.c}  |  50 ++-------
 .../sockopt_inherit.c}                        | 102 ++++++++----------
 .../sockopt_multi.c}                          |  62 ++---------
 .../sockopt_sk.c}                             |  60 +++--------
 .../{test_tcp_rtt.c => prog_tests/tcp_rtt.c}  |  83 +++++---------
 tools/testing/selftests/bpf/test_progs.c      |  38 +++++++
 tools/testing/selftests/bpf/test_progs.h      |   4 +-
 9 files changed, 142 insertions(+), 274 deletions(-)
 rename tools/testing/selftests/bpf/{test_sockopt.c => prog_tests/sockopt.c} (96%)
 rename tools/testing/selftests/bpf/{test_sockopt_inherit.c => prog_tests/sockopt_inherit.c} (72%)
 rename tools/testing/selftests/bpf/{test_sockopt_multi.c => prog_tests/sockopt_multi.c} (83%)
 rename tools/testing/selftests/bpf/{test_sockopt_sk.c => prog_tests/sockopt_sk.c} (79%)
 rename tools/testing/selftests/bpf/{test_tcp_rtt.c => prog_tests/tcp_rtt.c} (76%)
Signature · 1 line
2.23.0.187.g17f5b7556c-goog
#1 lore raw

PATCH 1/6 selftests/bpf: test_progs: add test__join_cgroup helper

test__join_cgroup() combines the following operations that usually go hand in hand and returns cgroup fd:

* setup cgroup environment (make sure cgroupfs is mounted)
* mkdir cgroup
* join cgroup

It also marks a test as a "cgroup cleanup needed" and removes cgroup state after the test is done.

---
 tools/testing/selftests/bpf/Makefile     |  4 +--
 tools/testing/selftests/bpf/test_progs.c | 38 ++++++++++++++++++++++++
 tools/testing/selftests/bpf/test_progs.h |  1 +
 3 files changed, 41 insertions(+), 2 deletions(-)
tools/testing/selftests/bpf/Makefile +2 -2
index c7595b4ed55d..e145954d3765 100644
@@ -102,7 +102,7 @@ $(OUTPUT)/test_socket_cookie: cgroup_helpers.c
 $(OUTPUT)/test_sockmap: cgroup_helpers.c
 $(OUTPUT)/test_tcpbpf_user: cgroup_helpers.c
 $(OUTPUT)/test_tcpnotify_user: cgroup_helpers.c trace_helpers.c
-$(OUTPUT)/test_progs: trace_helpers.c
+$(OUTPUT)/test_progs: cgroup_helpers.c trace_helpers.c
 $(OUTPUT)/get_cgroup_id_user: cgroup_helpers.c
 $(OUTPUT)/test_cgroup_storage: cgroup_helpers.c
 $(OUTPUT)/test_netcnt: cgroup_helpers.c
@@ -196,7 +196,7 @@ $(ALU32_BUILD_DIR)/test_progs_32: test_progs.c $(OUTPUT)/libbpf.a\
 						| $(ALU32_BUILD_DIR)
 	$(CC) $(TEST_PROGS_CFLAGS) $(CFLAGS) \
 		-o $(ALU32_BUILD_DIR)/test_progs_32 \
-		test_progs.c test_stub.c trace_helpers.c prog_tests/*.c \
+		test_progs.c test_stub.c cgroup_helpers.c trace_helpers.c prog_tests/*.c \
 		$(OUTPUT)/libbpf.a $(LDLIBS)
 
 $(ALU32_BUILD_DIR)/test_progs_32: $(PROG_TESTS_H)
tools/testing/selftests/bpf/test_progs.c +38 -0
index e8616e778cb5..af75a1c7a458 100644
@@ -2,6 +2,7 @@
 /* Copyright (c) 2017 Facebook
  */
 #include "test_progs.h"
+#include "cgroup_helpers.h"
 #include "bpf_rlimit.h"
 #include <argp.h>
 #include <string.h>
@@ -17,6 +18,7 @@ struct prog_test_def {
 	int error_cnt;
 	int skip_cnt;
 	bool tested;
+	bool need_cgroup_cleanup;
 
 	const char *subtest_name;
 	int subtest_num;
@@ -122,6 +124,39 @@ void test__fail(void)
 	env.test->error_cnt++;
 }
 
+int test__join_cgroup(const char *path)
+{
+	int fd;
+
+	if (!env.test->need_cgroup_cleanup) {
+		if (setup_cgroup_environment()) {
+			fprintf(stderr,
+				"#%d %s: Failed to setup cgroup environment\n",
+				env.test->test_num, env.test->test_name);
+			return -1;
+		}
+
+		env.test->need_cgroup_cleanup = true;
+	}
+
+	fd = create_and_get_cgroup(path);
+	if (fd < 0) {
+		fprintf(stderr,
+			"#%d %s: Failed to create cgroup '%s' (errno=%d)\n",
+			env.test->test_num, env.test->test_name, path, errno);
+		return fd;
+	}
+
+	if (join_cgroup(path)) {
+		fprintf(stderr,
+			"#%d %s: Failed to join cgroup '%s' (errno=%d)\n",
+			env.test->test_num, env.test->test_name, path, errno);
+		return -1;
+	}
+
+	return fd;
+}
+
 struct ipv4_packet pkt_v4 = {
 	.eth.h_proto = __bpf_constant_htons(ETH_P_IP),
 	.iph.ihl = 5,
@@ -530,6 +565,9 @@ int main(int argc, char **argv)
 		fprintf(env.stdout, "#%d %s:%s\n",
 			test->test_num, test->test_name,
 			test->error_cnt ? "FAIL" : "OK");
+
+		if (test->need_cgroup_cleanup)
+			cleanup_cgroup_environment();
 	}
 	stdio_restore();
 	printf("Summary: %d/%d PASSED, %d SKIPPED, %d FAILED\n",
tools/testing/selftests/bpf/test_progs.h +1 -0
index c8edb9464ba6..e518bd5da3e2 100644
@@ -71,6 +71,7 @@ extern void test__force_log();
 extern bool test__start_subtest(const char *name);
 extern void test__skip(void);
 extern void test__fail(void);
+extern int test__join_cgroup(const char *path);
 
 #define MAGIC_BYTES 123
 
Signature · 1 line
2.23.0.187.g17f5b7556c-goog
#2 lore raw

PATCH 2/6 selftests/bpf: test_progs: convert test_sockopt

In reply to Stanislav Fomichev

Move the files, adjust includes, remove entry from Makefile & .gitignore

---
 tools/testing/selftests/bpf/.gitignore        |  1 -
 tools/testing/selftests/bpf/Makefile          |  3 +-
 .../{test_sockopt.c => prog_tests/sockopt.c}  | 50 +++----------------
 3 files changed, 8 insertions(+), 46 deletions(-)
 rename tools/testing/selftests/bpf/{test_sockopt.c => prog_tests/sockopt.c} (96%)
tools/testing/selftests/bpf/.gitignore +0 -1
index 60c9338cd9b4..0315120eac8f 100644
@@ -39,7 +39,6 @@ libbpf.so.*
 test_hashmap
 test_btf_dump
 xdping
-test_sockopt
 test_sockopt_sk
 test_sockopt_multi
 test_sockopt_inherit
tools/testing/selftests/bpf/Makefile +1 -2
index e145954d3765..08e2183974d5 100644
@@ -28,7 +28,7 @@ TEST_GEN_PROGS = test_verifier test_tag test_maps test_lru_map test_lpm_map test
 	test_sock test_btf test_sockmap get_cgroup_id_user test_socket_cookie \
 	test_cgroup_storage test_select_reuseport test_section_names \
 	test_netcnt test_tcpnotify_user test_sock_fields test_sysctl test_hashmap \
-	test_btf_dump test_cgroup_attach xdping test_sockopt test_sockopt_sk \
+	test_btf_dump test_cgroup_attach xdping test_sockopt_sk \
 	test_sockopt_multi test_sockopt_inherit test_tcp_rtt
 
 BPF_OBJ_FILES = $(patsubst %.c,%.o, $(notdir $(wildcard progs/*.c)))
@@ -109,7 +109,6 @@ $(OUTPUT)/test_netcnt: cgroup_helpers.c
 $(OUTPUT)/test_sock_fields: cgroup_helpers.c
 $(OUTPUT)/test_sysctl: cgroup_helpers.c
 $(OUTPUT)/test_cgroup_attach: cgroup_helpers.c
-$(OUTPUT)/test_sockopt: cgroup_helpers.c
 $(OUTPUT)/test_sockopt_sk: cgroup_helpers.c
 $(OUTPUT)/test_sockopt_multi: cgroup_helpers.c
 $(OUTPUT)/test_sockopt_inherit: cgroup_helpers.c
tools/testing/selftests/bpf/prog_tests/sockopt.c renamed from tools/testing/selftests/bpf/test_sockopt.c +7 -43

68 lines not on this page · raw message

Signature · 1 line
2.23.0.187.g17f5b7556c-goog
#3 lore raw

PATCH 3/6 selftests/bpf: test_progs: convert test_sockopt_sk

In reply to Stanislav Fomichev

Move the files, adjust includes, remove entry from Makefile & .gitignore

---
 tools/testing/selftests/bpf/.gitignore        |  1 -
 tools/testing/selftests/bpf/Makefile          |  3 +-
 .../sockopt_sk.c}                             | 60 ++++---------------
 tools/testing/selftests/bpf/test_progs.h      |  3 +-
 4 files changed, 15 insertions(+), 52 deletions(-)
 rename tools/testing/selftests/bpf/{test_sockopt_sk.c => prog_tests/sockopt_sk.c} (79%)
tools/testing/selftests/bpf/.gitignore +0 -1
index 0315120eac8f..bc83c1a7ea1b 100644
@@ -39,7 +39,6 @@ libbpf.so.*
 test_hashmap
 test_btf_dump
 xdping
-test_sockopt_sk
 test_sockopt_multi
 test_sockopt_inherit
 test_tcp_rtt
tools/testing/selftests/bpf/Makefile +1 -2
index 08e2183974d5..ea790901297c 100644
@@ -28,7 +28,7 @@ TEST_GEN_PROGS = test_verifier test_tag test_maps test_lru_map test_lpm_map test
 	test_sock test_btf test_sockmap get_cgroup_id_user test_socket_cookie \
 	test_cgroup_storage test_select_reuseport test_section_names \
 	test_netcnt test_tcpnotify_user test_sock_fields test_sysctl test_hashmap \
-	test_btf_dump test_cgroup_attach xdping test_sockopt_sk \
+	test_btf_dump test_cgroup_attach xdping \
 	test_sockopt_multi test_sockopt_inherit test_tcp_rtt
 
 BPF_OBJ_FILES = $(patsubst %.c,%.o, $(notdir $(wildcard progs/*.c)))
@@ -109,7 +109,6 @@ $(OUTPUT)/test_netcnt: cgroup_helpers.c
 $(OUTPUT)/test_sock_fields: cgroup_helpers.c
 $(OUTPUT)/test_sysctl: cgroup_helpers.c
 $(OUTPUT)/test_cgroup_attach: cgroup_helpers.c
-$(OUTPUT)/test_sockopt_sk: cgroup_helpers.c
 $(OUTPUT)/test_sockopt_multi: cgroup_helpers.c
 $(OUTPUT)/test_sockopt_inherit: cgroup_helpers.c
 $(OUTPUT)/test_tcp_rtt: cgroup_helpers.c
tools/testing/selftests/bpf/prog_tests/sockopt_sk.c renamed from tools/testing/selftests/bpf/test_sockopt_sk.c +12 -48

93 lines not on this page · raw message

tools/testing/selftests/bpf/test_progs.h +2 -1
index e518bd5da3e2..0c48f64f732b 100644
@@ -16,9 +16,10 @@ typedef __u16 __sum16;
 #include <linux/if_packet.h>
 #include <linux/ip.h>
 #include <linux/ipv6.h>
-#include <linux/tcp.h>
+#include <netinet/tcp.h>
 #include <linux/filter.h>
 #include <linux/perf_event.h>
+#include <linux/socket.h>
 #include <linux/unistd.h>
 
 #include <sys/ioctl.h>
Signature · 1 line
2.23.0.187.g17f5b7556c-goog
#4 lore raw

PATCH 4/6 selftests/bpf: test_progs: convert test_sockopt_multi

In reply to Stanislav Fomichev

Move the files, adjust includes, remove entry from Makefile & .gitignore

---
 tools/testing/selftests/bpf/.gitignore        |  1 -
 tools/testing/selftests/bpf/Makefile          |  3 +-
 .../sockopt_multi.c}                          | 62 +++----------------
 3 files changed, 11 insertions(+), 55 deletions(-)
 rename tools/testing/selftests/bpf/{test_sockopt_multi.c => prog_tests/sockopt_multi.c} (83%)
tools/testing/selftests/bpf/.gitignore +0 -1
index bc83c1a7ea1b..4143add5a11e 100644
@@ -39,6 +39,5 @@ libbpf.so.*
 test_hashmap
 test_btf_dump
 xdping
-test_sockopt_multi
 test_sockopt_inherit
 test_tcp_rtt
tools/testing/selftests/bpf/Makefile +1 -2
index ea790901297c..271f8ce89c97 100644
@@ -29,7 +29,7 @@ TEST_GEN_PROGS = test_verifier test_tag test_maps test_lru_map test_lpm_map test
 	test_cgroup_storage test_select_reuseport test_section_names \
 	test_netcnt test_tcpnotify_user test_sock_fields test_sysctl test_hashmap \
 	test_btf_dump test_cgroup_attach xdping \
-	test_sockopt_multi test_sockopt_inherit test_tcp_rtt
+	test_sockopt_inherit test_tcp_rtt
 
 BPF_OBJ_FILES = $(patsubst %.c,%.o, $(notdir $(wildcard progs/*.c)))
 TEST_GEN_FILES = $(BPF_OBJ_FILES)
@@ -109,7 +109,6 @@ $(OUTPUT)/test_netcnt: cgroup_helpers.c
 $(OUTPUT)/test_sock_fields: cgroup_helpers.c
 $(OUTPUT)/test_sysctl: cgroup_helpers.c
 $(OUTPUT)/test_cgroup_attach: cgroup_helpers.c
-$(OUTPUT)/test_sockopt_multi: cgroup_helpers.c
 $(OUTPUT)/test_sockopt_inherit: cgroup_helpers.c
 $(OUTPUT)/test_tcp_rtt: cgroup_helpers.c
 
tools/testing/selftests/bpf/prog_tests/sockopt_multi.c renamed from tools/testing/selftests/bpf/test_sockopt_multi.c +10 -52

92 lines not on this page · raw message

Signature · 1 line
2.23.0.187.g17f5b7556c-goog
#5 lore raw

PATCH 5/6 selftests/bpf: test_progs: convert test_sockopt_inherit

In reply to Stanislav Fomichev

Move the files, adjust includes, remove entry from Makefile & .gitignore

I also added pthread_cond_wait for the server thread startup. We don't want to connect to the server that's not yet up (for some reason this existing race is now more prominent with test_progs).

---
 tools/testing/selftests/bpf/.gitignore        |   1 -
 tools/testing/selftests/bpf/Makefile          |   4 +-
 .../sockopt_inherit.c}                        | 102 ++++++++----------
 3 files changed, 43 insertions(+), 64 deletions(-)
 rename tools/testing/selftests/bpf/{test_sockopt_inherit.c => prog_tests/sockopt_inherit.c} (72%)
tools/testing/selftests/bpf/.gitignore +0 -1
index 4143add5a11e..5b06bb45b500 100644
@@ -39,5 +39,4 @@ libbpf.so.*
 test_hashmap
 test_btf_dump
 xdping
-test_sockopt_inherit
 test_tcp_rtt
tools/testing/selftests/bpf/Makefile +1 -3
index 271f8ce89c97..fe786df1174b 100644
@@ -28,8 +28,7 @@ TEST_GEN_PROGS = test_verifier test_tag test_maps test_lru_map test_lpm_map test
 	test_sock test_btf test_sockmap get_cgroup_id_user test_socket_cookie \
 	test_cgroup_storage test_select_reuseport test_section_names \
 	test_netcnt test_tcpnotify_user test_sock_fields test_sysctl test_hashmap \
-	test_btf_dump test_cgroup_attach xdping \
-	test_sockopt_inherit test_tcp_rtt
+	test_btf_dump test_cgroup_attach xdping test_tcp_rtt
 
 BPF_OBJ_FILES = $(patsubst %.c,%.o, $(notdir $(wildcard progs/*.c)))
 TEST_GEN_FILES = $(BPF_OBJ_FILES)
@@ -109,7 +108,6 @@ $(OUTPUT)/test_netcnt: cgroup_helpers.c
 $(OUTPUT)/test_sock_fields: cgroup_helpers.c
 $(OUTPUT)/test_sysctl: cgroup_helpers.c
 $(OUTPUT)/test_cgroup_attach: cgroup_helpers.c
-$(OUTPUT)/test_sockopt_inherit: cgroup_helpers.c
 $(OUTPUT)/test_tcp_rtt: cgroup_helpers.c
 
 .PHONY: force
tools/testing/selftests/bpf/prog_tests/sockopt_inherit.c renamed from tools/testing/selftests/bpf/test_sockopt_inherit.c +42 -60

166 lines not on this page · raw message

Signature · 1 line
2.23.0.187.g17f5b7556c-goog
#6 lore raw

PATCH 6/6 selftests/bpf: test_progs: convert test_tcp_rtt

In reply to Stanislav Fomichev

Move the files, adjust includes, remove entry from Makefile & .gitignore

---
 tools/testing/selftests/bpf/.gitignore        |  1 -
 tools/testing/selftests/bpf/Makefile          |  3 +-
 .../{test_tcp_rtt.c => prog_tests/tcp_rtt.c}  | 83 ++++++-------------
 3 files changed, 28 insertions(+), 59 deletions(-)
 rename tools/testing/selftests/bpf/{test_tcp_rtt.c => prog_tests/tcp_rtt.c} (76%)
tools/testing/selftests/bpf/.gitignore +0 -1
index 5b06bb45b500..7470327edcfe 100644
@@ -39,4 +39,3 @@ libbpf.so.*
 test_hashmap
 test_btf_dump
 xdping
-test_tcp_rtt
tools/testing/selftests/bpf/Makefile +1 -2
index fe786df1174b..811f1b24d02b 100644
@@ -28,7 +28,7 @@ TEST_GEN_PROGS = test_verifier test_tag test_maps test_lru_map test_lpm_map test
 	test_sock test_btf test_sockmap get_cgroup_id_user test_socket_cookie \
 	test_cgroup_storage test_select_reuseport test_section_names \
 	test_netcnt test_tcpnotify_user test_sock_fields test_sysctl test_hashmap \
-	test_btf_dump test_cgroup_attach xdping test_tcp_rtt
+	test_btf_dump test_cgroup_attach xdping
 
 BPF_OBJ_FILES = $(patsubst %.c,%.o, $(notdir $(wildcard progs/*.c)))
 TEST_GEN_FILES = $(BPF_OBJ_FILES)
@@ -108,7 +108,6 @@ $(OUTPUT)/test_netcnt: cgroup_helpers.c
 $(OUTPUT)/test_sock_fields: cgroup_helpers.c
 $(OUTPUT)/test_sysctl: cgroup_helpers.c
 $(OUTPUT)/test_cgroup_attach: cgroup_helpers.c
-$(OUTPUT)/test_tcp_rtt: cgroup_helpers.c
 
 .PHONY: force
 
tools/testing/selftests/bpf/prog_tests/tcp_rtt.c renamed from tools/testing/selftests/bpf/test_tcp_rtt.c +27 -56

128 lines not on this page · raw message

Signature · 1 line
2.23.0.187.g17f5b7556c-goog
#7 lore raw
In reply to Stanislav Fomichev
Quoted 8 lines · Stanislav Fomichev

Now that test_progs is shaping into more generic test framework, let's convert sockopt tests to it. This requires adding a helper to create and join a cgroup first (test__join_cgroup). Since we already hijack stdout/stderr that shouldn't be a problem (cgroup helpers log to stderr).

The rest of the patches just move sockopt tests files under prog_tests/ and do the required small adjustments.

Looks good. Thank you for working on it. Could you de-verbose setsockopt test a bit? #23/32 setsockopt: deny write ctx->retval:OK #23/33 setsockopt: deny read ctx->retval:OK #23/34 setsockopt: deny writing to ctx->optval:OK #23/35 setsockopt: deny writing to ctx->optval_end:OK #23/36 setsockopt: allow IP_TOS <= 128:OK #23/37 setsockopt: deny IP_TOS > 128:OK
37 subtests is a bit too much spam.

#8 lore raw
Quoted 11 lines · Alexei Starovoitov
Quoted 8 lines · Stanislav Fomichev

Now that test_progs is shaping into more generic test framework, let's convert sockopt tests to it. This requires adding a helper to create and join a cgroup first (test__join_cgroup). Since we already hijack stdout/stderr that shouldn't be a problem (cgroup helpers log to stderr).

The rest of the patches just move sockopt tests files under prog_tests/ and do the required small adjustments.

Quoted 9 lines

Looks good. Thank you for working on it. Could you de-verbose setsockopt test a bit? #23/32 setsockopt: deny write ctx->retval:OK #23/33 setsockopt: deny read ctx->retval:OK #23/34 setsockopt: deny writing to ctx->optval:OK #23/35 setsockopt: deny writing to ctx->optval_end:OK #23/36 setsockopt: allow IP_TOS <= 128:OK #23/37 setsockopt: deny IP_TOS > 128:OK
37 subtests is a bit too much spam.

If we merged test_btf into test_progs, we'd have >150 subtests, which would be pretty verbose as well. But the benefit of subtest is that you can run just that sub-test and debug/verify just it, without all the rest stuff.

So I'm wondering, if too many lines of default output is the only problem, should we just not output per-subtest line by default?

Quoted 1 line
#9 lore raw
Quoted 23 lines · Andrii Nakryiko
Quoted 11 lines · Alexei Starovoitov
Quoted 8 lines · Stanislav Fomichev

Now that test_progs is shaping into more generic test framework, let's convert sockopt tests to it. This requires adding a helper to create and join a cgroup first (test__join_cgroup). Since we already hijack stdout/stderr that shouldn't be a problem (cgroup helpers log to stderr).

The rest of the patches just move sockopt tests files under prog_tests/ and do the required small adjustments.

Quoted 9 lines

Looks good. Thank you for working on it. Could you de-verbose setsockopt test a bit? #23/32 setsockopt: deny write ctx->retval:OK #23/33 setsockopt: deny read ctx->retval:OK #23/34 setsockopt: deny writing to ctx->optval:OK #23/35 setsockopt: deny writing to ctx->optval_end:OK #23/36 setsockopt: allow IP_TOS <= 128:OK #23/37 setsockopt: deny IP_TOS > 128:OK
37 subtests is a bit too much spam.

Quoted 7 lines

If we merged test_btf into test_progs, we'd have >150 subtests, which would be pretty verbose as well. But the benefit of subtest is that you can run just that sub-test and debug/verify just it, without all the rest stuff.

So I'm wondering, if too many lines of default output is the only problem, should we just not output per-subtest line by default?

Ack, we can output per-subtest line if it fails so it's easy to re-run; otherwise, hiding by default sounds good. I'll prepare a v3 sometime today; Alexei, let us know if you disagree.

#10 lore raw
Quoted 29 lines · Stanislav Fomichev
Quoted 28 lines · Andrii Nakryiko
Quoted 11 lines · Alexei Starovoitov
Quoted 8 lines · Stanislav Fomichev

Now that test_progs is shaping into more generic test framework, let's convert sockopt tests to it. This requires adding a helper to create and join a cgroup first (test__join_cgroup). Since we already hijack stdout/stderr that shouldn't be a problem (cgroup helpers log to stderr).

The rest of the patches just move sockopt tests files under prog_tests/ and do the required small adjustments.

Quoted 9 lines

Looks good. Thank you for working on it. Could you de-verbose setsockopt test a bit? #23/32 setsockopt: deny write ctx->retval:OK #23/33 setsockopt: deny read ctx->retval:OK #23/34 setsockopt: deny writing to ctx->optval:OK #23/35 setsockopt: deny writing to ctx->optval_end:OK #23/36 setsockopt: allow IP_TOS <= 128:OK #23/37 setsockopt: deny IP_TOS > 128:OK
37 subtests is a bit too much spam.

If we merged test_btf into test_progs, we'd have >150 subtests, which would be pretty verbose as well. But the benefit of subtest is that you can run just that sub-test and debug/verify just it, without all the rest stuff.

Quoted 5 lines
Quoted 2 lines

So I'm wondering, if too many lines of default output is the only problem, should we just not output per-subtest line by default?

Ack, we can output per-subtest line if it fails so it's easy to re-run; otherwise, hiding by default sounds good. I'll prepare a v3 sometime today; Alexei, let us know if you disagree.

If the subtests are runnable and useful individually it's good to have them as subtests.
I think in the above I misread them as a sequence of sub-checks that needs to happen before actual test result.
Looking at test_sockopt.c I see that they're separate tests, so yeah keep them.
No need to hide by default or extra flags.
Let me look at v1 and v2 again...

#11 lore raw
Quoted 37 lines · Alexei Starovoitov
Quoted 29 lines · Stanislav Fomichev
Quoted 28 lines · Andrii Nakryiko
Quoted 11 lines · Alexei Starovoitov
Quoted 8 lines · Stanislav Fomichev

Now that test_progs is shaping into more generic test framework, let's convert sockopt tests to it. This requires adding a helper to create and join a cgroup first (test__join_cgroup). Since we already hijack stdout/stderr that shouldn't be a problem (cgroup helpers log to stderr).

The rest of the patches just move sockopt tests files under prog_tests/ and do the required small adjustments.

Quoted 9 lines

Looks good. Thank you for working on it. Could you de-verbose setsockopt test a bit? #23/32 setsockopt: deny write ctx->retval:OK #23/33 setsockopt: deny read ctx->retval:OK #23/34 setsockopt: deny writing to ctx->optval:OK #23/35 setsockopt: deny writing to ctx->optval_end:OK #23/36 setsockopt: allow IP_TOS <= 128:OK #23/37 setsockopt: deny IP_TOS > 128:OK
37 subtests is a bit too much spam.

If we merged test_btf into test_progs, we'd have >150 subtests, which would be pretty verbose as well. But the benefit of subtest is that you can run just that sub-test and debug/verify just it, without all the rest stuff.

Quoted 5 lines
Quoted 2 lines

So I'm wondering, if too many lines of default output is the only problem, should we just not output per-subtest line by default?

Ack, we can output per-subtest line if it fails so it's easy to re-run; otherwise, hiding by default sounds good. I'll prepare a v3 sometime today; Alexei, let us know if you disagree.

Quoted 8 lines

If the subtests are runnable and useful individually it's good to have them as subtests.
I think in the above I misread them as a sequence of sub-checks that needs to happen before actual test result.
Looking at test_sockopt.c I see that they're separate tests, so yeah keep them.
No need to hide by default or extra flags.
Let me look at v1 and v2 again...

I applied v1 set. Thanks!