From 45f940a9ee3e5b2fd783f284126f001e035ba453 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20=C5=BBenczykowski?= Date: Fri, 21 Jan 2022 14:12:51 -0800 Subject: [PATCH] adjust BpfCompatTest now that clatd & netd bpf program have been mainlined MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The purpose of this test is to verify that the bpfloader related stuff in the platform is compatible with mainline module bpf .o's. To be more precise: the test is trying to check that platform/OEM BPF programs (and, by implication, the platform/OEM bpfloader) have a struct layout that is known, and thus that BPF programs shipped in mainline modules will be compatible (with the OEM bpfloader). (ie. basically this is trying to make sure that the vendor/oem haven't made incompatible changes to the bpfloader parsed structs, these can only be extended safely in aosp master) Since clatd/netd.o have been moved to mainline they are no longer a useful representation of the state of the platform side of things. (we'd simply be testing that mainline is compatible with mainline, which of course it is...) As such we pick two other bpf .o files that are still shipped as part of the platform. Verified on cuttlefish via 'atest CtsNativeNetTestCases': x86 CtsNativeNetTestCases ------------------------- CtsNativeNetTestCases (2 Test(s)) [1/2] BpfTest#bpfStructSizeTestPreT: IGNORED (0ms) [2/2] BpfTest#bpfStructSizeTest: PASSED (0ms) Summary (Test executed with 1 device(s).) ------- x86 CtsNativeNetTestCases: Passed: 1, Failed: 0, Ignored: 1, Assumption Failed: 0, All tests passed! Note: it's not clear to me if this code can even ever be run on pre-T devices... but I guess it shouldn't hurt. Bug: 215718693 Test: atest Signed-off-by: Maciej Żenczykowski Change-Id: I1b2d76e5ef95d8e4b94068f5525263653879d1f4 --- tests/cts/net/native/Android.bp | 1 + tests/cts/net/native/src/BpfCompatTest.cpp | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/cts/net/native/Android.bp b/tests/cts/net/native/Android.bp index 1d1c18e92c..153ff51964 100644 --- a/tests/cts/net/native/Android.bp +++ b/tests/cts/net/native/Android.bp @@ -43,6 +43,7 @@ cc_test { static_libs: [ "libbpf_android", "libgtest", + "libmodules-utils-build", ], // Tag this module as a cts test artifact diff --git a/tests/cts/net/native/src/BpfCompatTest.cpp b/tests/cts/net/native/src/BpfCompatTest.cpp index 874bad4ee7..97ecb9e217 100644 --- a/tests/cts/net/native/src/BpfCompatTest.cpp +++ b/tests/cts/net/native/src/BpfCompatTest.cpp @@ -21,6 +21,8 @@ #include +#include "android-modules-utils/sdk_level.h" + #include "libbpf_android.h" using namespace android::bpf; @@ -33,11 +35,17 @@ void doBpfStructSizeTest(const char *elfPath) { EXPECT_EQ(28, readSectionUint("size_of_bpf_prog_def", elfFile, 0)); } -TEST(BpfTest, bpfStructSizeTest) { +TEST(BpfTest, bpfStructSizeTestPreT) { + if (android::modules::sdklevel::IsAtLeastT()) GTEST_SKIP() << "T+ device."; doBpfStructSizeTest("/system/etc/bpf/netd.o"); doBpfStructSizeTest("/system/etc/bpf/clatd.o"); } +TEST(BpfTest, bpfStructSizeTest) { + doBpfStructSizeTest("/system/etc/bpf/gpu_mem.o"); + doBpfStructSizeTest("/system/etc/bpf/time_in_state.o"); +} + int main(int argc, char **argv) { testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS();