From mboxrd@z Thu Jan 1 00:00:00 1970 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 421F8C8EC for ; Mon, 15 May 2023 13:38:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 300A9C433D2; Mon, 15 May 2023 13:38:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684157933; bh=PpjCQLDbUnlMKk9tHg2M9KwWLgQuMtiP2zFmMh9wIuA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QerYqZegJsfGAFZqaSpAoJGn7++W/ICx14Dkupp/cDTXcNGzQey/HSdrFG4xXrqfv feEnaetL2Ar1wgXFt6+DPgo+qYsOZzXKyl4imiMfWITax97BncBn8QpJBZX1pHIt4c YDMWudr8WkubgX+OIbQaht9vh9QE7G9Oav7PRH0sBrnnTiQl5hkdXCCx2TKnrJN9kK bTZFpXjMlU1yfrIwpCmxmk7jDBgF2f8vm8CUnea2+smldmgntAzJlGm6SxASazj8Cg sL31eRfX/ni70YqwUNp+z088NX/595cQ6AmRy3pd2AlKg6y0bRQwBq8MJBHmV0LAzh GmPYrW6ITeL2w== 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 Subject: [PATCHv4 bpf-next 05/10] selftests/bpf: Do not unload bpf_testmod in load_bpf_testmod Date: Mon, 15 May 2023 15:37:51 +0200 Message-Id: <20230515133756.1658301-6-jolsa@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230515133756.1658301-1-jolsa@kernel.org> References: <20230515133756.1658301-1-jolsa@kernel.org> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 cebe62d29f8d..4d582cac2c09 100644 --- a/tools/testing/selftests/bpf/test_progs.c +++ b/tools/testing/selftests/bpf/test_progs.c @@ -1657,9 +1657,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 f73bc88f3eb6..e01d7a62306c 100644 --- a/tools/testing/selftests/bpf/testing_helpers.c +++ b/tools/testing/selftests/bpf/testing_helpers.c @@ -359,9 +359,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"); -- 2.40.1