From c71dfae7df36a32d8f9fc362bc64c3a61c80e322 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20=C5=BBenczykowski?= Date: Wed, 9 Aug 2023 21:48:28 +0000 Subject: [PATCH] update bpf_existence_test to enforce minimum kver MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Test: TreeHugger Signed-off-by: Maciej Żenczykowski Change-Id: Ibcb4fd53b0bbb04dc52f9fcbb5ab6bdae9efe02c --- tests/mts/bpf_existence_test.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/mts/bpf_existence_test.cpp b/tests/mts/bpf_existence_test.cpp index c294e7bc8d..442d69f220 100644 --- a/tests/mts/bpf_existence_test.cpp +++ b/tests/mts/bpf_existence_test.cpp @@ -33,6 +33,8 @@ using android::bpf::isAtLeastKernelVersion; using android::modules::sdklevel::IsAtLeastR; using android::modules::sdklevel::IsAtLeastS; using android::modules::sdklevel::IsAtLeastT; +using android::modules::sdklevel::IsAtLeastU; +using android::modules::sdklevel::IsAtLeastV; #define PLATFORM "/sys/fs/bpf/" #define TETHERING "/sys/fs/bpf/tethering/" @@ -147,10 +149,14 @@ TEST_F(BpfExistenceTest, TestPrograms) { // so we should only test for the removal of stuff that was mainline'd, // and for the presence of mainline stuff. + // Note: Q is no longer supported by mainline + ASSERT_TRUE(IsAtLeastR()); + // R can potentially run on pre-4.9 kernel non-eBPF capable devices. DO_EXPECT(IsAtLeastR() && !IsAtLeastS() && isAtLeastKernelVersion(4, 9, 0), PLATFORM_ONLY_IN_R); // S requires Linux Kernel 4.9+ and thus requires eBPF support. + if (IsAtLeastS()) ASSERT_TRUE(isAtLeastKernelVersion(4, 9, 0)); DO_EXPECT(IsAtLeastS(), MAINLINE_FOR_S_PLUS); DO_EXPECT(IsAtLeastS() && isAtLeastKernelVersion(5, 10, 0), MAINLINE_FOR_S_5_10_PLUS); @@ -163,6 +169,10 @@ TEST_F(BpfExistenceTest, TestPrograms) { DO_EXPECT(IsAtLeastT() && isAtLeastKernelVersion(5, 15, 0), MAINLINE_FOR_T_5_15_PLUS); // U requires Linux Kernel 4.14+, but nothing (as yet) added or removed in U. + if (IsAtLeastU()) ASSERT_TRUE(isAtLeastKernelVersion(4, 14, 0)); + + // V requires Linux Kernel 4.19+, but nothing (as yet) added or removed in V. + if (IsAtLeastV()) ASSERT_TRUE(isAtLeastKernelVersion(4, 19, 0)); for (const auto& file : mustExist) { EXPECT_EQ(0, access(file.c_str(), R_OK)) << file << " does not exist";