Yiwei Zhang | fdd7e78 | 2020-01-31 15:59:34 -0800 | [diff] [blame] | 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 | #undef LOG_TAG |
| 18 | #define LOG_TAG "gpuservice_unittest" |
| 19 | |
Tim Van Patten | a9ad69b | 2021-11-24 19:29:38 -0700 | [diff] [blame] | 20 | #include <unistd.h> |
Vova Sharaienko | 0906b2c | 2022-05-23 21:05:08 +0000 | [diff] [blame^] | 21 | #include <binder/ProcessState.h> |
Yiwei Zhang | fdd7e78 | 2020-01-31 15:59:34 -0800 | [diff] [blame] | 22 | #include <cutils/properties.h> |
| 23 | #include <gmock/gmock.h> |
| 24 | #include <gpustats/GpuStats.h> |
| 25 | #include <gtest/gtest.h> |
Yiwei Zhang | b59a127 | 2020-02-04 14:58:01 -0800 | [diff] [blame] | 26 | #include <stats_pull_atom_callback.h> |
| 27 | #include <statslog.h> |
Yiwei Zhang | fdd7e78 | 2020-01-31 15:59:34 -0800 | [diff] [blame] | 28 | #include <utils/String16.h> |
| 29 | #include <utils/Vector.h> |
| 30 | |
Yiwei Zhang | b59a127 | 2020-02-04 14:58:01 -0800 | [diff] [blame] | 31 | #include "TestableGpuStats.h" |
| 32 | |
Yiwei Zhang | fdd7e78 | 2020-01-31 15:59:34 -0800 | [diff] [blame] | 33 | namespace android { |
| 34 | namespace { |
| 35 | |
| 36 | using testing::HasSubstr; |
| 37 | |
| 38 | // clang-format off |
| 39 | #define BUILTIN_DRIVER_PKG_NAME "system" |
| 40 | #define BUILTIN_DRIVER_VER_NAME "0" |
| 41 | #define BUILTIN_DRIVER_VER_CODE 0 |
| 42 | #define BUILTIN_DRIVER_BUILD_TIME 123 |
| 43 | #define UPDATED_DRIVER_PKG_NAME "updated" |
| 44 | #define UPDATED_DRIVER_VER_NAME "1" |
| 45 | #define UPDATED_DRIVER_VER_CODE 1 |
| 46 | #define UPDATED_DRIVER_BUILD_TIME 234 |
| 47 | #define VULKAN_VERSION 345 |
Yiwei Zhang | fdd7e78 | 2020-01-31 15:59:34 -0800 | [diff] [blame] | 48 | #define APP_PKG_NAME_1 "testapp1" |
| 49 | #define APP_PKG_NAME_2 "testapp2" |
| 50 | #define DRIVER_LOADING_TIME_1 678 |
| 51 | #define DRIVER_LOADING_TIME_2 789 |
| 52 | #define DRIVER_LOADING_TIME_3 891 |
| 53 | |
| 54 | enum InputCommand : int32_t { |
| 55 | DUMP_ALL = 0, |
| 56 | DUMP_GLOBAL = 1, |
| 57 | DUMP_APP = 2, |
| 58 | DUMP_ALL_THEN_CLEAR = 3, |
| 59 | DUMP_GLOBAL_THEN_CLEAR = 4, |
| 60 | DUMP_APP_THEN_CLEAR = 5, |
| 61 | }; |
| 62 | // clang-format on |
| 63 | |
| 64 | class GpuStatsTest : public testing::Test { |
| 65 | public: |
| 66 | GpuStatsTest() { |
| 67 | const ::testing::TestInfo* const test_info = |
| 68 | ::testing::UnitTest::GetInstance()->current_test_info(); |
| 69 | ALOGD("**** Setting up for %s.%s\n", test_info->test_case_name(), test_info->name()); |
| 70 | } |
| 71 | |
| 72 | ~GpuStatsTest() { |
| 73 | const ::testing::TestInfo* const test_info = |
| 74 | ::testing::UnitTest::GetInstance()->current_test_info(); |
| 75 | ALOGD("**** Tearing down after %s.%s\n", test_info->test_case_name(), test_info->name()); |
| 76 | } |
| 77 | |
| 78 | std::string inputCommand(InputCommand cmd); |
| 79 | |
| 80 | void SetUp() override { |
Yiwei Zhang | cf67368 | 2020-02-04 19:22:51 -0800 | [diff] [blame] | 81 | mCpuVulkanVersion = property_get_int32("ro.cpuvulkan.version", 0); |
| 82 | mGlesVersion = property_get_int32("ro.opengles.version", 0); |
Vova Sharaienko | 0906b2c | 2022-05-23 21:05:08 +0000 | [diff] [blame^] | 83 | |
| 84 | // start the thread pool |
| 85 | sp<ProcessState> ps(ProcessState::self()); |
| 86 | ps->startThreadPool(); |
Yiwei Zhang | fdd7e78 | 2020-01-31 15:59:34 -0800 | [diff] [blame] | 87 | } |
| 88 | |
| 89 | std::unique_ptr<GpuStats> mGpuStats = std::make_unique<GpuStats>(); |
| 90 | int32_t mCpuVulkanVersion = 0; |
| 91 | int32_t mGlesVersion = 0; |
| 92 | }; |
| 93 | |
| 94 | std::string GpuStatsTest::inputCommand(InputCommand cmd) { |
| 95 | std::string result; |
| 96 | Vector<String16> args; |
| 97 | |
| 98 | switch (cmd) { |
| 99 | case InputCommand::DUMP_ALL: |
| 100 | break; |
| 101 | case InputCommand::DUMP_GLOBAL: |
| 102 | args.push_back(String16("--global")); |
| 103 | break; |
| 104 | case InputCommand::DUMP_APP: |
| 105 | args.push_back(String16("--app")); |
| 106 | break; |
| 107 | case InputCommand::DUMP_ALL_THEN_CLEAR: |
| 108 | args.push_back(String16("--clear")); |
| 109 | break; |
| 110 | case InputCommand::DUMP_GLOBAL_THEN_CLEAR: |
| 111 | args.push_back(String16("--global")); |
| 112 | args.push_back(String16("--clear")); |
| 113 | break; |
| 114 | case InputCommand::DUMP_APP_THEN_CLEAR: |
| 115 | args.push_back(String16("--app")); |
| 116 | args.push_back(String16("--clear")); |
| 117 | break; |
| 118 | } |
| 119 | |
| 120 | mGpuStats->dump(args, &result); |
| 121 | return result; |
| 122 | } |
| 123 | |
| 124 | TEST_F(GpuStatsTest, statsEmptyByDefault) { |
| 125 | ASSERT_TRUE(inputCommand(InputCommand::DUMP_ALL).empty()); |
| 126 | } |
| 127 | |
| 128 | TEST_F(GpuStatsTest, canInsertBuiltinDriverStats) { |
| 129 | mGpuStats->insertDriverStats(BUILTIN_DRIVER_PKG_NAME, BUILTIN_DRIVER_VER_NAME, |
| 130 | BUILTIN_DRIVER_VER_CODE, BUILTIN_DRIVER_BUILD_TIME, APP_PKG_NAME_1, |
| 131 | VULKAN_VERSION, GpuStatsInfo::Driver::GL, true, |
| 132 | DRIVER_LOADING_TIME_1); |
| 133 | |
| 134 | std::string expectedResult = "driverPackageName = " + std::string(BUILTIN_DRIVER_PKG_NAME); |
| 135 | EXPECT_THAT(inputCommand(InputCommand::DUMP_GLOBAL), HasSubstr(expectedResult)); |
| 136 | expectedResult = "driverVersionName = " + std::string(BUILTIN_DRIVER_VER_NAME); |
| 137 | EXPECT_THAT(inputCommand(InputCommand::DUMP_GLOBAL), HasSubstr(expectedResult)); |
| 138 | expectedResult = "driverVersionCode = " + std::to_string(BUILTIN_DRIVER_VER_CODE); |
| 139 | EXPECT_THAT(inputCommand(InputCommand::DUMP_GLOBAL), HasSubstr(expectedResult)); |
| 140 | expectedResult = "driverBuildTime = " + std::to_string(BUILTIN_DRIVER_BUILD_TIME); |
| 141 | EXPECT_THAT(inputCommand(InputCommand::DUMP_GLOBAL), HasSubstr(expectedResult)); |
| 142 | EXPECT_THAT(inputCommand(InputCommand::DUMP_GLOBAL), HasSubstr("glLoadingCount = 1")); |
| 143 | EXPECT_THAT(inputCommand(InputCommand::DUMP_GLOBAL), HasSubstr("glLoadingFailureCount = 0")); |
| 144 | expectedResult = "appPackageName = " + std::string(APP_PKG_NAME_1); |
| 145 | EXPECT_THAT(inputCommand(InputCommand::DUMP_APP), HasSubstr(expectedResult)); |
| 146 | expectedResult = "driverVersionCode = " + std::to_string(BUILTIN_DRIVER_VER_CODE); |
| 147 | EXPECT_THAT(inputCommand(InputCommand::DUMP_APP), HasSubstr(expectedResult)); |
| 148 | expectedResult = "glDriverLoadingTime: " + std::to_string(DRIVER_LOADING_TIME_1); |
| 149 | EXPECT_THAT(inputCommand(InputCommand::DUMP_APP), HasSubstr(expectedResult)); |
| 150 | } |
| 151 | |
| 152 | TEST_F(GpuStatsTest, canInsertUpdatedDriverStats) { |
| 153 | mGpuStats->insertDriverStats(UPDATED_DRIVER_PKG_NAME, UPDATED_DRIVER_VER_NAME, |
| 154 | UPDATED_DRIVER_VER_CODE, UPDATED_DRIVER_BUILD_TIME, APP_PKG_NAME_2, |
| 155 | VULKAN_VERSION, GpuStatsInfo::Driver::VULKAN_UPDATED, false, |
| 156 | DRIVER_LOADING_TIME_2); |
| 157 | |
| 158 | std::string expectedResult = "driverPackageName = " + std::string(UPDATED_DRIVER_PKG_NAME); |
| 159 | EXPECT_THAT(inputCommand(InputCommand::DUMP_GLOBAL), HasSubstr(expectedResult)); |
| 160 | expectedResult = "driverVersionName = " + std::string(UPDATED_DRIVER_VER_NAME); |
| 161 | EXPECT_THAT(inputCommand(InputCommand::DUMP_GLOBAL), HasSubstr(expectedResult)); |
| 162 | expectedResult = "driverVersionCode = " + std::to_string(UPDATED_DRIVER_VER_CODE); |
| 163 | EXPECT_THAT(inputCommand(InputCommand::DUMP_GLOBAL), HasSubstr(expectedResult)); |
| 164 | expectedResult = "driverBuildTime = " + std::to_string(UPDATED_DRIVER_BUILD_TIME); |
| 165 | EXPECT_THAT(inputCommand(InputCommand::DUMP_GLOBAL), HasSubstr(expectedResult)); |
| 166 | EXPECT_THAT(inputCommand(InputCommand::DUMP_GLOBAL), HasSubstr("vkLoadingCount = 1")); |
| 167 | EXPECT_THAT(inputCommand(InputCommand::DUMP_GLOBAL), HasSubstr("vkLoadingFailureCount = 1")); |
| 168 | expectedResult = "appPackageName = " + std::string(APP_PKG_NAME_2); |
| 169 | EXPECT_THAT(inputCommand(InputCommand::DUMP_APP), HasSubstr(expectedResult)); |
| 170 | expectedResult = "driverVersionCode = " + std::to_string(UPDATED_DRIVER_VER_CODE); |
| 171 | EXPECT_THAT(inputCommand(InputCommand::DUMP_APP), HasSubstr(expectedResult)); |
| 172 | expectedResult = "vkDriverLoadingTime: " + std::to_string(DRIVER_LOADING_TIME_2); |
| 173 | EXPECT_THAT(inputCommand(InputCommand::DUMP_APP), HasSubstr(expectedResult)); |
| 174 | } |
| 175 | |
| 176 | TEST_F(GpuStatsTest, canInsertAngleDriverStats) { |
| 177 | mGpuStats->insertDriverStats(UPDATED_DRIVER_PKG_NAME, UPDATED_DRIVER_VER_NAME, |
| 178 | UPDATED_DRIVER_VER_CODE, UPDATED_DRIVER_BUILD_TIME, APP_PKG_NAME_2, |
| 179 | VULKAN_VERSION, GpuStatsInfo::Driver::ANGLE, true, |
| 180 | DRIVER_LOADING_TIME_3); |
| 181 | |
| 182 | EXPECT_THAT(inputCommand(InputCommand::DUMP_GLOBAL), HasSubstr("angleLoadingCount = 1")); |
| 183 | EXPECT_THAT(inputCommand(InputCommand::DUMP_GLOBAL), HasSubstr("angleLoadingFailureCount = 0")); |
| 184 | std::string expectedResult = "angleDriverLoadingTime: " + std::to_string(DRIVER_LOADING_TIME_3); |
| 185 | EXPECT_THAT(inputCommand(InputCommand::DUMP_APP), HasSubstr(expectedResult)); |
| 186 | } |
| 187 | |
| 188 | TEST_F(GpuStatsTest, canDump3dApiVersion) { |
| 189 | mGpuStats->insertDriverStats(BUILTIN_DRIVER_PKG_NAME, BUILTIN_DRIVER_VER_NAME, |
| 190 | BUILTIN_DRIVER_VER_CODE, BUILTIN_DRIVER_BUILD_TIME, APP_PKG_NAME_1, |
| 191 | VULKAN_VERSION, GpuStatsInfo::Driver::GL, true, |
| 192 | DRIVER_LOADING_TIME_1); |
| 193 | |
| 194 | std::string expectedResult = "vulkanVersion = " + std::to_string(VULKAN_VERSION); |
| 195 | EXPECT_THAT(inputCommand(InputCommand::DUMP_GLOBAL), HasSubstr(expectedResult)); |
| 196 | expectedResult = "cpuVulkanVersion = " + std::to_string(mCpuVulkanVersion); |
| 197 | EXPECT_THAT(inputCommand(InputCommand::DUMP_GLOBAL), HasSubstr(expectedResult)); |
| 198 | expectedResult = "glesVersion = " + std::to_string(mGlesVersion); |
| 199 | EXPECT_THAT(inputCommand(InputCommand::DUMP_GLOBAL), HasSubstr(expectedResult)); |
| 200 | } |
| 201 | |
| 202 | TEST_F(GpuStatsTest, canNotInsertTargetStatsBeforeProperSetup) { |
| 203 | mGpuStats->insertTargetStats(APP_PKG_NAME_1, BUILTIN_DRIVER_VER_CODE, |
| 204 | GpuStatsInfo::Stats::CPU_VULKAN_IN_USE, 0); |
| 205 | mGpuStats->insertTargetStats(APP_PKG_NAME_1, BUILTIN_DRIVER_VER_CODE, |
| 206 | GpuStatsInfo::Stats::FALSE_PREROTATION, 0); |
| 207 | mGpuStats->insertTargetStats(APP_PKG_NAME_1, BUILTIN_DRIVER_VER_CODE, |
| 208 | GpuStatsInfo::Stats::GLES_1_IN_USE, 0); |
| 209 | |
| 210 | EXPECT_TRUE(inputCommand(InputCommand::DUMP_APP).empty()); |
| 211 | } |
| 212 | |
| 213 | TEST_F(GpuStatsTest, canInsertTargetStatsAfterProperSetup) { |
| 214 | mGpuStats->insertDriverStats(BUILTIN_DRIVER_PKG_NAME, BUILTIN_DRIVER_VER_NAME, |
| 215 | BUILTIN_DRIVER_VER_CODE, BUILTIN_DRIVER_BUILD_TIME, APP_PKG_NAME_1, |
| 216 | VULKAN_VERSION, GpuStatsInfo::Driver::GL, true, |
| 217 | DRIVER_LOADING_TIME_1); |
| 218 | mGpuStats->insertTargetStats(APP_PKG_NAME_1, BUILTIN_DRIVER_VER_CODE, |
| 219 | GpuStatsInfo::Stats::CPU_VULKAN_IN_USE, 0); |
| 220 | mGpuStats->insertTargetStats(APP_PKG_NAME_1, BUILTIN_DRIVER_VER_CODE, |
| 221 | GpuStatsInfo::Stats::FALSE_PREROTATION, 0); |
| 222 | mGpuStats->insertTargetStats(APP_PKG_NAME_1, BUILTIN_DRIVER_VER_CODE, |
| 223 | GpuStatsInfo::Stats::GLES_1_IN_USE, 0); |
| 224 | |
| 225 | EXPECT_THAT(inputCommand(InputCommand::DUMP_APP), HasSubstr("cpuVulkanInUse = 1")); |
| 226 | EXPECT_THAT(inputCommand(InputCommand::DUMP_APP), HasSubstr("falsePrerotation = 1")); |
| 227 | EXPECT_THAT(inputCommand(InputCommand::DUMP_APP), HasSubstr("gles1InUse = 1")); |
| 228 | } |
| 229 | |
Tim Van Patten | a9ad69b | 2021-11-24 19:29:38 -0700 | [diff] [blame] | 230 | // Verify we always have the most recently used apps in mAppStats, even when we fill it. |
| 231 | TEST_F(GpuStatsTest, canInsertMoreThanMaxNumAppRecords) { |
| 232 | constexpr int kNumExtraApps = 15; |
| 233 | static_assert(kNumExtraApps > GpuStats::APP_RECORD_HEADROOM); |
| 234 | |
| 235 | // Insert stats for GpuStats::MAX_NUM_APP_RECORDS so we fill it up. |
| 236 | for (int i = 0; i < GpuStats::MAX_NUM_APP_RECORDS + kNumExtraApps; ++i) { |
| 237 | std::stringstream nameStream; |
| 238 | nameStream << "testapp" << "_" << i; |
| 239 | std::string fullPkgName = nameStream.str(); |
| 240 | |
| 241 | mGpuStats->insertDriverStats(BUILTIN_DRIVER_PKG_NAME, BUILTIN_DRIVER_VER_NAME, |
| 242 | BUILTIN_DRIVER_VER_CODE, BUILTIN_DRIVER_BUILD_TIME, |
| 243 | fullPkgName, VULKAN_VERSION, GpuStatsInfo::Driver::GL, true, |
| 244 | DRIVER_LOADING_TIME_1); |
| 245 | mGpuStats->insertTargetStats(fullPkgName, BUILTIN_DRIVER_VER_CODE, |
| 246 | GpuStatsInfo::Stats::CPU_VULKAN_IN_USE, 0); |
| 247 | mGpuStats->insertTargetStats(fullPkgName, BUILTIN_DRIVER_VER_CODE, |
| 248 | GpuStatsInfo::Stats::FALSE_PREROTATION, 0); |
| 249 | mGpuStats->insertTargetStats(fullPkgName, BUILTIN_DRIVER_VER_CODE, |
| 250 | GpuStatsInfo::Stats::GLES_1_IN_USE, 0); |
| 251 | |
| 252 | EXPECT_THAT(inputCommand(InputCommand::DUMP_APP), HasSubstr(fullPkgName.c_str())); |
| 253 | EXPECT_THAT(inputCommand(InputCommand::DUMP_APP), HasSubstr("cpuVulkanInUse = 1")); |
| 254 | EXPECT_THAT(inputCommand(InputCommand::DUMP_APP), HasSubstr("falsePrerotation = 1")); |
| 255 | EXPECT_THAT(inputCommand(InputCommand::DUMP_APP), HasSubstr("gles1InUse = 1")); |
| 256 | } |
| 257 | |
| 258 | // mAppStats purges GpuStats::APP_RECORD_HEADROOM apps removed everytime it's filled up. |
| 259 | int numPurges = kNumExtraApps / GpuStats::APP_RECORD_HEADROOM; |
| 260 | numPurges += (kNumExtraApps % GpuStats::APP_RECORD_HEADROOM) == 0 ? 0 : 1; |
| 261 | |
| 262 | // Verify the remaining apps are present. |
| 263 | for (int i = numPurges * GpuStats::APP_RECORD_HEADROOM; |
| 264 | i < GpuStats::MAX_NUM_APP_RECORDS + kNumExtraApps; |
| 265 | ++i) { |
| 266 | std::stringstream nameStream; |
| 267 | // Add a newline to search for the exact package name. |
| 268 | nameStream << "testapp" << "_" << i << "\n"; |
| 269 | std::string fullPkgName = nameStream.str(); |
| 270 | |
| 271 | EXPECT_THAT(inputCommand(InputCommand::DUMP_APP), HasSubstr(fullPkgName.c_str())); |
| 272 | } |
| 273 | } |
| 274 | |
Yiwei Zhang | fdd7e78 | 2020-01-31 15:59:34 -0800 | [diff] [blame] | 275 | TEST_F(GpuStatsTest, canDumpAllBeforeClearAll) { |
| 276 | mGpuStats->insertDriverStats(BUILTIN_DRIVER_PKG_NAME, BUILTIN_DRIVER_VER_NAME, |
| 277 | BUILTIN_DRIVER_VER_CODE, BUILTIN_DRIVER_BUILD_TIME, APP_PKG_NAME_1, |
| 278 | VULKAN_VERSION, GpuStatsInfo::Driver::GL, true, |
| 279 | DRIVER_LOADING_TIME_1); |
| 280 | |
| 281 | EXPECT_FALSE(inputCommand(InputCommand::DUMP_ALL_THEN_CLEAR).empty()); |
| 282 | EXPECT_TRUE(inputCommand(InputCommand::DUMP_ALL).empty()); |
| 283 | } |
| 284 | |
| 285 | TEST_F(GpuStatsTest, canDumpGlobalBeforeClearGlobal) { |
| 286 | mGpuStats->insertDriverStats(BUILTIN_DRIVER_PKG_NAME, BUILTIN_DRIVER_VER_NAME, |
| 287 | BUILTIN_DRIVER_VER_CODE, BUILTIN_DRIVER_BUILD_TIME, APP_PKG_NAME_1, |
| 288 | VULKAN_VERSION, GpuStatsInfo::Driver::GL, true, |
| 289 | DRIVER_LOADING_TIME_1); |
| 290 | |
| 291 | EXPECT_FALSE(inputCommand(InputCommand::DUMP_GLOBAL_THEN_CLEAR).empty()); |
| 292 | EXPECT_TRUE(inputCommand(InputCommand::DUMP_GLOBAL).empty()); |
| 293 | EXPECT_FALSE(inputCommand(InputCommand::DUMP_APP).empty()); |
| 294 | } |
| 295 | |
| 296 | TEST_F(GpuStatsTest, canDumpAppBeforeClearApp) { |
| 297 | mGpuStats->insertDriverStats(BUILTIN_DRIVER_PKG_NAME, BUILTIN_DRIVER_VER_NAME, |
| 298 | BUILTIN_DRIVER_VER_CODE, BUILTIN_DRIVER_BUILD_TIME, APP_PKG_NAME_1, |
| 299 | VULKAN_VERSION, GpuStatsInfo::Driver::GL, true, |
| 300 | DRIVER_LOADING_TIME_1); |
| 301 | |
| 302 | EXPECT_FALSE(inputCommand(InputCommand::DUMP_APP_THEN_CLEAR).empty()); |
| 303 | EXPECT_TRUE(inputCommand(InputCommand::DUMP_APP).empty()); |
| 304 | EXPECT_FALSE(inputCommand(InputCommand::DUMP_GLOBAL).empty()); |
| 305 | } |
| 306 | |
Yiwei Zhang | b59a127 | 2020-02-04 14:58:01 -0800 | [diff] [blame] | 307 | TEST_F(GpuStatsTest, skipPullInvalidAtom) { |
| 308 | TestableGpuStats testableGpuStats(mGpuStats.get()); |
| 309 | mGpuStats->insertDriverStats(BUILTIN_DRIVER_PKG_NAME, BUILTIN_DRIVER_VER_NAME, |
| 310 | BUILTIN_DRIVER_VER_CODE, BUILTIN_DRIVER_BUILD_TIME, APP_PKG_NAME_1, |
| 311 | VULKAN_VERSION, GpuStatsInfo::Driver::GL, true, |
| 312 | DRIVER_LOADING_TIME_1); |
| 313 | |
| 314 | EXPECT_FALSE(inputCommand(InputCommand::DUMP_GLOBAL).empty()); |
| 315 | EXPECT_FALSE(inputCommand(InputCommand::DUMP_APP).empty()); |
| 316 | |
| 317 | EXPECT_TRUE(testableGpuStats.makePullAtomCallback(-1) == AStatsManager_PULL_SKIP); |
| 318 | |
| 319 | EXPECT_FALSE(inputCommand(InputCommand::DUMP_GLOBAL).empty()); |
| 320 | EXPECT_FALSE(inputCommand(InputCommand::DUMP_APP).empty()); |
| 321 | } |
| 322 | |
| 323 | TEST_F(GpuStatsTest, canPullGlobalAtom) { |
| 324 | TestableGpuStats testableGpuStats(mGpuStats.get()); |
| 325 | mGpuStats->insertDriverStats(BUILTIN_DRIVER_PKG_NAME, BUILTIN_DRIVER_VER_NAME, |
| 326 | BUILTIN_DRIVER_VER_CODE, BUILTIN_DRIVER_BUILD_TIME, APP_PKG_NAME_1, |
| 327 | VULKAN_VERSION, GpuStatsInfo::Driver::GL, true, |
| 328 | DRIVER_LOADING_TIME_1); |
| 329 | |
| 330 | EXPECT_FALSE(inputCommand(InputCommand::DUMP_GLOBAL).empty()); |
| 331 | EXPECT_FALSE(inputCommand(InputCommand::DUMP_APP).empty()); |
| 332 | |
| 333 | EXPECT_TRUE(testableGpuStats.makePullAtomCallback(android::util::GPU_STATS_GLOBAL_INFO) == |
| 334 | AStatsManager_PULL_SUCCESS); |
| 335 | |
| 336 | EXPECT_TRUE(inputCommand(InputCommand::DUMP_GLOBAL).empty()); |
| 337 | EXPECT_FALSE(inputCommand(InputCommand::DUMP_APP).empty()); |
| 338 | } |
| 339 | |
Yiwei Zhang | 29f8593 | 2020-02-04 17:14:54 -0800 | [diff] [blame] | 340 | TEST_F(GpuStatsTest, canPullAppAtom) { |
| 341 | TestableGpuStats testableGpuStats(mGpuStats.get()); |
| 342 | mGpuStats->insertDriverStats(BUILTIN_DRIVER_PKG_NAME, BUILTIN_DRIVER_VER_NAME, |
| 343 | BUILTIN_DRIVER_VER_CODE, BUILTIN_DRIVER_BUILD_TIME, APP_PKG_NAME_1, |
| 344 | VULKAN_VERSION, GpuStatsInfo::Driver::GL, true, |
| 345 | DRIVER_LOADING_TIME_1); |
| 346 | |
| 347 | EXPECT_FALSE(inputCommand(InputCommand::DUMP_GLOBAL).empty()); |
| 348 | EXPECT_FALSE(inputCommand(InputCommand::DUMP_APP).empty()); |
| 349 | |
| 350 | EXPECT_TRUE(testableGpuStats.makePullAtomCallback(android::util::GPU_STATS_APP_INFO) == |
| 351 | AStatsManager_PULL_SUCCESS); |
| 352 | |
| 353 | EXPECT_FALSE(inputCommand(InputCommand::DUMP_GLOBAL).empty()); |
| 354 | EXPECT_TRUE(inputCommand(InputCommand::DUMP_APP).empty()); |
| 355 | } |
| 356 | |
Yiwei Zhang | fdd7e78 | 2020-01-31 15:59:34 -0800 | [diff] [blame] | 357 | } // namespace |
| 358 | } // namespace android |