selftests/bpf: test_progs: convert test_sockopt_multi
Move the files, adjust includes, remove entry from Makefile & .gitignore Signed-off-by: Stanislav Fomichev <sdf@google.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:
parent
9a365e67d8
commit
3886bd7c9b
1
tools/testing/selftests/bpf/.gitignore
vendored
1
tools/testing/selftests/bpf/.gitignore
vendored
@ -39,6 +39,5 @@ libbpf.so.*
|
|||||||
test_hashmap
|
test_hashmap
|
||||||
test_btf_dump
|
test_btf_dump
|
||||||
xdping
|
xdping
|
||||||
test_sockopt_multi
|
|
||||||
test_sockopt_inherit
|
test_sockopt_inherit
|
||||||
test_tcp_rtt
|
test_tcp_rtt
|
||||||
|
@ -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_cgroup_storage test_select_reuseport test_section_names \
|
||||||
test_netcnt test_tcpnotify_user test_sock_fields test_sysctl test_hashmap \
|
test_netcnt test_tcpnotify_user test_sock_fields test_sysctl test_hashmap \
|
||||||
test_btf_dump test_cgroup_attach xdping \
|
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)))
|
BPF_OBJ_FILES = $(patsubst %.c,%.o, $(notdir $(wildcard progs/*.c)))
|
||||||
TEST_GEN_FILES = $(BPF_OBJ_FILES)
|
TEST_GEN_FILES = $(BPF_OBJ_FILES)
|
||||||
@ -113,7 +113,6 @@ $(OUTPUT)/test_netcnt: cgroup_helpers.c
|
|||||||
$(OUTPUT)/test_sock_fields: cgroup_helpers.c
|
$(OUTPUT)/test_sock_fields: cgroup_helpers.c
|
||||||
$(OUTPUT)/test_sysctl: cgroup_helpers.c
|
$(OUTPUT)/test_sysctl: cgroup_helpers.c
|
||||||
$(OUTPUT)/test_cgroup_attach: 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_sockopt_inherit: cgroup_helpers.c
|
||||||
$(OUTPUT)/test_tcp_rtt: cgroup_helpers.c
|
$(OUTPUT)/test_tcp_rtt: cgroup_helpers.c
|
||||||
|
|
||||||
|
@ -1,19 +1,5 @@
|
|||||||
// SPDX-License-Identifier: GPL-2.0
|
// SPDX-License-Identifier: GPL-2.0
|
||||||
|
#include <test_progs.h>
|
||||||
#include <error.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <netinet/in.h>
|
|
||||||
|
|
||||||
#include <linux/filter.h>
|
|
||||||
#include <bpf/bpf.h>
|
|
||||||
#include <bpf/libbpf.h>
|
|
||||||
|
|
||||||
#include "bpf_rlimit.h"
|
|
||||||
#include "bpf_util.h"
|
|
||||||
#include "cgroup_helpers.h"
|
#include "cgroup_helpers.h"
|
||||||
|
|
||||||
static int prog_attach(struct bpf_object *obj, int cgroup_fd, const char *title)
|
static int prog_attach(struct bpf_object *obj, int cgroup_fd, const char *title)
|
||||||
@ -308,7 +294,7 @@ detach:
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
void test_sockopt_multi(void)
|
||||||
{
|
{
|
||||||
struct bpf_prog_load_attr attr = {
|
struct bpf_prog_load_attr attr = {
|
||||||
.file = "./sockopt_multi.o",
|
.file = "./sockopt_multi.o",
|
||||||
@ -319,56 +305,28 @@ int main(int argc, char **argv)
|
|||||||
int err = -1;
|
int err = -1;
|
||||||
int ignored;
|
int ignored;
|
||||||
|
|
||||||
if (setup_cgroup_environment()) {
|
cg_parent = test__join_cgroup("/parent");
|
||||||
log_err("Failed to setup cgroup environment\n");
|
if (CHECK_FAIL(cg_parent < 0))
|
||||||
goto out;
|
goto out;
|
||||||
}
|
|
||||||
|
|
||||||
cg_parent = create_and_get_cgroup("/parent");
|
cg_child = test__join_cgroup("/parent/child");
|
||||||
if (cg_parent < 0) {
|
if (CHECK_FAIL(cg_child < 0))
|
||||||
log_err("Failed to create cgroup /parent\n");
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
|
||||||
|
|
||||||
cg_child = create_and_get_cgroup("/parent/child");
|
|
||||||
if (cg_child < 0) {
|
|
||||||
log_err("Failed to create cgroup /parent/child\n");
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (join_cgroup("/parent/child")) {
|
|
||||||
log_err("Failed to join cgroup /parent/child\n");
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
err = bpf_prog_load_xattr(&attr, &obj, &ignored);
|
err = bpf_prog_load_xattr(&attr, &obj, &ignored);
|
||||||
if (err) {
|
if (CHECK_FAIL(err))
|
||||||
log_err("Failed to load BPF object");
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
|
||||||
|
|
||||||
sock_fd = socket(AF_INET, SOCK_STREAM, 0);
|
sock_fd = socket(AF_INET, SOCK_STREAM, 0);
|
||||||
if (sock_fd < 0) {
|
if (CHECK_FAIL(sock_fd < 0))
|
||||||
log_err("Failed to create socket");
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
|
||||||
|
|
||||||
if (run_getsockopt_test(obj, cg_parent, cg_child, sock_fd))
|
CHECK_FAIL(run_getsockopt_test(obj, cg_parent, cg_child, sock_fd));
|
||||||
err = -1;
|
CHECK_FAIL(run_setsockopt_test(obj, cg_parent, cg_child, sock_fd));
|
||||||
printf("test_sockopt_multi: getsockopt %s\n",
|
|
||||||
err ? "FAILED" : "PASSED");
|
|
||||||
|
|
||||||
if (run_setsockopt_test(obj, cg_parent, cg_child, sock_fd))
|
|
||||||
err = -1;
|
|
||||||
printf("test_sockopt_multi: setsockopt %s\n",
|
|
||||||
err ? "FAILED" : "PASSED");
|
|
||||||
|
|
||||||
out:
|
out:
|
||||||
close(sock_fd);
|
close(sock_fd);
|
||||||
bpf_object__close(obj);
|
bpf_object__close(obj);
|
||||||
close(cg_child);
|
close(cg_child);
|
||||||
close(cg_parent);
|
close(cg_parent);
|
||||||
|
|
||||||
printf("test_sockopt_multi: %s\n", err ? "FAILED" : "PASSED");
|
|
||||||
return err ? EXIT_FAILURE : EXIT_SUCCESS;
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user