From patchwork Thu Jul 4 06:48:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13723309 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 03C0B1A0721; Thu, 4 Jul 2024 06:48:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720075707; cv=none; b=uF/AajG0VYg6K/q0RxAlLYKYMml5UaP24AFb7QMmHw/xb3J1kUlCl4ickBkKKP+lHUoM132Yj8Q4JcPES66wM1Fgqp5vUu7+Hr1mmfSu04FHVi39w9sa4ig/CnAOp0bBqyj5MxZQaYqgtoLtV8W5AQIjYDTWyHzPQ3fVfvDNQUk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720075707; c=relaxed/simple; bh=ykZWrxE+n4/sVCNo5kafkiXafCpMooYXm2h/xWx50e8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TfMIwZFBkCKoqdbk3on+R9qkBYY6vU9GX2MVpyts/9Bkl3oF6k3rDXJPNVgkjFLM2H8bepah7FljhEt3mExZWPXC/JHF9ifDXW+Fo7ygZtNz7CyJ3VGr7exymCkjvCSd1AJVHbPE9WvmfXZBbF0Ip0ROBV02DTspqUbFMbNtN48= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=HFjFZHu0; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="HFjFZHu0" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3E230C3277B; Thu, 4 Jul 2024 06:48:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720075706; bh=ykZWrxE+n4/sVCNo5kafkiXafCpMooYXm2h/xWx50e8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HFjFZHu06ItIp9mDDSPmKBwrzjO/tonM8g30oBILKmQeXzWeNeyY0ogVmHF+1s+V+ ai7cAF2OCWdmb6W4IS1dSI37g2tB3zmXlE8a98jOey2CG8lNE5fsFqvCKVl4hYXtHs E37MYc7ou68xCLXLWIm1zFmBFvkXMIQ1uhew66hg4Vm+GuJSCkmSBtMgBcZ5in6UBS xFXvv8s/EXJBy5E9AS6p7C7fhbhwUfHcgBM+4QPWsefmDjs4jGHXgipR4fcWhPpPc+ OZR384TQ4u8TuFV1swAskaegAhnapri9h/C14nZXQtoDP5JhLvHDC6hTsBkMTc0X+b UqikAHObK9sEg== From: Geliang Tang To: Andrii Nakryiko , Eduard Zingerman , Mykola Lysenko , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Shuah Khan Cc: Geliang Tang , bpf@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH 1/6] selftests/bpf: Define ENOTSUPP in testing_helpers.h Date: Thu, 4 Jul 2024 14:48:01 +0800 Message-ID: <03d468d5f4c4b267905d8d3c5d697a9028245f22.1720075006.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Geliang Tang ENOTSUPP are defined in so many places in bpf selftests, this patch moves this definition into testing_helpers.h, which is almost included by each tests. And drop all other duplicate definitions. Signed-off-by: Geliang Tang --- tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c | 4 ---- tools/testing/selftests/bpf/prog_tests/lsm_cgroup.c | 4 ---- tools/testing/selftests/bpf/prog_tests/sock_addr.c | 4 ---- tools/testing/selftests/bpf/test_maps.c | 4 ---- tools/testing/selftests/bpf/test_verifier.c | 4 ---- tools/testing/selftests/bpf/testing_helpers.h | 4 ++++ 6 files changed, 4 insertions(+), 20 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c b/tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c index bceff5900016..fa2efb246d3b 100644 --- a/tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c +++ b/tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c @@ -16,10 +16,6 @@ #include "tcp_ca_kfunc.skel.h" #include "bpf_cc_cubic.skel.h" -#ifndef ENOTSUPP -#define ENOTSUPP 524 -#endif - static const unsigned int total_bytes = 10 * 1024 * 1024; static int expected_stg = 0xeB9F; diff --git a/tools/testing/selftests/bpf/prog_tests/lsm_cgroup.c b/tools/testing/selftests/bpf/prog_tests/lsm_cgroup.c index 130a3b21e467..6df25de8f080 100644 --- a/tools/testing/selftests/bpf/prog_tests/lsm_cgroup.c +++ b/tools/testing/selftests/bpf/prog_tests/lsm_cgroup.c @@ -10,10 +10,6 @@ #include "cgroup_helpers.h" #include "network_helpers.h" -#ifndef ENOTSUPP -#define ENOTSUPP 524 -#endif - static struct btf *btf; static __u32 query_prog_cnt(int cgroup_fd, const char *attach_func) diff --git a/tools/testing/selftests/bpf/prog_tests/sock_addr.c b/tools/testing/selftests/bpf/prog_tests/sock_addr.c index b880c564a204..68d9255d2bb7 100644 --- a/tools/testing/selftests/bpf/prog_tests/sock_addr.c +++ b/tools/testing/selftests/bpf/prog_tests/sock_addr.c @@ -23,10 +23,6 @@ #include "getpeername_unix_prog.skel.h" #include "network_helpers.h" -#ifndef ENOTSUPP -# define ENOTSUPP 524 -#endif - #define TEST_NS "sock_addr" #define TEST_IF_PREFIX "test_sock_addr" #define TEST_IPV4 "127.0.0.4" diff --git a/tools/testing/selftests/bpf/test_maps.c b/tools/testing/selftests/bpf/test_maps.c index dfbab214f4d1..227d7d6eaf8e 100644 --- a/tools/testing/selftests/bpf/test_maps.c +++ b/tools/testing/selftests/bpf/test_maps.c @@ -26,10 +26,6 @@ #include "test_maps.h" #include "testing_helpers.h" -#ifndef ENOTSUPP -#define ENOTSUPP 524 -#endif - int skips; static struct bpf_map_create_opts map_opts = { .sz = sizeof(map_opts) }; diff --git a/tools/testing/selftests/bpf/test_verifier.c b/tools/testing/selftests/bpf/test_verifier.c index 610392dfc4fb..447b68509d76 100644 --- a/tools/testing/selftests/bpf/test_verifier.c +++ b/tools/testing/selftests/bpf/test_verifier.c @@ -42,10 +42,6 @@ #include "../../../include/linux/filter.h" #include "testing_helpers.h" -#ifndef ENOTSUPP -#define ENOTSUPP 524 -#endif - #define MAX_INSNS BPF_MAXINSNS #define MAX_EXPECTED_INSNS 32 #define MAX_UNEXPECTED_INSNS 32 diff --git a/tools/testing/selftests/bpf/testing_helpers.h b/tools/testing/selftests/bpf/testing_helpers.h index d55f6ab12433..bad21e72dafc 100644 --- a/tools/testing/selftests/bpf/testing_helpers.h +++ b/tools/testing/selftests/bpf/testing_helpers.h @@ -9,6 +9,10 @@ #include #include +#ifndef ENOTSUPP +#define ENOTSUPP 524 +#endif + #define __TO_STR(x) #x #define TO_STR(x) __TO_STR(x) From patchwork Thu Jul 4 06:48:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13723310 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 645EE1A072F; Thu, 4 Jul 2024 06:48:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720075713; cv=none; b=Y7OJkCW9yabEvsydy8wbQ+uL/BCrnqfKRbwv6IDbDwdIB177XcL5I9rfhO6sniNaTzCc0Dp7MBl6HDo9LXDvF8qHReTTVXc8r2qAe5ntqNXpIrp1N3FKcdN+aAmZzssThelzc0+yY8TI82tlXfwwEmIGW7ntlUn9jvbq2qQ/20s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720075713; c=relaxed/simple; bh=uOaIVfz5RfQqH0iY+EtTeoqdXo5UjZY01UReZZmwiy4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ehcchF8si7rvYWcilqS3QY0iwnfcSMySq2iyiVYb4sZQCEOBT0bBSJVssF6GP057yxfryNQcwLbqNjgSjZhssWWUu5xT/ZQ9fUUvTIEdZZJBbp6Zuyub9JsukKYqek96ShztoGeiEoCmCSFu5Dgg1B7ujNS65BK9Mo0Z4H++pXs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jAl46Mx/; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="jAl46Mx/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7A4FEC4AF0F; Thu, 4 Jul 2024 06:48:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720075713; bh=uOaIVfz5RfQqH0iY+EtTeoqdXo5UjZY01UReZZmwiy4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jAl46Mx/YbPy+OwsnwY+RW/7XWgAHsRfz4VZvsLf1Bow6ahTL07KYRgCa0WvrgoVS EJlenqAT9b+DckNUEGLbVjvk/rQaHlCaUw0pH0vHDGChifQI8MT0pTuEgXpf2FEwW2 cRNvwnXKiwib+Lq8AUNPH0lhT/hRSgDkXEqM+khcx2/QMWCgw9S4AznYJFWeQPc6FU rFTUvI6g5RWumMXlpPFnLIeHFexGrCaeDjKY3D1MtOeEKGIjwfBGCq07Yu1dnhXxn4 mJNO17rznkMqwQddhbtIOg7/kx8mS/Ivq/RtEhIXS+ujvIrAJMkl235POZ/C4Whh3C 9mA4piY5j8Obg== From: Geliang Tang To: Andrii Nakryiko , Eduard Zingerman , Mykola Lysenko , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Shuah Khan Cc: Geliang Tang , bpf@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH 2/6] selftests/bpf: Skip ENOTSUPP in ASSERT_OK Date: Thu, 4 Jul 2024 14:48:02 +0800 Message-ID: <9e037774bb1fe1e374900f32d2ceab47e6986e07.1720075006.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Geliang Tang Just like handling ENOTSUPP in test_lsm_cgroup_functional(), this patch checks ENOTSUPP (524) and ENOTSUP (95) in ASSERT_OK(), invoke test__skip() in this case instead of test__fail(). Signed-off-by: Geliang Tang --- tools/testing/selftests/bpf/prog_tests/lsm_cgroup.c | 6 +----- tools/testing/selftests/bpf/test_progs.h | 9 +++++++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/lsm_cgroup.c b/tools/testing/selftests/bpf/prog_tests/lsm_cgroup.c index 6df25de8f080..6511f5f4a00f 100644 --- a/tools/testing/selftests/bpf/prog_tests/lsm_cgroup.c +++ b/tools/testing/selftests/bpf/prog_tests/lsm_cgroup.c @@ -102,12 +102,8 @@ static void test_lsm_cgroup_functional(void) ASSERT_EQ(query_prog_cnt(cgroup_fd, "bpf_lsm_sk_alloc_security"), 0, "prog count"); ASSERT_EQ(query_prog_cnt(cgroup_fd, NULL), 0, "total prog count"); err = bpf_prog_attach(alloc_prog_fd, cgroup_fd, BPF_LSM_CGROUP, 0); - if (err == -ENOTSUPP) { - test__skip(); - goto close_cgroup; - } if (!ASSERT_OK(err, "attach alloc_prog_fd")) - goto detach_cgroup; + goto close_cgroup; ASSERT_EQ(query_prog_cnt(cgroup_fd, "bpf_lsm_sk_alloc_security"), 1, "prog count"); ASSERT_EQ(query_prog_cnt(cgroup_fd, NULL), 1, "total prog count"); diff --git a/tools/testing/selftests/bpf/test_progs.h b/tools/testing/selftests/bpf/test_progs.h index 0ba5a20b19ba..25f6976c08b5 100644 --- a/tools/testing/selftests/bpf/test_progs.h +++ b/tools/testing/selftests/bpf/test_progs.h @@ -338,8 +338,13 @@ int test__join_cgroup(const char *path); static int duration = 0; \ long long ___res = (res); \ bool ___ok = ___res == 0; \ - CHECK(!___ok, (name), "unexpected error: %lld (errno %d)\n", \ - ___res, errno); \ + if (___res == -ENOTSUPP || ___res == -ENOTSUP || \ + errno == ENOTSUPP || errno == ENOTSUP) \ + test__skip(); \ + else \ + CHECK(!___ok, (name), \ + "unexpected error: %lld (errno %d)\n", \ + ___res, errno); \ ___ok; \ }) From patchwork Thu Jul 4 06:48:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13723311 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 1040C1BC4E; Thu, 4 Jul 2024 06:48:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720075719; cv=none; b=Jl58RxRCixNGPsUNullDeLiSPPEK1RLzshfDCvmoEPAztmWHRZnM6qa9SJ23AHJIzAQMI5r/JDOcBOfuB1n8xmHV1bEwgeKWF7W0eqgm2607pb9jwRU2bU7h1TBGMJfCk5zeSKCbESlQFduEOihwuy/+GAPaQwu6omjqJpenyog= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720075719; c=relaxed/simple; bh=i1hi7joj/cR8gtdNdPAzFDk5iX3Vay2ss48OzQh+0WM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=o6g+kovITxgPmJjAPiI44RT2AZyEIEaEsmDFY3XfxkLyZmI7ZSwaxCQuc1VOEWAjmrKm5D2PoA6HaumogaWeOW1o/siTrHEzw2740oWPtTo7tFu8vL5Mz4ChDzfTCTjhOzVYflpqkp7FL5YEGUcwYW07GdWvR7DgL6qOa8Df8KE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=OCW5BT8J; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="OCW5BT8J" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BECC4C3277B; Thu, 4 Jul 2024 06:48:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720075718; bh=i1hi7joj/cR8gtdNdPAzFDk5iX3Vay2ss48OzQh+0WM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OCW5BT8JRx4+ykZAMrR6B3ppEkyzF7zvFKm5F6ayh6uqlygaju0/bT9RaM3zYqaZi ArP33Xl9QqTANgyi3MMQ26ciTL4Ic8v0m9eBmk98m05hb3LpyIwASY++MFa6fVCq6T CC2vhrNUGTGyHkOnV0iMlUKskEdZxZAvR+gDlv1gMx8Nns/BhS5WD5p3sA/gANBjRp X2ckX4cfNk4euIogSgL1J12590BIEb0ANHRwRfXBtVvNfahhQ9PJAxUUNhWVd+24zA BqCpe+HsVeIAg/HwQreM8aweldZNcgrC8K3H2psmS7APbXmpYYWmYPXlfT7B9Y4lCU IduESX622BUxA== From: Geliang Tang To: Andrii Nakryiko , Eduard Zingerman , Mykola Lysenko , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Shuah Khan Cc: Geliang Tang , bpf@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH 3/6] selftests/bpf: Use ASSERT_OK to skip ENOTSUPP Date: Thu, 4 Jul 2024 14:48:03 +0800 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Geliang Tang There are so many "ENOTSUPP" (-524) errors when running BPF selftests on a Loongarch platform since lacking BPF trampoline on Loongarch: ''' test_d_path_basic:PASS:setup 0 nsec libbpf: prog 'prog_stat': failed to attach: unknown error (-524) libbpf: prog 'prog_stat': failed to auto-attach: -524 test_d_path_basic:FAIL:setup attach failed: -524 #77/1 d_path/basic:FAIL #77/2 d_path/check_rdonly_mem:OK #77/3 d_path/check_alloc_mem:OK #77 d_path:FAIL ... ... test_module_attach:PASS:skel_open 0 nsec test_module_attach:PASS:set_attach_target 0 nsec test_module_attach:PASS:set_attach_target_explicit 0 nsec test_module_attach:PASS:skel_load 0 nsec libbpf: prog 'handle_fentry': failed to attach: unknown error (-524) libbpf: prog 'handle_fentry': failed to auto-attach: -524 test_module_attach:FAIL:skel_attach skeleton attach failed: -524 #167 module_attach:FAIL ... ... ringbuf_subtest:PASS:skel_open 0 nsec ringbuf_subtest:PASS:skel_load 0 nsec ringbuf_subtest:PASS:rw_cons_pos 0 nsec ringbuf_subtest:PASS:rw_extend 0 nsec ringbuf_subtest:PASS:exec_cons_pos_protect 0 nsec ringbuf_subtest:PASS:unmap_rw 0 nsec ringbuf_subtest:PASS:wr_prod_pos 0 nsec ringbuf_subtest:PASS:wr_prod_pos_err 0 nsec ringbuf_subtest:PASS:wr_data_page_one 0 nsec ringbuf_subtest:PASS:wr_data_page_one_err 0 nsec ringbuf_subtest:PASS:wr_data_page_two 0 nsec ringbuf_subtest:PASS:wr_data_page_all 0 nsec ringbuf_subtest:PASS:ro_prod_pos 0 nsec ringbuf_subtest:PASS:write_protect 0 nsec ringbuf_subtest:PASS:exec_protect 0 nsec ringbuf_subtest:PASS:ro_remap 0 nsec ringbuf_subtest:PASS:unmap_ro 0 nsec ringbuf_subtest:PASS:ro_prod_pos 0 nsec ringbuf_subtest:PASS:write_protect 0 nsec ringbuf_subtest:PASS:exec_protect 0 nsec ringbuf_subtest:PASS:ro_remap 0 nsec ringbuf_subtest:PASS:unmap_ro 0 nsec ringbuf_subtest:PASS:ringbuf_create 0 nsec ringbuf_subtest:FAIL:skel_attach skeleton attachment failed: -1 #277/1 ringbuf/ringbuf:FAIL #277/2 ringbuf/ringbuf_n:SKIP #277/3 ringbuf/ringbuf_map_key:SKIP #277 ringbuf:FAIL ... ... test_test_bprm_opts:PASS:skel_load 0 nsec libbpf: prog 'secure_exec': failed to attach: unknown error (-524) libbpf: prog 'secure_exec': failed to auto-attach: -524 test_test_bprm_opts:FAIL:attach attach failed: -524 #382 test_bprm_opts:FAIL ... ... test_test_ima:PASS:skel_load 0 nsec test_test_ima:PASS:ringbuf 0 nsec libbpf: prog 'bprm_committed_creds': failed to attach: \ unknown error (-524) libbpf: prog 'bprm_committed_creds': failed to auto-attach: -524 test_test_ima:FAIL:attach attach failed: -524 #384 test_ima:FAIL ... ... test_trace_ext:PASS:setup 0 nsec test_trace_ext:PASS:setup 0 nsec test_trace_ext:PASS:setup 0 nsec test_trace_ext:PASS:setup 0 nsec libbpf: prog 'test_pkt_md_access_new': failed to attach: \ unknown error (-524) libbpf: prog 'test_pkt_md_access_new': failed to auto-attach: -524 test_trace_ext:FAIL:setup freplace/test_pkt_md_access attach failed: -524 #397 trace_ext:FAIL ''' This patch uses ASSERT_OK() instead of CHECK() to skip these "ENOTSUPP" errors. With this change, the new output of these selftests look like: ''' #77/1 d_path/basic:SKIP #77/2 d_path/check_rdonly_mem:OK #77/3 d_path/check_alloc_mem:OK #77 d_path:OK (SKIP: 1/3) ... ... #167 module_attach:SKIP ... ... #277/1 ringbuf/ringbuf:SKIP #277/2 ringbuf/ringbuf_n:SKIP #277/3 ringbuf/ringbuf_map_key:SKIP #277 ringbuf:SKIP ... ... #382 test_bprm_opts:SKIP ... ... #384 test_ima:SKIP ... ... #397 trace_ext:SKIP ''' Signed-off-by: Geliang Tang --- tools/testing/selftests/bpf/prog_tests/d_path.c | 2 +- tools/testing/selftests/bpf/prog_tests/module_attach.c | 2 +- tools/testing/selftests/bpf/prog_tests/ringbuf.c | 2 +- tools/testing/selftests/bpf/prog_tests/test_bprm_opts.c | 2 +- tools/testing/selftests/bpf/prog_tests/test_ima.c | 2 +- tools/testing/selftests/bpf/prog_tests/trace_ext.c | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/d_path.c b/tools/testing/selftests/bpf/prog_tests/d_path.c index ccc768592e66..78110075b485 100644 --- a/tools/testing/selftests/bpf/prog_tests/d_path.c +++ b/tools/testing/selftests/bpf/prog_tests/d_path.c @@ -129,7 +129,7 @@ static void test_d_path_basic(void) goto cleanup; err = test_d_path__attach(skel); - if (CHECK(err, "setup", "attach failed: %d\n", err)) + if (!ASSERT_OK(err, "setup")) goto cleanup; bss = skel->bss; diff --git a/tools/testing/selftests/bpf/prog_tests/module_attach.c b/tools/testing/selftests/bpf/prog_tests/module_attach.c index 6d391d95f96e..4aab747ad202 100644 --- a/tools/testing/selftests/bpf/prog_tests/module_attach.c +++ b/tools/testing/selftests/bpf/prog_tests/module_attach.c @@ -62,7 +62,7 @@ void test_module_attach(void) bss = skel->bss; err = test_module_attach__attach(skel); - if (CHECK(err, "skel_attach", "skeleton attach failed: %d\n", err)) + if (!ASSERT_OK(err, "skel_attach")) goto cleanup; /* trigger tracepoint */ diff --git a/tools/testing/selftests/bpf/prog_tests/ringbuf.c b/tools/testing/selftests/bpf/prog_tests/ringbuf.c index 4c6f42dae409..ee7deb76b60a 100644 --- a/tools/testing/selftests/bpf/prog_tests/ringbuf.c +++ b/tools/testing/selftests/bpf/prog_tests/ringbuf.c @@ -161,7 +161,7 @@ static void ringbuf_subtest(void) goto cleanup; err = test_ringbuf_lskel__attach(skel); - if (CHECK(err, "skel_attach", "skeleton attachment failed: %d\n", err)) + if (!ASSERT_OK(err, "skel_attach")) goto cleanup; trigger_samples(); diff --git a/tools/testing/selftests/bpf/prog_tests/test_bprm_opts.c b/tools/testing/selftests/bpf/prog_tests/test_bprm_opts.c index a0054019e677..40a86a303c1a 100644 --- a/tools/testing/selftests/bpf/prog_tests/test_bprm_opts.c +++ b/tools/testing/selftests/bpf/prog_tests/test_bprm_opts.c @@ -88,7 +88,7 @@ void test_test_bprm_opts(void) goto close_prog; err = bprm_opts__attach(skel); - if (CHECK(err, "attach", "attach failed: %d\n", err)) + if (!ASSERT_OK(err, "attach")) goto close_prog; /* Run the test with the secureexec bit unset */ diff --git a/tools/testing/selftests/bpf/prog_tests/test_ima.c b/tools/testing/selftests/bpf/prog_tests/test_ima.c index 810b14981c2e..2a6c388fe29d 100644 --- a/tools/testing/selftests/bpf/prog_tests/test_ima.c +++ b/tools/testing/selftests/bpf/prog_tests/test_ima.c @@ -83,7 +83,7 @@ void test_test_ima(void) goto close_prog; err = ima__attach(skel); - if (CHECK(err, "attach", "attach failed: %d\n", err)) + if (!ASSERT_OK(err, "attach")) goto close_prog; measured_dir = mkdtemp(measured_dir_template); diff --git a/tools/testing/selftests/bpf/prog_tests/trace_ext.c b/tools/testing/selftests/bpf/prog_tests/trace_ext.c index aabdff7bea3e..d006c0b91178 100644 --- a/tools/testing/selftests/bpf/prog_tests/trace_ext.c +++ b/tools/testing/selftests/bpf/prog_tests/trace_ext.c @@ -60,7 +60,7 @@ void test_trace_ext(void) } err = test_trace_ext__attach(skel_ext); - if (CHECK(err, "setup", "freplace/test_pkt_md_access attach failed: %d\n", err)) + if (!ASSERT_OK(err, "setup replace/test_pkt_md_access attach")) goto cleanup; prog = skel_ext->progs.test_pkt_md_access_new; From patchwork Thu Jul 4 06:48:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13723312 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 1B5AB1BC4E; Thu, 4 Jul 2024 06:48:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720075725; cv=none; b=U7l3SkVTBZE+wSrykS1xvxFfGQQpOXO9UcrwJdrV/LPaGOya6ayPnky99v0tXlUl1aHY1dcWrqnM+E/c+zc6FFinPeB/8sI77JCdGTcV8iw+2ly1TywOG5ygYG1Zbob1cJudDNVcNu0cCdXALuOSx0GJ+57mJam9wvjMnCjVj0Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720075725; c=relaxed/simple; bh=Mb8k4zWoJ3BhIpD2KKINFF2veb6v9T7oCfAwzClcDKQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hT8U5m3xzW/PTH9ieVhTVNORSoqQIFnkBzi4l0iGV871wQp5PHnINrNv9Go9ElX6lp5y9trR//fouCaeQJNeGcMLp5BgT+eWiKXSEZ2EcdnO5kzC3nc2j8lBeDloS8Q7nipQtJyxS6PnUgbMNwMuu24/AYV3wCPJR+GT6m1PXgQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Nw3zmwCo; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Nw3zmwCo" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8E76AC3277B; Thu, 4 Jul 2024 06:48:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720075724; bh=Mb8k4zWoJ3BhIpD2KKINFF2veb6v9T7oCfAwzClcDKQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Nw3zmwCoPdWbH9zM9j2+iyf0n9tgDm9uVm4PbW3frlBvPTvyTGeseaF0+wfeQmFT1 lGk8bHut8dSDLbz8kGJN3VPDv+vuKF/o9vu7Z8Da+NeZrsrZ91P3tlXV7Frvm2b5F6 Bt3Tli5tW1/ONktSKBwwJ6nHI7zpACJ+rq0zUcLiSyoLfA1ozev5tHSpEzq45T7TIZ NItuH3vdFtt7DYtoOhzdQsEizM/cJTsVlGc7zehgCM2AUHRZT5Z7sQoMHVSlcg6VNv /CR0Oh78anHe6a8pFfDoYk/HIrNDaPcOdGtaYnb/kEwNN7m8p1wUeOtwFL1W59T1lP RNSs7rFBfcbmQ== From: Geliang Tang To: Andrii Nakryiko , Eduard Zingerman , Mykola Lysenko , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Shuah Khan Cc: Geliang Tang , bpf@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH 4/6] selftests/bpf: Null checks for link in bpf_tcp_ca Date: Thu, 4 Jul 2024 14:48:04 +0800 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Geliang Tang Run bpf_tcp_ca selftests (./test_progs -t bpf_tcp_ca) on a Loongarch platform, some "Segmentation fault" errors occur: ''' test_dctcp:PASS:bpf_dctcp__open_and_load 0 nsec test_dctcp:FAIL:bpf_map__attach_struct_ops unexpected error: -524 #29/1 bpf_tcp_ca/dctcp:FAIL test_cubic:PASS:bpf_cubic__open_and_load 0 nsec test_cubic:FAIL:bpf_map__attach_struct_ops unexpected error: -524 #29/2 bpf_tcp_ca/cubic:FAIL test_dctcp_fallback:PASS:dctcp_skel 0 nsec test_dctcp_fallback:PASS:bpf_dctcp__load 0 nsec test_dctcp_fallback:FAIL:dctcp link unexpected error: -524 #29/4 bpf_tcp_ca/dctcp_fallback:FAIL test_write_sk_pacing:PASS:open_and_load 0 nsec test_write_sk_pacing:FAIL:attach_struct_ops unexpected error: -524 #29/6 bpf_tcp_ca/write_sk_pacing:FAIL test_update_ca:PASS:open 0 nsec test_update_ca:FAIL:attach_struct_ops unexpected error: -524 settcpca:FAIL:setsockopt unexpected setsockopt: \ actual -1 == expected -1 (network_helpers.c:99: errno: No such file or directory) \ Failed to call post_socket_cb start_test:FAIL:start_server_str unexpected start_server_str: \ actual -1 == expected -1 test_update_ca:FAIL:ca1_ca1_cnt unexpected ca1_ca1_cnt: \ actual 0 <= expected 0 #29/9 bpf_tcp_ca/update_ca:FAIL #29 bpf_tcp_ca:FAIL Caught signal #11! Stack trace: ./test_progs(crash_handler+0x28)[0x5555567ed91c] linux-vdso.so.1(__vdso_rt_sigreturn+0x0)[0x7ffffee408b0] ./test_progs(bpf_link__update_map+0x80)[0x555556824a78] ./test_progs(+0x94d68)[0x5555564c4d68] ./test_progs(test_bpf_tcp_ca+0xe8)[0x5555564c6a88] ./test_progs(+0x3bde54)[0x5555567ede54] ./test_progs(main+0x61c)[0x5555567efd54] /usr/lib64/libc.so.6(+0x22208)[0x7ffff2aaa208] /usr/lib64/libc.so.6(__libc_start_main+0xac)[0x7ffff2aaa30c] ./test_progs(_start+0x48)[0x55555646bca8] Segmentation fault ''' This is because "link" returned by bpf_map__attach_struct_ops() is NULL in this case. test_progs crashs when this NULL link passes to bpf_link__update_map(). This patch adds NULL checks for all links in bpf_tcp_ca to fix these errors. If "link" is NULL, goto the newly added label "err" to destroy the skel. v2: - use "goto err" instead of "return" as Eduard suggested. Signed-off-by: Geliang Tang --- .../selftests/bpf/prog_tests/bpf_tcp_ca.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c b/tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c index fa2efb246d3b..45a21a064437 100644 --- a/tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c +++ b/tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c @@ -407,7 +407,8 @@ static void test_update_ca(void) return; link = bpf_map__attach_struct_ops(skel->maps.ca_update_1); - ASSERT_OK_PTR(link, "attach_struct_ops"); + if (!ASSERT_OK_PTR(link, "attach_struct_ops")) + goto err; do_test(&opts); saved_ca1_cnt = skel->bss->ca1_cnt; @@ -421,6 +422,7 @@ static void test_update_ca(void) ASSERT_GT(skel->bss->ca2_cnt, 0, "ca2_ca2_cnt"); bpf_link__destroy(link); +err: tcp_ca_update__destroy(skel); } @@ -443,7 +445,8 @@ static void test_update_wrong(void) return; link = bpf_map__attach_struct_ops(skel->maps.ca_update_1); - ASSERT_OK_PTR(link, "attach_struct_ops"); + if (!ASSERT_OK_PTR(link, "attach_struct_ops")) + goto err; do_test(&opts); saved_ca1_cnt = skel->bss->ca1_cnt; @@ -456,6 +459,7 @@ static void test_update_wrong(void) ASSERT_GT(skel->bss->ca1_cnt, saved_ca1_cnt, "ca2_ca1_cnt"); bpf_link__destroy(link); +err: tcp_ca_update__destroy(skel); } @@ -480,7 +484,8 @@ static void test_mixed_links(void) ASSERT_OK_PTR(link_nl, "attach_struct_ops_nl"); link = bpf_map__attach_struct_ops(skel->maps.ca_update_1); - ASSERT_OK_PTR(link, "attach_struct_ops"); + if (!ASSERT_OK_PTR(link, "attach_struct_ops")) + goto err; do_test(&opts); ASSERT_GT(skel->bss->ca1_cnt, 0, "ca1_ca1_cnt"); @@ -489,6 +494,7 @@ static void test_mixed_links(void) ASSERT_ERR(err, "update_map"); bpf_link__destroy(link); +err: bpf_link__destroy(link_nl); tcp_ca_update__destroy(skel); } @@ -532,7 +538,8 @@ static void test_link_replace(void) bpf_link__destroy(link); link = bpf_map__attach_struct_ops(skel->maps.ca_update_2); - ASSERT_OK_PTR(link, "attach_struct_ops_2nd"); + if (!ASSERT_OK_PTR(link, "attach_struct_ops_2nd")) + goto err; /* BPF_F_REPLACE with a wrong old map Fd. It should fail! * @@ -555,6 +562,7 @@ static void test_link_replace(void) bpf_link__destroy(link); +err: tcp_ca_update__destroy(skel); } From patchwork Thu Jul 4 06:48:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13723313 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 6900018637; Thu, 4 Jul 2024 06:48:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720075730; cv=none; b=RrC+xZVhALA9OBeP0YoIsOf6Ss45i64PwuFQ3Q4ABS7A+lkjtIfRcEWN21Zy/BqpFK8SlUIcOkB4lx/WwcESpG42AEqJ7XSFkbrZ400AHrX8zOiFqbKCCsKpDLSoLjf04o3L35drAzzfjllIRwcStwkNejLJZKC1CtjFc5SgFrk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720075730; c=relaxed/simple; bh=LkRPX3ra3F+F5EKKI+sEIgNO5JK+F5Sff8fCHyJQoYY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=quuc6OY1RchAYKfCxD6pKCtXe97QhaNUiOI8OBppJQL8Ilde9adOz2IT3dUMn8SqhyXa190YPhB5bicmWQB1Xb6Nuwg5OqhymK1bTwMQ4JV8uFJYaOjCXdro5d8w2kK8wz7UsiAsnknsDVVvR2UFd6LrqnGwLexk33q2ikdV01A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=o5vZodhC; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="o5vZodhC" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 37BEFC32786; Thu, 4 Jul 2024 06:48:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720075729; bh=LkRPX3ra3F+F5EKKI+sEIgNO5JK+F5Sff8fCHyJQoYY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o5vZodhCSfdb2eeclOG61GjK/cOMW2JhOvXmUDPUY1UIPygePKTA7jgIgsXCoVaCD HrbyBaYIbGxAqCZywTfYus50I/RLm10bs79gXKOnREamWSFRjULg4l/vHTuJ7Pi5AV A5jhiT7f4TNDgFpbvinyVUj0kUkwvgIz/b39+bI5TRcLuabXuTY1AUvfGJBWQ4VPV2 ep0AzXYxvmosbqtcYiD2AHwbt4pc2HZlod8p81cVNOifdSU+Wl9/VgQOQC4+OO98IV JJp1V8YED1SuiEDtxvO+s08u+EghwuE44DqZTbQQx8bfEkmxbslNMWD76sSUchGCdu AaUFkTEZVFzyA== From: Geliang Tang To: Andrii Nakryiko , Eduard Zingerman , Mykola Lysenko , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Shuah Khan Cc: Geliang Tang , bpf@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH 5/6] selftests/bpf: Skip ENOTSUPP in ASSERT_OK_PTR Date: Thu, 4 Jul 2024 14:48:05 +0800 Message-ID: <9f722006ec00357ecbc1ecfa02e7fcefbf297f90.1720075006.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Geliang Tang Although the "Segmentation fault" errors are fixed in the last commit, run bpf_tcp_ca selftests (./test_progs -t bpf_tcp_ca) on a Loongarch platform, still some other "ENOTSUPP" (-524) errors left since lacking BPF trampoline on Loongarch: ''' test_dctcp:PASS:bpf_dctcp__open_and_load 0 nsec test_dctcp:FAIL:bpf_map__attach_struct_ops unexpected error: -524 #29/1 bpf_tcp_ca/dctcp:FAIL test_cubic:PASS:bpf_cubic__open_and_load 0 nsec test_cubic:FAIL:bpf_map__attach_struct_ops unexpected error: -524 #29/2 bpf_tcp_ca/cubic:FAIL #29/3 bpf_tcp_ca/invalid_license:OK test_dctcp_fallback:PASS:dctcp_skel 0 nsec test_dctcp_fallback:PASS:bpf_dctcp__load 0 nsec test_dctcp_fallback:FAIL:dctcp link unexpected error: -524 #29/4 bpf_tcp_ca/dctcp_fallback:FAIL #29/5 bpf_tcp_ca/rel_setsockopt:OK test_write_sk_pacing:PASS:open_and_load 0 nsec test_write_sk_pacing:FAIL:attach_struct_ops unexpected error: -524 #29/6 bpf_tcp_ca/write_sk_pacing:FAIL #29/7 bpf_tcp_ca/incompl_cong_ops:OK #29/8 bpf_tcp_ca/unsupp_cong_op:OK test_update_ca:PASS:open 0 nsec test_update_ca:FAIL:attach_struct_ops unexpected error: -524 #29/9 bpf_tcp_ca/update_ca:FAIL test_update_wrong:PASS:open 0 nsec test_update_wrong:FAIL:attach_struct_ops unexpected error: -524 #29/10 bpf_tcp_ca/update_wrong:FAIL test_mixed_links:PASS:open 0 nsec test_mixed_links:FAIL:attach_struct_ops_nl unexpected error: -524 test_mixed_links:FAIL:attach_struct_ops unexpected error: -524 #29/11 bpf_tcp_ca/mixed_links:FAIL test_multi_links:PASS:open 0 nsec test_multi_links:FAIL:attach_struct_ops_1st unexpected error: -524 test_multi_links:FAIL:attach_struct_ops_2nd unexpected error: -524 #29/12 bpf_tcp_ca/multi_links:FAIL test_link_replace:PASS:open 0 nsec test_link_replace:FAIL:attach_struct_ops_1st unexpected error: -524 test_link_replace:FAIL:attach_struct_ops_2nd unexpected error: -524 #29/13 bpf_tcp_ca/link_replace:FAIL #29/14 bpf_tcp_ca/tcp_ca_kfunc:OK test_cc_cubic:PASS:bpf_cc_cubic__open_and_load 0 nsec test_cc_cubic:FAIL:bpf_map__attach_struct_ops unexpected error: -524 #29/15 bpf_tcp_ca/cc_cubic:FAIL #29 bpf_tcp_ca:FAIL ''' Just like in ASSERT_OK(), this patch skips ENOTSUPP (524) and ENOTSUP (95) in ASSERT_OK_PTR() too. With this change, the new output of bpf_tcp_ca selftests look like: ''' #29/1 bpf_tcp_ca/dctcp:SKIP #29/2 bpf_tcp_ca/cubic:SKIP #29/3 bpf_tcp_ca/invalid_license:OK #29/4 bpf_tcp_ca/dctcp_fallback:SKIP #29/5 bpf_tcp_ca/rel_setsockopt:OK #29/6 bpf_tcp_ca/write_sk_pacing:SKIP #29/7 bpf_tcp_ca/incompl_cong_ops:OK #29/8 bpf_tcp_ca/unsupp_cong_op:OK #29/9 bpf_tcp_ca/update_ca:SKIP #29/10 bpf_tcp_ca/update_wrong:SKIP #29/11 bpf_tcp_ca/mixed_links:SKIP #29/12 bpf_tcp_ca/multi_links:SKIP #29/13 bpf_tcp_ca/link_replace:SKIP #29/14 bpf_tcp_ca/tcp_ca_kfunc:OK #29/15 bpf_tcp_ca/cc_cubic:SKIP #29 bpf_tcp_ca:OK (SKIP: 10/15) ''' Signed-off-by: Geliang Tang --- tools/testing/selftests/bpf/test_progs.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/bpf/test_progs.h b/tools/testing/selftests/bpf/test_progs.h index 25f6976c08b5..464aa12feada 100644 --- a/tools/testing/selftests/bpf/test_progs.h +++ b/tools/testing/selftests/bpf/test_progs.h @@ -369,7 +369,10 @@ int test__join_cgroup(const char *path); const void *___res = (ptr); \ int ___err = libbpf_get_error(___res); \ bool ___ok = ___err == 0; \ - CHECK(!___ok, (name), "unexpected error: %d\n", ___err); \ + if (___err == -ENOTSUPP || ___err == -ENOTSUP) \ + test__skip(); \ + else \ + CHECK(!___ok, (name), "unexpected error: %d\n", ___err);\ ___ok; \ }) From patchwork Thu Jul 4 06:48:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13723314 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 939451B960; Thu, 4 Jul 2024 06:48:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720075735; cv=none; b=tygyZ5js7IKgpeAic5hXrB+vLLxkla0Vwf70a4XrpQN3QjfQoBrCpk4IRvsVIWFoCpl8rfTa9byuUmalUdYOuoqFRBeirM5cGzjUFeMzAZf667nJwIv0weFytealD3oL5INCnSOrWxMIwww+yss6MG+n/anx0lkBkKiNe4GQfNs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720075735; c=relaxed/simple; bh=2KyYRBPPd7WUDhqBRx2b+SOyUf0G1E0Hbgwa4AS/ZC4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=A6L9GOt0rYrwm7PC49K8MasAE7CbFfto2SD7VkjhLVUIrTadI3Y2dw67xGHyvhxpX8vIL+Pu6dDpSKRoiBMQW40f372ZtL3vbf7M5HCrLOZH+jL6B7EoyjCjBk+kHSZJyhJ3B8VXA2q8ifvdffzjJH7juxJrLaW/RrfgjH6ilCU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=N/5m3n9F; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="N/5m3n9F" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6E5B5C3277B; Thu, 4 Jul 2024 06:48:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720075735; bh=2KyYRBPPd7WUDhqBRx2b+SOyUf0G1E0Hbgwa4AS/ZC4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N/5m3n9FxrruGU7mWfhgHKx+XGzQTP6+BN5Ne4yUNROzXQfuSCAJdlL1QGxhq8u19 dLDXd/RpwinkpuglYdeEf7EGxOTi6zMJDRZeeiYAJdk2zoU7MuIOtcnclvb9mPzt2L Q/+HxN6v2kq48kB4BYd3CvxjhVIEB1VvHbYmC1r4cnzM6w8uaUbt797EICm0EwIOoh Z5+ETRSn7GtFk31rzOvMy3qupN/ocetzjXY6BbpfCbmIOEckJrY+snPjf3jcj5AW1V jpZ4q7TgYld9FJPC7pUSZ+nmPjhb65jYQR6kKYs96J6DhiS4fSMfqu8r7qw2a0qc7R tcR9DhGStEL5A== From: Geliang Tang To: Andrii Nakryiko , Eduard Zingerman , Mykola Lysenko , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Shuah Khan Cc: Geliang Tang , bpf@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH 6/6] selftests/bpf: Skip ENOTSUPP in ASSERT_GE Date: Thu, 4 Jul 2024 14:48:06 +0800 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Geliang Tang There are still some "ENOTSUPP" (-524) errors left when running BPF selftests on a Loongarch platform since ASSERT_GE() are used there to check the return values, not ASSERT_OK(): ''' test_bpf_cookie:PASS:skel_open 0 nsec #17/1 bpf_cookie/kprobe:OK #17/2 bpf_cookie/multi_kprobe_link_api:OK #17/3 bpf_cookie/multi_kprobe_attach_api:OK #17/4 bpf_cookie/uprobe:OK #17/5 bpf_cookie/multi_uprobe_attach_api:OK #17/6 bpf_cookie/tracepoint:OK #17/7 bpf_cookie/perf_event:OK tracing_subtest:FAIL:fentry.link_create unexpected fentry.link_create: \ actual -524 < expected 0 #17/8 bpf_cookie/trampoline:FAIL lsm_subtest:FAIL:lsm.link_create unexpected lsm.link_create: \ actual -524 < expected 0 #17/9 bpf_cookie/lsm:FAIL #17/10 bpf_cookie/tp_btf:OK #17/11 bpf_cookie/raw_tp:OK #17 bpf_cookie:FAIL ... ... test_module_fentry_shadow:PASS:load_vmlinux_btf 0 nsec test_module_fentry_shadow:PASS:get_bpf_testmod_btf_fd 0 nsec test_module_fentry_shadow:PASS:btf_get_from_fd 0 nsec test_module_fentry_shadow:PASS:btf_find_by_name 0 nsec test_module_fentry_shadow:PASS:btf_find_by_name 0 nsec test_module_fentry_shadow:PASS:bpf_prog_load 0 nsec test_module_fentry_shadow:FAIL:bpf_link_create unexpected \ bpf_link_create: actual -524 < expected 0 #168 module_fentry_shadow:FAIL ''' Just like in ASSERT_OK(), this patch skips ENOTSUPP (524) and ENOTSUP (95) in ASSERT_GT() too. With this change, the new output of these selftests look like: ''' #17/1 bpf_cookie/kprobe:OK #17/2 bpf_cookie/multi_kprobe_link_api:OK #17/3 bpf_cookie/multi_kprobe_attach_api:OK #17/4 bpf_cookie/uprobe:OK #17/5 bpf_cookie/multi_uprobe_attach_api:OK #17/6 bpf_cookie/tracepoint:OK #17/7 bpf_cookie/perf_event:OK #17/8 bpf_cookie/trampoline:SKIP #17/9 bpf_cookie/lsm:SKIP #17/10 bpf_cookie/tp_btf:SKIP #17/11 bpf_cookie/raw_tp:SKIP #17 bpf_cookie:OK (SKIP: 4/11) ... ... #168 module_fentry_shadow:SKIP ''' Signed-off-by: Geliang Tang --- tools/testing/selftests/bpf/test_progs.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/bpf/test_progs.h b/tools/testing/selftests/bpf/test_progs.h index 464aa12feada..8a5ce360aa1c 100644 --- a/tools/testing/selftests/bpf/test_progs.h +++ b/tools/testing/selftests/bpf/test_progs.h @@ -294,9 +294,13 @@ int test__join_cgroup(const char *path); typeof(actual) ___act = (actual); \ typeof(expected) ___exp = (expected); \ bool ___ok = ___act >= ___exp; \ - CHECK(!___ok, (name), \ - "unexpected %s: actual %lld < expected %lld\n", \ - (name), (long long)(___act), (long long)(___exp)); \ + if (___act == -ENOTSUPP || ___act == -ENOTSUP || \ + errno == ENOTSUPP || errno == ENOTSUP) \ + test__skip(); \ + else \ + CHECK(!___ok, (name), \ + "unexpected %s: actual %lld < expected %lld\n", \ + (name), (long long)(___act), (long long)(___exp));\ ___ok; \ })