Commit 4a647421 authored by Stanislav Fomichev's avatar Stanislav Fomichev Committed by Alexei Starovoitov
Browse files

selftests/bpf: test_progs: convert test_sockopt



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

Signed-off-by: default avatarStanislav Fomichev <sdf@google.com>
Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent 88dadc63
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -39,7 +39,6 @@ libbpf.so.*
test_hashmap
test_btf_dump
xdping
test_sockopt
test_sockopt_sk
test_sockopt_multi
test_sockopt_inherit
+1 −2
Original line number Diff line number Diff line
@@ -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)))
@@ -113,7 +113,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
+7 −43
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0

#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 <test_progs.h>
#include "cgroup_helpers.h"

#define CG_PATH				"/sockopt"

static char bpf_log_buf[4096];
static bool verbose;

@@ -983,39 +968,18 @@ close_prog_fd:
	return ret;
}

int main(int args, char **argv)
void test_sockopt(void)
{
	int err = EXIT_FAILURE, error_cnt = 0;
	int cgroup_fd, i;

	if (setup_cgroup_environment())
		goto cleanup_obj;

	cgroup_fd = create_and_get_cgroup(CG_PATH);
	if (cgroup_fd < 0)
		goto cleanup_cgroup_env;

	if (join_cgroup(CG_PATH))
		goto cleanup_cgroup;
	cgroup_fd = test__join_cgroup("/sockopt");
	if (CHECK_FAIL(cgroup_fd < 0))
		return;

	for (i = 0; i < ARRAY_SIZE(tests); i++) {
		int err = run_test(cgroup_fd, &tests[i]);

		if (err)
			error_cnt++;

		printf("#%d %s: %s\n", i, err ? "FAIL" : "PASS",
		       tests[i].descr);
		test__start_subtest(tests[i].descr);
		CHECK_FAIL(run_test(cgroup_fd, &tests[i]));
	}

	printf("Summary: %ld PASSED, %d FAILED\n",
	       ARRAY_SIZE(tests) - error_cnt, error_cnt);
	err = error_cnt ? EXIT_FAILURE : EXIT_SUCCESS;

cleanup_cgroup:
	close(cgroup_fd);
cleanup_cgroup_env:
	cleanup_cgroup_environment();
cleanup_obj:
	return err;
}