Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f3337153 authored by Yiwei Zhang's avatar Yiwei Zhang
Browse files

GpuMem: fix flaky unittests on cuttlefish platform

There isn't enough ram allocated in the default test config, which is
fixed here. This change also adds the SKIP_IF_BPF_NOT_SUPPORTED micro as
so far there's no guarantee that S will require a BPF capable kernel.

Bug: 158873003
Test: atest gpuservice_unittest:GpuMemTest
Change-Id: Id8127a4aba894da82a8c7fa3051e6748f0b61821
Merged-In: Id8127a4aba894da82a8c7fa3051e6748f0b61821
parent 9feb4aed
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -57,11 +57,16 @@ public:
    }

    void SetUp() override {
        SKIP_IF_BPF_NOT_SUPPORTED;
        ASSERT_EQ(0, bpf::setrlimitForTest());

        mGpuMem = std::make_unique<GpuMem>();
        mTestableGpuMem = TestableGpuMem(mGpuMem.get());
        errno = 0;
        mTestMap = bpf::BpfMap<uint64_t, uint64_t>(BPF_MAP_TYPE_HASH, TEST_MAP_SIZE,
                                                   BPF_F_NO_PREALLOC);

        EXPECT_EQ(0, errno);
        EXPECT_LE(0, mTestMap.getMap().get());
        EXPECT_TRUE(mTestMap.isValid());
    }
@@ -79,6 +84,8 @@ public:
};

TEST_F(GpuMemTest, validGpuMemTotalBpfPaths) {
    SKIP_IF_BPF_NOT_SUPPORTED;

    EXPECT_EQ(mTestableGpuMem.getGpuMemTraceGroup(), "gpu_mem");
    EXPECT_EQ(mTestableGpuMem.getGpuMemTotalTracepoint(), "gpu_mem_total");
    EXPECT_EQ(mTestableGpuMem.getGpuMemTotalProgPath(),
@@ -87,16 +94,20 @@ TEST_F(GpuMemTest, validGpuMemTotalBpfPaths) {
}

TEST_F(GpuMemTest, bpfInitializationFailed) {
    SKIP_IF_BPF_NOT_SUPPORTED;

    EXPECT_EQ(dumpsys(), "Failed to initialize GPU memory eBPF\n");
}

TEST_F(GpuMemTest, gpuMemTotalMapEmpty) {
    SKIP_IF_BPF_NOT_SUPPORTED;
    mTestableGpuMem.setGpuMemTotalMap(mTestMap);

    EXPECT_EQ(dumpsys(), "GPU memory total usage map is empty\n");
}

TEST_F(GpuMemTest, globalMemTotal) {
    SKIP_IF_BPF_NOT_SUPPORTED;
    ASSERT_RESULT_OK(mTestMap.writeValue(TEST_GLOBAL_KEY, TEST_GLOBAL_VAL, BPF_ANY));
    mTestableGpuMem.setGpuMemTotalMap(mTestMap);

@@ -104,6 +115,7 @@ TEST_F(GpuMemTest, globalMemTotal) {
}

TEST_F(GpuMemTest, missingGlobalMemTotal) {
    SKIP_IF_BPF_NOT_SUPPORTED;
    ASSERT_RESULT_OK(mTestMap.writeValue(TEST_PROC_KEY_1, TEST_PROC_VAL_1, BPF_ANY));
    mTestableGpuMem.setGpuMemTotalMap(mTestMap);

@@ -111,6 +123,7 @@ TEST_F(GpuMemTest, missingGlobalMemTotal) {
}

TEST_F(GpuMemTest, procMemTotal) {
    SKIP_IF_BPF_NOT_SUPPORTED;
    ASSERT_RESULT_OK(mTestMap.writeValue(TEST_PROC_KEY_1, TEST_PROC_VAL_1, BPF_ANY));
    ASSERT_RESULT_OK(mTestMap.writeValue(TEST_PROC_KEY_2, TEST_PROC_VAL_2, BPF_ANY));
    mTestableGpuMem.setGpuMemTotalMap(mTestMap);