1 /* 2 * Copyright 2020 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #pragma once 18 19 #include <bpf/BpfMap.h> 20 #include <gpumem/GpuMem.h> 21 22 namespace android { 23 24 class TestableGpuMem { 25 public: 26 TestableGpuMem() = default; TestableGpuMem(GpuMem * gpuMem)27 explicit TestableGpuMem(GpuMem *gpuMem) : mGpuMem(gpuMem) {} 28 setInitialized()29 void setInitialized() { mGpuMem->mInitialized.store(true); } 30 setGpuMemTotalMap(bpf::BpfMapRO<uint64_t,uint64_t> & map)31 void setGpuMemTotalMap(bpf::BpfMapRO<uint64_t, uint64_t>& map) { 32 mGpuMem->setGpuMemTotalMap(map); 33 } 34 getGpuMemTraceGroup()35 std::string getGpuMemTraceGroup() { return mGpuMem->kGpuMemTraceGroup; } 36 getGpuMemTotalTracepoint()37 std::string getGpuMemTotalTracepoint() { return mGpuMem->kGpuMemTotalTracepoint; } 38 getGpuMemTotalProgPath()39 std::string getGpuMemTotalProgPath() { return mGpuMem->kGpuMemTotalProgPath; } 40 getGpuMemTotalMapPath()41 std::string getGpuMemTotalMapPath() { return mGpuMem->kGpuMemTotalMapPath; } 42 43 private: 44 GpuMem *mGpuMem; 45 }; 46 47 } // namespace android 48