Skip to content

Commit faf1b9e

Browse files
selftests/bpf: Convert test_sysctl to prog_tests
JIRA: https://issues.redhat.com/browse/RHEL-93930 Conflicts: Context change due to missing commits: - eea6c14 ("selftests/bpf: Retire test_sock.c") - c3566ee ("selftests/bpf: remove test_tcp_check_syncookie") commit b8a2054 Author: Jerome Marchand <jmarchan@redhat.com> Date: Thu Jun 19 16:06:03 2025 +0200 selftests/bpf: Convert test_sysctl to prog_tests Convert test_sysctl test to prog_tests with minimal change to the tests themselves. Signed-off-by: Jerome Marchand <jmarchan@redhat.com> Acked-by: Yonghong Song <yonghong.song@linux.dev> Link: https://lore.kernel.org/r/20250619140603.148942-3-jmarchan@redhat.com Signed-off-by: Alexei Starovoitov <ast@kernel.org> Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
1 parent 934b7aa commit faf1b9e

File tree

3 files changed

+10
-33
lines changed

3 files changed

+10
-33
lines changed

tools/testing/selftests/bpf/.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ flow_dissector_load
2424
test_tcpnotify_user
2525
test_libbpf
2626
test_tcp_check_syncookie_user
27-
test_sysctl
2827
xdping
2928
test_cpp
3029
*.d

tools/testing/selftests/bpf/Makefile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ endif
8585
# Order correspond to 'make run_tests' order
8686
TEST_GEN_PROGS = test_verifier test_tag test_maps test_lru_map test_progs \
8787
test_sock test_sockmap \
88-
test_tcpnotify_user test_sysctl \
88+
test_tcpnotify_user \
8989
test_progs-no_alu32
9090
TEST_INST_SUBDIRS := no_alu32
9191

@@ -235,7 +235,7 @@ ifeq ($(VMLINUX_BTF),)
235235
$(error Cannot find a vmlinux for VMLINUX_BTF at any of "$(VMLINUX_BTF_PATHS)")
236236
endif
237237

238-
# Define simple and short `make test_progs`, `make test_sysctl`, etc targets
238+
# Define simple and short `make test_progs`, `make test_maps`, etc targets
239239
# to build individual tests.
240240
# NOTE: Semicolon at the end is critical to override lib.mk's default static
241241
# rule for binaries.
@@ -363,7 +363,6 @@ $(OUTPUT)/test_sock: $(CGROUP_HELPERS) $(TESTING_HELPERS)
363363
$(OUTPUT)/test_sockmap: $(CGROUP_HELPERS) $(TESTING_HELPERS)
364364
$(OUTPUT)/test_tcpnotify_user: $(CGROUP_HELPERS) $(TESTING_HELPERS) $(TRACE_HELPERS)
365365
$(OUTPUT)/test_sock_fields: $(CGROUP_HELPERS) $(TESTING_HELPERS)
366-
$(OUTPUT)/test_sysctl: $(CGROUP_HELPERS) $(TESTING_HELPERS)
367366
$(OUTPUT)/test_tag: $(TESTING_HELPERS)
368367
$(OUTPUT)/test_lirc_mode2_user: $(TESTING_HELPERS)
369368
$(OUTPUT)/xdping: $(TESTING_HELPERS)

tools/testing/selftests/bpf/test_sysctl.c renamed to tools/testing/selftests/bpf/prog_tests/test_sysctl.c

Lines changed: 8 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,8 @@
11
// SPDX-License-Identifier: GPL-2.0
22
// Copyright (c) 2019 Facebook
33

4-
#include <fcntl.h>
5-
#include <stdint.h>
6-
#include <stdio.h>
7-
#include <stdlib.h>
8-
#include <string.h>
9-
#include <unistd.h>
10-
11-
#include <linux/filter.h>
12-
13-
#include <bpf/bpf.h>
14-
#include <bpf/libbpf.h>
15-
16-
#include <bpf/bpf_endian.h>
17-
#include "bpf_util.h"
4+
#include "test_progs.h"
185
#include "cgroup_helpers.h"
19-
#include "testing_helpers.h"
206

217
#define CG_PATH "/foo"
228
#define MAX_INSNS 512
@@ -1608,26 +1594,19 @@ static int run_tests(int cgfd)
16081594
return fails ? -1 : 0;
16091595
}
16101596

1611-
int main(int argc, char **argv)
1597+
void test_sysctl(void)
16121598
{
1613-
int cgfd = -1;
1614-
int err = 0;
1599+
int cgfd;
16151600

16161601
cgfd = cgroup_setup_and_join(CG_PATH);
1617-
if (cgfd < 0)
1618-
goto err;
1602+
if (!ASSERT_OK_FD(cgfd < 0, "create_cgroup"))
1603+
goto out;
16191604

1620-
/* Use libbpf 1.0 API mode */
1621-
libbpf_set_strict_mode(LIBBPF_STRICT_ALL);
1605+
if (!ASSERT_OK(run_tests(cgfd), "run_tests"))
1606+
goto out;
16221607

1623-
if (run_tests(cgfd))
1624-
goto err;
1625-
1626-
goto out;
1627-
err:
1628-
err = -1;
16291608
out:
16301609
close(cgfd);
16311610
cleanup_cgroup_environment();
1632-
return err;
1611+
return;
16331612
}

0 commit comments

Comments
 (0)