From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stanislav Fomichev Subject: [PATCH bpf-next v2 2/6] selftests/bpf: skip sockmap in test_maps if kernel doesn't have support Date: Mon, 17 Dec 2018 10:25:50 -0800 Message-ID: <20181217182554.52170-3-sdf@google.com> References: <20181217182554.52170-1-sdf@google.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Cc: davem@davemloft.net, daniel@iogearbox.net, ecree@solarflare.com, quentin.monnet@netronome.com, Stanislav Fomichev To: netdev@vger.kernel.org, ast@kernel.org Return-path: Received: from mail-ot1-f74.google.com ([209.85.210.74]:52203 "EHLO mail-ot1-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727840AbeLQS0Y (ORCPT ); Mon, 17 Dec 2018 13:26:24 -0500 Received: by mail-ot1-f74.google.com with SMTP id c33so7845700otb.18 for ; Mon, 17 Dec 2018 10:26:23 -0800 (PST) In-Reply-To: <20181217182554.52170-1-sdf@google.com> Sender: netdev-owner@vger.kernel.org List-ID: Use recently introduced bpf_map_type_supported() to skip test_sockmap() if map creation fails. The skipped test is indicated in the output. Example: test_sockmap SKIP (unsupported map type BPF_MAP_TYPE_SOCKMAP) Fork 1024 tasks to 'test_update_delete' ... test_sockmap SKIP (unsupported map type BPF_MAP_TYPE_SOCKMAP) Fork 1024 tasks to 'test_update_delete' ... test_maps: OK, 2 SKIPPED Signed-off-by: Stanislav Fomichev --- tools/testing/selftests/bpf/Makefile | 1 + tools/testing/selftests/bpf/test_maps.c | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile index 73aa6d8f4a2f..52a0654145ad 100644 --- a/tools/testing/selftests/bpf/Makefile +++ b/tools/testing/selftests/bpf/Makefile @@ -81,6 +81,7 @@ $(OUTPUT)/test_progs: trace_helpers.c $(OUTPUT)/get_cgroup_id_user: cgroup_helpers.c $(OUTPUT)/test_cgroup_storage: cgroup_helpers.c $(OUTPUT)/test_netcnt: cgroup_helpers.c +$(OUTPUT)/test_maps: probe_helpers.c .PHONY: force diff --git a/tools/testing/selftests/bpf/test_maps.c b/tools/testing/selftests/bpf/test_maps.c index 9c79ee017df3..bdf9bdaea73e 100644 --- a/tools/testing/selftests/bpf/test_maps.c +++ b/tools/testing/selftests/bpf/test_maps.c @@ -27,11 +27,14 @@ #include "bpf_util.h" #include "bpf_rlimit.h" +#include "probe_helpers.h" #ifndef ENOTSUPP #define ENOTSUPP 524 #endif +static int skips; + static int map_flags; #define CHECK(condition, tag, format...) ({ \ @@ -725,6 +728,15 @@ static void test_sockmap(int tasks, void *data) sizeof(key), sizeof(value), 6, 0); if (fd < 0) { + if (!bpf_map_type_supported(BPF_MAP_TYPE_SOCKMAP)) { + printf("%s SKIP (unsupported map type BPF_MAP_TYPE_SOCKMAP)\n", + __func__); + skips++; + for (i = 0; i < 6; i++) + close(sfd[i]); + return; + } + printf("Failed to create sockmap %i\n", fd); goto out_sockmap; } @@ -1702,6 +1714,6 @@ int main(void) map_flags = BPF_F_NO_PREALLOC; run_all_tests(); - printf("test_maps: OK\n"); + printf("test_maps: OK, %d SKIPPED\n", skips); return 0; } -- 2.20.0.405.gbc1bbc6f85-goog