From patchwork Fri Feb 3 16:23:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Olsa X-Patchwork-Id: 13128082 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 93CA2C05027 for ; Fri, 3 Feb 2023 16:24:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232602AbjBCQYh (ORCPT ); Fri, 3 Feb 2023 11:24:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231629AbjBCQYd (ORCPT ); Fri, 3 Feb 2023 11:24:33 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 712B1A6C31 for ; Fri, 3 Feb 2023 08:24:26 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0B10061F72 for ; Fri, 3 Feb 2023 16:24:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 59F5EC433EF; Fri, 3 Feb 2023 16:24:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675441465; bh=ezccFv4heL8FQl8SJ4uv1sDVpD9zQulszGW8H+xPaxg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T3mt38Tk6CEmrxichSlfY0T1I2bp7QqjI9KAxh8q0wNXF0qMvaAt8OlFqWLU/vyvv nYF41Q9vI6ySPQIDFPK+/VkR4QZaclUH0du+O30mutv5r6NFxYNtpJ7r9zX4rn+4I/ +C9xWEUj+D9GWcuwBGWwaVn6+vlFOPirxuJkHwrXyZbNBmksUdNFLXO8U69N/g0Cgp y9udicmW6d8Im8edM6tNhIrgwA6YN49YjRDsN/kkN92e3TkDmP3svEM3oEQoldH7Y7 gUJCmvKrWt+xhCMlrtdoT/jRy+1W0OquNLXmhXnASrcf5ifXJInAmbLPjUqPopkrmI t3TOgRKWMN6kg== From: Jiri Olsa To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Cc: David Vernet , bpf@vger.kernel.org, Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Kumar Kartikeya Dwivedi , Artem Savkov Subject: [PATCHv3 bpf-next 4/9] selftests/bpf: Do not unload bpf_testmod in load_bpf_testmod Date: Fri, 3 Feb 2023 17:23:31 +0100 Message-Id: <20230203162336.608323-5-jolsa@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230203162336.608323-1-jolsa@kernel.org> References: <20230203162336.608323-1-jolsa@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net Do not unload bpf_testmod in load_bpf_testmod, instead call unload_bpf_testmod separatelly. This way we will be able use un/load_bpf_testmod functions in other tests that un/load bpf_testmod module. Acked-by: David Vernet Signed-off-by: Jiri Olsa --- tools/testing/selftests/bpf/test_progs.c | 11 ++++++++--- tools/testing/selftests/bpf/testing_helpers.c | 3 --- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/tools/testing/selftests/bpf/test_progs.c b/tools/testing/selftests/bpf/test_progs.c index 39ceb6a1bfc6..0b4925cf6331 100644 --- a/tools/testing/selftests/bpf/test_progs.c +++ b/tools/testing/selftests/bpf/test_progs.c @@ -1592,9 +1592,14 @@ int main(int argc, char **argv) env.stderr = stderr; env.has_testmod = true; - if (!env.list_test_names && load_bpf_testmod(verbose())) { - fprintf(env.stderr, "WARNING! Selftests relying on bpf_testmod.ko will be skipped.\n"); - env.has_testmod = false; + if (!env.list_test_names) { + /* ensure previous instance of the module is unloaded */ + unload_bpf_testmod(verbose()); + + if (load_bpf_testmod(verbose())) { + fprintf(env.stderr, "WARNING! Selftests relying on bpf_testmod.ko will be skipped.\n"); + env.has_testmod = false; + } } /* initializing tests */ diff --git a/tools/testing/selftests/bpf/testing_helpers.c b/tools/testing/selftests/bpf/testing_helpers.c index fd22c64646fc..3872c36c17d4 100644 --- a/tools/testing/selftests/bpf/testing_helpers.c +++ b/tools/testing/selftests/bpf/testing_helpers.c @@ -262,9 +262,6 @@ int load_bpf_testmod(bool verbose) { int fd; - /* ensure previous instance of the module is unloaded */ - unload_bpf_testmod(verbose); - if (verbose) fprintf(stdout, "Loading bpf_testmod.ko...\n");