From nobody Mon Feb 9 10:27:30 2026 Received: from mail-pl1-f194.google.com (mail-pl1-f194.google.com [209.85.214.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9363933E37C for ; Fri, 9 Jan 2026 08:27:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767947223; cv=none; b=ti2hx5dZp8bQsZiyh94SAeW+4xE4knjM4FXnnR2wC7SghkpSspMcmETD/tBt6F1p9Lmc2/zhig+nyR/CJipo8j70QMmadkQHP/28lSwDqMdR4niAPOxbf1DJeeGeF4yeusHP1m06xW8qDlrgiyFQPSJL0RQy0OPLmFWiymX5Nyw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767947223; c=relaxed/simple; bh=XFKYbdqek82e955LuFfB7XrslWtR7nToplf1ovT/uLc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=px0OyikDxVyfCSY6q+xBUxAdSZFxcH9+vW8Py8THaFrJB/4Ow5Tb9Ag1Uotuda4xSMjxIyW4ZnZ0mB1fVOmOuNLPQAvNQaTBCfDNdYrcIgWbH4dkWZytn1iuhSBb7cgY87RVulZ90GWLBhua/QekNnNhqmDhpPyvAr+FVJZHNL0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Gfm24XKT; arc=none smtp.client-ip=209.85.214.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Gfm24XKT" Received: by mail-pl1-f194.google.com with SMTP id d9443c01a7336-2a3e89aa5d0so29599055ad.1 for ; Fri, 09 Jan 2026 00:27:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1767947218; x=1768552018; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Zwi+SQABySrXhJ73Aavan6sR47ltHo8LNgDoB9IyaJE=; b=Gfm24XKTXf9PFdCwdwbaUQPIP/O0JiUcF3utyhC7MGEFXfwOh8dw7bZ11BvbjXC7YJ 9jnqI0k8bSrJ56tAhkd+bI0HNFHwaxidDfV43yCXUHmZcGrEgSqnDZqwFIweyG3g4rlN yzqWI0kGNOdOQlobZxtMKla8QCcJu9ZlhM8+TSXvbPAJTCg0iawoIyBz1E6i/DNURowO bwrtN7Yq9H2WoQPq2Y5yrGIcv/XUfty5fjQg9jUYOdx6rHBRHt2EezY+1w6+zxNYKggO 3uRGm97e3VV+tFAoG3O78thfhlA6luMBo7VjmgvxuP71YMl8prrzGELOXA7jQU5D2j1V fBhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767947218; x=1768552018; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=Zwi+SQABySrXhJ73Aavan6sR47ltHo8LNgDoB9IyaJE=; b=GjAe1P1qNMrJRb+T1VRsGAu0874B+plO2NfojrDBmtQ/5yP0h79bx4MFm5vYmTnXs8 jtBvnq1tNy17f96mBVKUwST42wBctnSzvoJb5UFiZaL87GmEYeJmXiCn9GCR5MMteuH+ He1vXfS7FD7AIVYqKgHNW2qWGGIIfrmqslg/clYWEX/jZH5c+z4I8wOcG8SGmQDndvn2 8dIYrKdW51HQNEfX1/3NVueWjA3Y0GcaIf5R+KMpiQlPQypxaUJ/hIqhiynsrApO8+a2 icnVOw0OCJ9JHdOyu+4/UbyWk9VlEDlXSY/hB8uzU4H2WkBpujlAGnDpU0qOE2TeKSoL Hb9Q== X-Forwarded-Encrypted: i=1; AJvYcCUMpYK+EdToMrOB9ilMUw+2L6pCC+3CHXLX/vN5ltYQTQDN9uWyWnbsBmnyo4ndKyTvtGjl0vrF4zuF2vw=@vger.kernel.org X-Gm-Message-State: AOJu0YyofNkO/ccH7zmALvx/S9+SBU499fm1RGTMWO9nGFxc/ayvXnFW HLl9tcm+YximshIIgR01szL3M6l445++DmSV0+prLoYnZA/+E2OJc8Z8 X-Gm-Gg: AY/fxX4GwwPe3anCZlLdK3pqJuT+JXl/7Po3lLbG6cMHXH3yRXB4dG+bS08qz0oO9BS J37KS02tuqvx1O605HyNmqA+RquEBT7edNTuxU6CR6/ejHKUdvIn/x0g63jjFwvEeqIVU1+UU1P +4PMnyW29OSnglo+lkPfi+rAPXyi2hAv2Ppm3yhJ/m6JC7ujRdNncTe59P9La1P3VRQCra2GK1B IAmtM0Cx7qDyU+Ks/InQXiJ5iFmr1z5MuC+Q6XCzS3Ld0eGfKGqN59KvRIjXmJcDab+xc71s628 aekUANM5FZea5U89V6OerzAg0i8ETklft9JZEfMlz7ddUitmFzVAF884CJn1a6msVarbTghJLDs CukyxzGRQ4VBl4gvfY0y2g7gW46Hvw6jnY+sFiRu48epddUx390r5tNWMxhL/H0BTil/zlfesqu w1VsFoaIM= X-Google-Smtp-Source: AGHT+IFkmYIsAMugEppgaXOpQe5O3ZkdkSpkBnrFqRwXgUMwl1QncrAuD0R34kIn9aTM0yWLwMIwkw== X-Received: by 2002:a17:903:1b43:b0:2a0:bb05:df4f with SMTP id d9443c01a7336-2a3ee49c701mr96639765ad.44.1767947218306; Fri, 09 Jan 2026 00:26:58 -0800 (PST) Received: from 7940hx ([160.187.0.149]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2a3e3cc7912sm100104695ad.67.2026.01.09.00.26.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jan 2026 00:26:58 -0800 (PST) From: Menglong Dong X-Google-Original-From: Menglong Dong To: ast@kernel.org, eddyz87@gmail.com Cc: daniel@iogearbox.net, john.fastabend@gmail.com, andrii@kernel.org, martin.lau@linux.dev, song@kernel.org, yonghong.song@linux.dev, kpsingh@kernel.org, sdf@fomichev.me, haoluo@google.com, jolsa@kernel.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH bpf-next v3 2/3] selftests/bpf: add TEST_TAG_KCONFIG_CHECK to test_loader Date: Fri, 9 Jan 2026 16:26:30 +0800 Message-ID: <20260109082631.246647-3-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260109082631.246647-1-dongml2@chinatelecom.cn> References: <20260109082631.246647-1-dongml2@chinatelecom.cn> 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 Content-Type: text/plain; charset="utf-8" Add the __kconfig_check() to specify the kernel config for the test case. The test case will be skipped if the specified Kconfig option is not matched. Signed-off-by: Menglong Dong --- tools/testing/selftests/bpf/progs/bpf_misc.h | 3 ++ tools/testing/selftests/bpf/test_loader.c | 46 +++++++++++++++++++- 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/bpf/progs/bpf_misc.h b/tools/testing/s= elftests/bpf/progs/bpf_misc.h index c9bfbe1bafc1..e230f135f580 100644 --- a/tools/testing/selftests/bpf/progs/bpf_misc.h +++ b/tools/testing/selftests/bpf/progs/bpf_misc.h @@ -129,6 +129,8 @@ * * __linear_size Specify the size of the linear area of non-linear skb= s, or * 0 for linear skbs. + * + * __kconfig_check The test case is skipped if the specified Kconfig opt= ion is not set. */ #define __msg(msg) __attribute__((btf_decl_tag("comment:test_expect_msg= =3D" XSTR(__COUNTER__) "=3D" msg))) #define __not_msg(msg) __attribute__((btf_decl_tag("comment:test_expect_n= ot_msg=3D" XSTR(__COUNTER__) "=3D" msg))) @@ -163,6 +165,7 @@ #define __stdout(msg) __attribute__((btf_decl_tag("comment:test_expect_st= dout=3D" XSTR(__COUNTER__) "=3D" msg))) #define __stdout_unpriv(msg) __attribute__((btf_decl_tag("comment:test_exp= ect_stdout_unpriv=3D" XSTR(__COUNTER__) "=3D" msg))) #define __linear_size(sz) __attribute__((btf_decl_tag("comment:test_linear= _size=3D" XSTR(sz)))) +#define __kconfig_check(config) __attribute__((btf_decl_tag("comment:test_= kconfig=3D" config))) =20 /* Define common capabilities tested using __caps_unpriv */ #define CAP_NET_ADMIN 12 diff --git a/tools/testing/selftests/bpf/test_loader.c b/tools/testing/self= tests/bpf/test_loader.c index 338c035c3688..a5fbd70e37d6 100644 --- a/tools/testing/selftests/bpf/test_loader.c +++ b/tools/testing/selftests/bpf/test_loader.c @@ -4,6 +4,9 @@ #include #include #include +#include +#include +#include =20 #include "autoconf_helper.h" #include "disasm_helpers.h" @@ -44,6 +47,7 @@ #define TEST_TAG_EXPECT_STDOUT_PFX "comment:test_expect_stdout=3D" #define TEST_TAG_EXPECT_STDOUT_PFX_UNPRIV "comment:test_expect_stdout_unpr= iv=3D" #define TEST_TAG_LINEAR_SIZE "comment:test_linear_size=3D" +#define TEST_TAG_KCONFIG_CHECK "comment:test_kconfig=3D" =20 /* Warning: duplicated in bpf_misc.h */ #define POINTER_VALUE 0xbadcafe @@ -93,6 +97,7 @@ struct test_spec { int linear_sz; bool auxiliary; bool valid; + bool skip; }; =20 static int tester_init(struct test_loader *tester) @@ -394,6 +399,41 @@ static int get_current_arch(void) return ARCH_UNKNOWN; } =20 +static int kconfig_check(const char *kconfig) +{ + int len, err =3D -ENOENT; + char buf[PATH_MAX]; + struct utsname uts; + gzFile file; + + uname(&uts); + len =3D snprintf(buf, PATH_MAX, "/boot/config-%s", uts.release); + if (len < 0) + return -EINVAL; + else if (len >=3D PATH_MAX) + return -ENAMETOOLONG; + + /* gzopen also accepts uncompressed files. */ + file =3D gzopen(buf, "re"); + if (!file) + file =3D gzopen("/proc/config.gz", "re"); + + if (!file) { + fprintf(stderr, "failed to open system Kconfig\n"); + return -ENOENT; + } + + while (gzgets(file, buf, sizeof(buf))) { + if (strstr(buf, kconfig)) { + err =3D 0; + break; + } + } + + gzclose(file); + return err; +} + /* Uses btf_decl_tag attributes to describe the expected test * behavior, see bpf_misc.h for detailed description of each attribute * and attribute combinations. @@ -650,6 +690,10 @@ static int parse_test_spec(struct test_loader *tester, err =3D -EINVAL; goto cleanup; } + } else if (str_has_pfx(s, TEST_TAG_KCONFIG_CHECK)) { + val =3D s + sizeof(TEST_TAG_KCONFIG_CHECK) - 1; + if (kconfig_check(val)) + spec->skip =3D true; } } =20 @@ -1151,7 +1195,7 @@ void run_subtest(struct test_loader *tester, if (!test__start_subtest(subspec->name)) return; =20 - if ((get_current_arch() & spec->arch_mask) =3D=3D 0) { + if ((get_current_arch() & spec->arch_mask) =3D=3D 0 || spec->skip) { test__skip(); return; } --=20 2.52.0