From nobody Thu Oct 9 09:07:03 2025 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C579D26FA58 for ; Thu, 19 Jun 2025 14:06:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750341993; cv=none; b=ZXhnkwCgreAHfk9CYJNelotKz2VRKcXfiNsMUeuCqlKnqUjNtru5AnRzr4JzD4FLZc5+Vkh/6A0cXtWnwl6kVR8qy5JXYGe4RCag+Mv+HvsTN9wD8CxJkWmd8Mb5OzoDTc0/F/ZglicEAXN80GNvDLJJQEc8vCo/hMEkPUTjiKk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750341993; c=relaxed/simple; bh=mNbUYvZReUbPX24HxzYrXfLJ05cI+cpHUEK2EdjWNwk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qrax5fMaERgkw8QEOwYvKnPDgq00JsN6RCjmBGzfUkyQQTo8qx0Aa+8P2gwqIFZ+JPJaElF32ibPj/9pLfVNcz8M3AUdyxaDpFyuYe2I4XCgV9j3IVwz6tAjxLUTn4QQkrEYtSNlV0eoGuq7zT3SEFclSny1YL9HiuqOugDYP6U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=iY0MnNz5; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="iY0MnNz5" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1750341990; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3rFJy2cGcGcOiZjoBdoVKK7T7Guml8LSC5Piayfcnbo=; b=iY0MnNz5eSrovEfeuGN0vCMRNu9fU59ciQAtrXaf2d+9mQqTuFFmVaUVMdL98O0aBuf95r 6ORXNl7sH22FfmtF4pAbK4nAlCPvnzgfPFIR4xgGfDd8JWpDOyRI1ZyUPUqmjPdTjcfd2d x4gSMmCJfmvQ6decHUtDkEOjr6aBfd0= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-3-prla-sTlMFOhS4rQhKUc6A-1; Thu, 19 Jun 2025 10:06:24 -0400 X-MC-Unique: prla-sTlMFOhS4rQhKUc6A-1 X-Mimecast-MFC-AGG-ID: prla-sTlMFOhS4rQhKUc6A_1750341982 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5C77C1800283; Thu, 19 Jun 2025 14:06:22 +0000 (UTC) Received: from fedora (unknown [10.45.226.41]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with SMTP id 2F38F19560A3; Thu, 19 Jun 2025 14:06:17 +0000 (UTC) Received: by fedora (sSMTP sendmail emulation); Thu, 19 Jun 2025 16:06:16 +0200 From: "Jerome Marchand" To: bpf@vger.kernel.org Cc: Martin KaFai Lau , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Yonghong Song , Eduard Zingerman , linux-kernel@vger.kernel.org, Jerome Marchand Subject: [PATCH v3 2/2] selftests/bpf: Convert test_sysctl to prog_tests Date: Thu, 19 Jun 2025 16:06:03 +0200 Message-ID: <20250619140603.148942-3-jmarchan@redhat.com> In-Reply-To: <20250619140603.148942-1-jmarchan@redhat.com> References: <20250619140603.148942-1-jmarchan@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Content-Type: text/plain; charset="utf-8" Convert test_sysctl test to prog_tests with minimal change to the tests themselves. Signed-off-by: Jerome Marchand Acked-by: Yonghong Song --- tools/testing/selftests/bpf/.gitignore | 1 - tools/testing/selftests/bpf/Makefile | 5 +-- .../bpf/{ =3D> prog_tests}/test_sysctl.c | 37 ++++--------------- 3 files changed, 10 insertions(+), 33 deletions(-) rename tools/testing/selftests/bpf/{ =3D> prog_tests}/test_sysctl.c (98%) diff --git a/tools/testing/selftests/bpf/.gitignore b/tools/testing/selftes= ts/bpf/.gitignore index e2a2c46c008b1..3d8378972d26c 100644 --- a/tools/testing/selftests/bpf/.gitignore +++ b/tools/testing/selftests/bpf/.gitignore @@ -21,7 +21,6 @@ test_lirc_mode2_user flow_dissector_load test_tcpnotify_user test_libbpf -test_sysctl xdping test_cpp *.d diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests= /bpf/Makefile index 66bb50356be08..53dc08d905bd1 100644 --- a/tools/testing/selftests/bpf/Makefile +++ b/tools/testing/selftests/bpf/Makefile @@ -70,7 +70,7 @@ endif # Order correspond to 'make run_tests' order TEST_GEN_PROGS =3D test_verifier test_tag test_maps test_lru_map test_prog= s \ test_sockmap \ - test_tcpnotify_user test_sysctl \ + test_tcpnotify_user \ test_progs-no_alu32 TEST_INST_SUBDIRS :=3D no_alu32 =20 @@ -215,7 +215,7 @@ ifeq ($(VMLINUX_BTF),) $(error Cannot find a vmlinux for VMLINUX_BTF at any of "$(VMLINUX_BTF_PAT= HS)") endif =20 -# Define simple and short `make test_progs`, `make test_sysctl`, etc targe= ts +# Define simple and short `make test_progs`, `make test_maps`, etc targets # to build individual tests. # NOTE: Semicolon at the end is critical to override lib.mk's default stat= ic # rule for binaries. @@ -324,7 +324,6 @@ NETWORK_HELPERS :=3D $(OUTPUT)/network_helpers.o $(OUTPUT)/test_sockmap: $(CGROUP_HELPERS) $(TESTING_HELPERS) $(OUTPUT)/test_tcpnotify_user: $(CGROUP_HELPERS) $(TESTING_HELPERS) $(TRAC= E_HELPERS) $(OUTPUT)/test_sock_fields: $(CGROUP_HELPERS) $(TESTING_HELPERS) -$(OUTPUT)/test_sysctl: $(CGROUP_HELPERS) $(TESTING_HELPERS) $(OUTPUT)/test_tag: $(TESTING_HELPERS) $(OUTPUT)/test_lirc_mode2_user: $(TESTING_HELPERS) $(OUTPUT)/xdping: $(TESTING_HELPERS) diff --git a/tools/testing/selftests/bpf/test_sysctl.c b/tools/testing/self= tests/bpf/prog_tests/test_sysctl.c similarity index 98% rename from tools/testing/selftests/bpf/test_sysctl.c rename to tools/testing/selftests/bpf/prog_tests/test_sysctl.c index bcdbd27f22f08..273dd41ca09e4 100644 --- a/tools/testing/selftests/bpf/test_sysctl.c +++ b/tools/testing/selftests/bpf/prog_tests/test_sysctl.c @@ -1,22 +1,8 @@ // SPDX-License-Identifier: GPL-2.0 // Copyright (c) 2019 Facebook =20 -#include -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include -#include "bpf_util.h" +#include "test_progs.h" #include "cgroup_helpers.h" -#include "testing_helpers.h" =20 #define CG_PATH "/foo" #define MAX_INSNS 512 @@ -1608,26 +1594,19 @@ static int run_tests(int cgfd) return fails ? -1 : 0; } =20 -int main(int argc, char **argv) +void test_sysctl(void) { - int cgfd =3D -1; - int err =3D 0; + int cgfd; =20 cgfd =3D cgroup_setup_and_join(CG_PATH); - if (cgfd < 0) - goto err; + if (!ASSERT_OK_FD(cgfd < 0, "create_cgroup")) + goto out; =20 - /* Use libbpf 1.0 API mode */ - libbpf_set_strict_mode(LIBBPF_STRICT_ALL); + if (!ASSERT_OK(run_tests(cgfd), "run_tests")) + goto out; =20 - if (run_tests(cgfd)) - goto err; - - goto out; -err: - err =3D -1; out: close(cgfd); cleanup_cgroup_environment(); - return err; + return; } --=20 2.49.0