From mboxrd@z Thu Jan 1 00:00:00 1970 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 36885C54EED for ; Mon, 30 Jan 2023 08:56:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230517AbjA3I40 (ORCPT ); Mon, 30 Jan 2023 03:56:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235540AbjA3I4Z (ORCPT ); Mon, 30 Jan 2023 03:56:25 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87DF627D61 for ; Mon, 30 Jan 2023 00:56:22 -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 2309960EF2 for ; Mon, 30 Jan 2023 08:56:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 081B6C433EF; Mon, 30 Jan 2023 08:56:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675068981; bh=sNYaGkEITxM7ZjUJQihW+zWbIAn4vLhlSZUVi40xHXg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fSkAxTH3W1qGmzFs/T83b6qFoOewleb3dC0m1Tj83u6uS5aq0x4O1AfLfVROcijSG 8ADo0/Q3kv2/0HO4CX6ldU2Gzrc+ybikUN7r3gzfWXGBGB+zxU3fwhPWWd14EB3tEd rQ7oNYi8wcNsEHoLVW9oWKC4VYISot8/jAbqyClqHbOkD5XaVpElZBmLAOynGKkp43 ZFBCzIwbKPs+w2ynUK/8+Can2GiLtOasBBd6DL0GC03LhItARGwxTy2AmOvw4R7LXH qswtZViUoZEHljA7Z0klLxBBx+WvIFntw1dLx1TiMITm0cahxec5jIM9l6K2jd5Vgu NkpPSUHz9kIMQ== From: Jiri Olsa To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Cc: bpf@vger.kernel.org, Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , David Vernet , Kumar Kartikeya Dwivedi , Artem Savkov Subject: [PATCHv2 bpf-next 3/7] selftests/bpf: Do not unload bpf_testmod in load_bpf_testmod Date: Mon, 30 Jan 2023 09:55:36 +0100 Message-Id: <20230130085540.410638-4-jolsa@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230130085540.410638-1-jolsa@kernel.org> References: <20230130085540.410638-1-jolsa@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org 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. 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 a150c35516ef..9ca718c84890 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(env.stderr, 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(env.stderr, verbose()); + + if (load_bpf_testmod(env.stderr, 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 c0eb54bf08b3..ade6208b4a69 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(FILE *err, bool verbose) { int fd; - /* ensure previous instance of the module is unloaded */ - unload_bpf_testmod(err, verbose); - if (verbose) fprintf(stdout, "Loading bpf_testmod.ko...\n"); -- 2.39.1