Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 1 | /* |
Ronghua Wu | 67e7f54 | 2015-03-13 10:47:08 -0700 | [diff] [blame] | 2 | * Copyright 2015 The Android Open Source Project |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 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 | //#define LOG_NDEBUG 0 |
| 18 | #define LOG_TAG "ResourceManagerService_test" |
| 19 | #include <utils/Log.h> |
| 20 | |
| 21 | #include <gtest/gtest.h> |
| 22 | |
| 23 | #include "ResourceManagerService.h" |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 24 | #include <android/media/BnResourceManagerClient.h> |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 25 | #include <media/MediaResource.h> |
| 26 | #include <media/MediaResourcePolicy.h> |
| 27 | #include <media/stagefright/foundation/ADebug.h> |
| 28 | #include <media/stagefright/ProcessInfoInterface.h> |
| 29 | |
| 30 | namespace android { |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 31 | namespace media { |
| 32 | |
| 33 | using ::android::binder::Status; |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 34 | |
Chih-Hung Hsieh | 51873d8 | 2016-08-09 14:18:51 -0700 | [diff] [blame] | 35 | static int64_t getId(const sp<IResourceManagerClient>& client) { |
Ronghua Wu | 37c8924 | 2015-07-15 12:23:48 -0700 | [diff] [blame] | 36 | return (int64_t) client.get(); |
| 37 | } |
| 38 | |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 39 | struct TestProcessInfo : public ProcessInfoInterface { |
| 40 | TestProcessInfo() {} |
| 41 | virtual ~TestProcessInfo() {} |
| 42 | |
| 43 | virtual bool getPriority(int pid, int *priority) { |
| 44 | // For testing, use pid as priority. |
| 45 | // Lower the value higher the priority. |
| 46 | *priority = pid; |
| 47 | return true; |
| 48 | } |
| 49 | |
Ronghua Wu | d11c43a | 2016-01-27 16:26:12 -0800 | [diff] [blame] | 50 | virtual bool isValidPid(int /* pid */) { |
| 51 | return true; |
| 52 | } |
| 53 | |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 54 | private: |
| 55 | DISALLOW_EVIL_CONSTRUCTORS(TestProcessInfo); |
| 56 | }; |
| 57 | |
Chong Zhang | dd72680 | 2019-08-21 17:24:13 -0700 | [diff] [blame] | 58 | struct TestSystemCallback : |
| 59 | public ResourceManagerService::SystemCallbackInterface { |
| 60 | TestSystemCallback() : |
| 61 | mLastEvent({EventType::INVALID, 0}), mEventCount(0) {} |
| 62 | |
| 63 | enum EventType { |
| 64 | INVALID = -1, |
| 65 | VIDEO_ON = 0, |
| 66 | VIDEO_OFF = 1, |
| 67 | VIDEO_RESET = 2, |
| 68 | CPUSET_ENABLE = 3, |
| 69 | CPUSET_DISABLE = 4, |
| 70 | }; |
| 71 | |
| 72 | struct EventEntry { |
| 73 | EventType type; |
| 74 | int arg; |
| 75 | }; |
| 76 | |
| 77 | virtual void noteStartVideo(int uid) override { |
| 78 | mLastEvent = {EventType::VIDEO_ON, uid}; |
| 79 | mEventCount++; |
| 80 | } |
| 81 | |
| 82 | virtual void noteStopVideo(int uid) override { |
| 83 | mLastEvent = {EventType::VIDEO_OFF, uid}; |
| 84 | mEventCount++; |
| 85 | } |
| 86 | |
| 87 | virtual void noteResetVideo() override { |
| 88 | mLastEvent = {EventType::VIDEO_RESET, 0}; |
| 89 | mEventCount++; |
| 90 | } |
| 91 | |
| 92 | virtual bool requestCpusetBoost( |
| 93 | bool enable, const sp<IInterface> &/*client*/) override { |
| 94 | mLastEvent = {enable ? EventType::CPUSET_ENABLE : EventType::CPUSET_DISABLE, 0}; |
| 95 | mEventCount++; |
| 96 | return true; |
| 97 | } |
| 98 | |
| 99 | size_t eventCount() { return mEventCount; } |
| 100 | EventType lastEventType() { return mLastEvent.type; } |
| 101 | EventEntry lastEvent() { return mLastEvent; } |
| 102 | |
| 103 | protected: |
| 104 | virtual ~TestSystemCallback() {} |
| 105 | |
| 106 | private: |
| 107 | EventEntry mLastEvent; |
| 108 | size_t mEventCount; |
| 109 | |
| 110 | DISALLOW_EVIL_CONSTRUCTORS(TestSystemCallback); |
| 111 | }; |
| 112 | |
| 113 | |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 114 | struct TestClient : public BnResourceManagerClient { |
Ronghua Wu | 37c8924 | 2015-07-15 12:23:48 -0700 | [diff] [blame] | 115 | TestClient(int pid, sp<ResourceManagerService> service) |
| 116 | : mReclaimed(false), mPid(pid), mService(service) {} |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 117 | |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 118 | Status reclaimResource(bool* _aidl_return) override { |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 119 | sp<IResourceManagerClient> client(this); |
Chong Zhang | fb092d3 | 2019-08-12 09:45:44 -0700 | [diff] [blame] | 120 | mService->removeClient(mPid, (int64_t) client.get()); |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 121 | mReclaimed = true; |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 122 | *_aidl_return = true; |
| 123 | return Status::ok(); |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 124 | } |
| 125 | |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 126 | Status getName(::std::string* _aidl_return) override { |
| 127 | *_aidl_return = "test_client"; |
| 128 | return Status::ok(); |
Ronghua Wu | 8f9dd87 | 2015-04-23 15:24:25 -0700 | [diff] [blame] | 129 | } |
| 130 | |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 131 | bool reclaimed() const { |
| 132 | return mReclaimed; |
| 133 | } |
| 134 | |
| 135 | void reset() { |
| 136 | mReclaimed = false; |
| 137 | } |
| 138 | |
| 139 | protected: |
| 140 | virtual ~TestClient() {} |
| 141 | |
| 142 | private: |
| 143 | bool mReclaimed; |
Ronghua Wu | 37c8924 | 2015-07-15 12:23:48 -0700 | [diff] [blame] | 144 | int mPid; |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 145 | sp<ResourceManagerService> mService; |
| 146 | DISALLOW_EVIL_CONSTRUCTORS(TestClient); |
| 147 | }; |
| 148 | |
| 149 | static const int kTestPid1 = 30; |
Chong Zhang | ee33d64 | 2019-08-08 14:26:43 -0700 | [diff] [blame] | 150 | static const int kTestUid1 = 1010; |
| 151 | |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 152 | static const int kTestPid2 = 20; |
Chong Zhang | ee33d64 | 2019-08-08 14:26:43 -0700 | [diff] [blame] | 153 | static const int kTestUid2 = 1011; |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 154 | |
Ronghua Wu | 05d89f1 | 2015-07-07 16:47:42 -0700 | [diff] [blame] | 155 | static const int kLowPriorityPid = 40; |
| 156 | static const int kMidPriorityPid = 25; |
| 157 | static const int kHighPriorityPid = 10; |
| 158 | |
Chong Zhang | dd72680 | 2019-08-21 17:24:13 -0700 | [diff] [blame] | 159 | using EventType = TestSystemCallback::EventType; |
| 160 | using EventEntry = TestSystemCallback::EventEntry; |
| 161 | bool operator== (const EventEntry& lhs, const EventEntry& rhs) { |
| 162 | return lhs.type == rhs.type && lhs.arg == rhs.arg; |
| 163 | } |
| 164 | |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 165 | #define CHECK_STATUS_TRUE(condition) \ |
| 166 | EXPECT_TRUE((condition).isOk() && (result)) |
| 167 | |
| 168 | #define CHECK_STATUS_FALSE(condition) \ |
| 169 | EXPECT_TRUE((condition).isOk() && !(result)) |
| 170 | |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 171 | class ResourceManagerServiceTest : public ::testing::Test { |
| 172 | public: |
| 173 | ResourceManagerServiceTest() |
Chong Zhang | dd72680 | 2019-08-21 17:24:13 -0700 | [diff] [blame] | 174 | : mSystemCB(new TestSystemCallback()), |
| 175 | mService(new ResourceManagerService(new TestProcessInfo, mSystemCB)), |
Ronghua Wu | 37c8924 | 2015-07-15 12:23:48 -0700 | [diff] [blame] | 176 | mTestClient1(new TestClient(kTestPid1, mService)), |
| 177 | mTestClient2(new TestClient(kTestPid2, mService)), |
| 178 | mTestClient3(new TestClient(kTestPid2, mService)) { |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 179 | } |
| 180 | |
| 181 | protected: |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 182 | static bool isEqualResources(const std::vector<MediaResourceParcel> &resources1, |
Chong Zhang | fb092d3 | 2019-08-12 09:45:44 -0700 | [diff] [blame] | 183 | const ResourceList &resources2) { |
| 184 | // convert resource1 to ResourceList |
| 185 | ResourceList r1; |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 186 | for (size_t i = 0; i < resources1.size(); ++i) { |
Robert Shih | c3af31b | 2019-09-20 21:45:01 -0700 | [diff] [blame] | 187 | const auto &res = resources1[i]; |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 188 | const auto resType = std::tuple(res.type, res.subType, res.id); |
Robert Shih | c3af31b | 2019-09-20 21:45:01 -0700 | [diff] [blame] | 189 | r1[resType] = res; |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 190 | } |
Chong Zhang | fb092d3 | 2019-08-12 09:45:44 -0700 | [diff] [blame] | 191 | return r1 == resources2; |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 192 | } |
| 193 | |
Chong Zhang | ee33d64 | 2019-08-08 14:26:43 -0700 | [diff] [blame] | 194 | static void expectEqResourceInfo(const ResourceInfo &info, |
| 195 | int uid, |
| 196 | sp<IResourceManagerClient> client, |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 197 | const std::vector<MediaResourceParcel> &resources) { |
Chong Zhang | ee33d64 | 2019-08-08 14:26:43 -0700 | [diff] [blame] | 198 | EXPECT_EQ(uid, info.uid); |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 199 | EXPECT_EQ(client, info.client); |
| 200 | EXPECT_TRUE(isEqualResources(resources, info.resources)); |
| 201 | } |
| 202 | |
| 203 | void verifyClients(bool c1, bool c2, bool c3) { |
| 204 | TestClient *client1 = static_cast<TestClient*>(mTestClient1.get()); |
| 205 | TestClient *client2 = static_cast<TestClient*>(mTestClient2.get()); |
| 206 | TestClient *client3 = static_cast<TestClient*>(mTestClient3.get()); |
| 207 | |
| 208 | EXPECT_EQ(c1, client1->reclaimed()); |
| 209 | EXPECT_EQ(c2, client2->reclaimed()); |
| 210 | EXPECT_EQ(c3, client3->reclaimed()); |
| 211 | |
| 212 | client1->reset(); |
| 213 | client2->reset(); |
| 214 | client3->reset(); |
| 215 | } |
| 216 | |
Ronghua Wu | 67e7f54 | 2015-03-13 10:47:08 -0700 | [diff] [blame] | 217 | // test set up |
| 218 | // --------------------------------------------------------------------------------- |
| 219 | // pid priority client type number |
| 220 | // --------------------------------------------------------------------------------- |
| 221 | // kTestPid1(30) 30 mTestClient1 secure codec 1 |
| 222 | // graphic memory 200 |
| 223 | // graphic memory 200 |
| 224 | // --------------------------------------------------------------------------------- |
| 225 | // kTestPid2(20) 20 mTestClient2 non-secure codec 1 |
| 226 | // graphic memory 300 |
| 227 | // ------------------------------------------- |
| 228 | // mTestClient3 secure codec 1 |
| 229 | // graphic memory 100 |
| 230 | // --------------------------------------------------------------------------------- |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 231 | void addResource() { |
| 232 | // kTestPid1 mTestClient1 |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 233 | std::vector<MediaResourceParcel> resources1; |
| 234 | resources1.push_back(MediaResource(MediaResource::Type::kSecureCodec, 1)); |
Chong Zhang | ee33d64 | 2019-08-08 14:26:43 -0700 | [diff] [blame] | 235 | mService->addResource(kTestPid1, kTestUid1, getId(mTestClient1), mTestClient1, resources1); |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 236 | resources1.push_back(MediaResource(MediaResource::Type::kGraphicMemory, 200)); |
| 237 | std::vector<MediaResourceParcel> resources11; |
| 238 | resources11.push_back(MediaResource(MediaResource::Type::kGraphicMemory, 200)); |
Chong Zhang | ee33d64 | 2019-08-08 14:26:43 -0700 | [diff] [blame] | 239 | mService->addResource(kTestPid1, kTestUid1, getId(mTestClient1), mTestClient1, resources11); |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 240 | |
| 241 | // kTestPid2 mTestClient2 |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 242 | std::vector<MediaResourceParcel> resources2; |
| 243 | resources2.push_back(MediaResource(MediaResource::Type::kNonSecureCodec, 1)); |
| 244 | resources2.push_back(MediaResource(MediaResource::Type::kGraphicMemory, 300)); |
Chong Zhang | ee33d64 | 2019-08-08 14:26:43 -0700 | [diff] [blame] | 245 | mService->addResource(kTestPid2, kTestUid2, getId(mTestClient2), mTestClient2, resources2); |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 246 | |
| 247 | // kTestPid2 mTestClient3 |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 248 | std::vector<MediaResourceParcel> resources3; |
Chong Zhang | ee33d64 | 2019-08-08 14:26:43 -0700 | [diff] [blame] | 249 | mService->addResource(kTestPid2, kTestUid2, getId(mTestClient3), mTestClient3, resources3); |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 250 | resources3.push_back(MediaResource(MediaResource::Type::kSecureCodec, 1)); |
| 251 | resources3.push_back(MediaResource(MediaResource::Type::kGraphicMemory, 100)); |
Chong Zhang | ee33d64 | 2019-08-08 14:26:43 -0700 | [diff] [blame] | 252 | mService->addResource(kTestPid2, kTestUid2, getId(mTestClient3), mTestClient3, resources3); |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 253 | |
| 254 | const PidResourceInfosMap &map = mService->mMap; |
| 255 | EXPECT_EQ(2u, map.size()); |
| 256 | ssize_t index1 = map.indexOfKey(kTestPid1); |
| 257 | ASSERT_GE(index1, 0); |
| 258 | const ResourceInfos &infos1 = map[index1]; |
| 259 | EXPECT_EQ(1u, infos1.size()); |
Chong Zhang | fb092d3 | 2019-08-12 09:45:44 -0700 | [diff] [blame] | 260 | expectEqResourceInfo(infos1.valueFor(getId(mTestClient1)), kTestUid1, mTestClient1, resources1); |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 261 | |
| 262 | ssize_t index2 = map.indexOfKey(kTestPid2); |
| 263 | ASSERT_GE(index2, 0); |
| 264 | const ResourceInfos &infos2 = map[index2]; |
| 265 | EXPECT_EQ(2u, infos2.size()); |
Chong Zhang | fb092d3 | 2019-08-12 09:45:44 -0700 | [diff] [blame] | 266 | expectEqResourceInfo(infos2.valueFor(getId(mTestClient2)), kTestUid2, mTestClient2, resources2); |
| 267 | expectEqResourceInfo(infos2.valueFor(getId(mTestClient3)), kTestUid2, mTestClient3, resources3); |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 268 | } |
| 269 | |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 270 | void testCombineResourceWithNegativeValues() { |
| 271 | // kTestPid1 mTestClient1 |
| 272 | std::vector<MediaResourceParcel> resources1; |
| 273 | resources1.push_back(MediaResource(MediaResource::Type::kDrmSession, -100)); |
| 274 | resources1.push_back(MediaResource(MediaResource::Type::kNonSecureCodec, -100)); |
| 275 | mService->addResource(kTestPid1, kTestUid1, getId(mTestClient1), mTestClient1, resources1); |
| 276 | |
| 277 | // Expected result: |
| 278 | // 1) the client should have been added; |
| 279 | // 2) both resource entries should have been rejected, resource list should be empty. |
| 280 | const PidResourceInfosMap &map = mService->mMap; |
| 281 | EXPECT_EQ(1u, map.size()); |
| 282 | ssize_t index1 = map.indexOfKey(kTestPid1); |
| 283 | ASSERT_GE(index1, 0); |
| 284 | const ResourceInfos &infos1 = map[index1]; |
| 285 | EXPECT_EQ(1u, infos1.size()); |
| 286 | std::vector<MediaResourceParcel> expected; |
| 287 | expectEqResourceInfo(infos1.valueFor(getId(mTestClient1)), kTestUid1, mTestClient1, expected); |
| 288 | |
| 289 | resources1.clear(); |
| 290 | resources1.push_back(MediaResource(MediaResource::Type::kDrmSession, INT64_MAX)); |
| 291 | resources1.push_back(MediaResource(MediaResource::Type::kNonSecureCodec, INT64_MAX)); |
| 292 | mService->addResource(kTestPid1, kTestUid1, getId(mTestClient1), mTestClient1, resources1); |
| 293 | resources1.clear(); |
| 294 | resources1.push_back(MediaResource(MediaResource::Type::kDrmSession, 10)); |
| 295 | resources1.push_back(MediaResource(MediaResource::Type::kNonSecureCodec, 10)); |
| 296 | mService->addResource(kTestPid1, kTestUid1, getId(mTestClient1), mTestClient1, resources1); |
| 297 | |
| 298 | // Expected result: |
| 299 | // Both values should saturate to INT64_MAX |
| 300 | expected.push_back(MediaResource(MediaResource::Type::kDrmSession, INT64_MAX)); |
| 301 | expected.push_back(MediaResource(MediaResource::Type::kNonSecureCodec, INT64_MAX)); |
| 302 | expectEqResourceInfo(infos1.valueFor(getId(mTestClient1)), kTestUid1, mTestClient1, expected); |
| 303 | |
| 304 | resources1.clear(); |
| 305 | resources1.push_back(MediaResource(MediaResource::Type::kDrmSession, -10)); |
| 306 | resources1.push_back(MediaResource(MediaResource::Type::kNonSecureCodec, -10)); |
| 307 | mService->addResource(kTestPid1, kTestUid1, getId(mTestClient1), mTestClient1, resources1); |
| 308 | |
| 309 | // Expected result: |
| 310 | // 1) DrmSession resource should allow negative value addition, and value should drop accordingly |
| 311 | // 2) Non-drm session resource should ignore negative value addition. |
| 312 | expected.push_back(MediaResource(MediaResource::Type::kDrmSession, INT64_MAX - 10)); |
| 313 | expected.push_back(MediaResource(MediaResource::Type::kNonSecureCodec, INT64_MAX)); |
| 314 | expectEqResourceInfo(infos1.valueFor(getId(mTestClient1)), kTestUid1, mTestClient1, expected); |
| 315 | |
| 316 | resources1.clear(); |
| 317 | resources1.push_back(MediaResource(MediaResource::Type::kDrmSession, INT64_MIN)); |
| 318 | expected.push_back(MediaResource(MediaResource::Type::kNonSecureCodec, INT64_MIN)); |
| 319 | mService->addResource(kTestPid1, kTestUid1, getId(mTestClient1), mTestClient1, resources1); |
| 320 | |
| 321 | // Expected result: |
| 322 | // 1) DrmSession resource value should drop to 0, but the entry shouldn't be removed. |
| 323 | // 2) Non-drm session resource should ignore negative value addition. |
| 324 | expected.clear(); |
| 325 | expected.push_back(MediaResource(MediaResource::Type::kDrmSession, 0)); |
| 326 | expected.push_back(MediaResource(MediaResource::Type::kNonSecureCodec, INT64_MAX)); |
| 327 | expectEqResourceInfo(infos1.valueFor(getId(mTestClient1)), kTestUid1, mTestClient1, expected); |
| 328 | } |
| 329 | |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 330 | void testConfig() { |
| 331 | EXPECT_TRUE(mService->mSupportsMultipleSecureCodecs); |
| 332 | EXPECT_TRUE(mService->mSupportsSecureWithNonSecureCodec); |
| 333 | |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 334 | std::vector<MediaResourcePolicyParcel> policies1; |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 335 | policies1.push_back( |
Ronghua Wu | 9ba21b9 | 2015-04-21 14:23:06 -0700 | [diff] [blame] | 336 | MediaResourcePolicy( |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 337 | IResourceManagerService::kPolicySupportsMultipleSecureCodecs(), |
| 338 | "true")); |
Ronghua Wu | 9ba21b9 | 2015-04-21 14:23:06 -0700 | [diff] [blame] | 339 | policies1.push_back( |
| 340 | MediaResourcePolicy( |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 341 | IResourceManagerService::kPolicySupportsSecureWithNonSecureCodec(), |
| 342 | "false")); |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 343 | mService->config(policies1); |
| 344 | EXPECT_TRUE(mService->mSupportsMultipleSecureCodecs); |
| 345 | EXPECT_FALSE(mService->mSupportsSecureWithNonSecureCodec); |
| 346 | |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 347 | std::vector<MediaResourcePolicyParcel> policies2; |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 348 | policies2.push_back( |
Ronghua Wu | 9ba21b9 | 2015-04-21 14:23:06 -0700 | [diff] [blame] | 349 | MediaResourcePolicy( |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 350 | IResourceManagerService::kPolicySupportsMultipleSecureCodecs(), |
| 351 | "false")); |
Ronghua Wu | 9ba21b9 | 2015-04-21 14:23:06 -0700 | [diff] [blame] | 352 | policies2.push_back( |
| 353 | MediaResourcePolicy( |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 354 | IResourceManagerService::kPolicySupportsSecureWithNonSecureCodec(), |
| 355 | "true")); |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 356 | mService->config(policies2); |
| 357 | EXPECT_FALSE(mService->mSupportsMultipleSecureCodecs); |
| 358 | EXPECT_TRUE(mService->mSupportsSecureWithNonSecureCodec); |
| 359 | } |
| 360 | |
Chong Zhang | fb092d3 | 2019-08-12 09:45:44 -0700 | [diff] [blame] | 361 | void testCombineResource() { |
| 362 | // kTestPid1 mTestClient1 |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 363 | std::vector<MediaResourceParcel> resources1; |
| 364 | resources1.push_back(MediaResource(MediaResource::Type::kSecureCodec, 1)); |
Chong Zhang | fb092d3 | 2019-08-12 09:45:44 -0700 | [diff] [blame] | 365 | mService->addResource(kTestPid1, kTestUid1, getId(mTestClient1), mTestClient1, resources1); |
| 366 | |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 367 | std::vector<MediaResourceParcel> resources11; |
| 368 | resources11.push_back(MediaResource(MediaResource::Type::kGraphicMemory, 200)); |
Chong Zhang | fb092d3 | 2019-08-12 09:45:44 -0700 | [diff] [blame] | 369 | mService->addResource(kTestPid1, kTestUid1, getId(mTestClient1), mTestClient1, resources11); |
| 370 | |
| 371 | const PidResourceInfosMap &map = mService->mMap; |
| 372 | EXPECT_EQ(1u, map.size()); |
| 373 | ssize_t index1 = map.indexOfKey(kTestPid1); |
| 374 | ASSERT_GE(index1, 0); |
| 375 | const ResourceInfos &infos1 = map[index1]; |
| 376 | EXPECT_EQ(1u, infos1.size()); |
| 377 | |
| 378 | // test adding existing types to combine values |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 379 | resources1.push_back(MediaResource(MediaResource::Type::kGraphicMemory, 100)); |
Chong Zhang | fb092d3 | 2019-08-12 09:45:44 -0700 | [diff] [blame] | 380 | mService->addResource(kTestPid1, kTestUid1, getId(mTestClient1), mTestClient1, resources1); |
| 381 | |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 382 | std::vector<MediaResourceParcel> expected; |
| 383 | expected.push_back(MediaResource(MediaResource::Type::kSecureCodec, 2)); |
| 384 | expected.push_back(MediaResource(MediaResource::Type::kGraphicMemory, 300)); |
Chong Zhang | fb092d3 | 2019-08-12 09:45:44 -0700 | [diff] [blame] | 385 | expectEqResourceInfo(infos1.valueFor(getId(mTestClient1)), kTestUid1, mTestClient1, expected); |
| 386 | |
| 387 | // test adding new types (including types that differs only in subType) |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 388 | resources11.push_back(MediaResource(MediaResource::Type::kNonSecureCodec, 1)); |
| 389 | resources11.push_back(MediaResource(MediaResource::Type::kSecureCodec, MediaResource::SubType::kVideoCodec, 1)); |
Chong Zhang | fb092d3 | 2019-08-12 09:45:44 -0700 | [diff] [blame] | 390 | mService->addResource(kTestPid1, kTestUid1, getId(mTestClient1), mTestClient1, resources11); |
| 391 | |
| 392 | expected.clear(); |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 393 | expected.push_back(MediaResource(MediaResource::Type::kSecureCodec, 2)); |
| 394 | expected.push_back(MediaResource(MediaResource::Type::kNonSecureCodec, 1)); |
| 395 | expected.push_back(MediaResource(MediaResource::Type::kSecureCodec, MediaResource::SubType::kVideoCodec, 1)); |
| 396 | expected.push_back(MediaResource(MediaResource::Type::kGraphicMemory, 500)); |
Chong Zhang | fb092d3 | 2019-08-12 09:45:44 -0700 | [diff] [blame] | 397 | expectEqResourceInfo(infos1.valueFor(getId(mTestClient1)), kTestUid1, mTestClient1, expected); |
| 398 | } |
| 399 | |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 400 | void testRemoveResource() { |
Chong Zhang | fb092d3 | 2019-08-12 09:45:44 -0700 | [diff] [blame] | 401 | // kTestPid1 mTestClient1 |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 402 | std::vector<MediaResourceParcel> resources1; |
| 403 | resources1.push_back(MediaResource(MediaResource::Type::kSecureCodec, 1)); |
Chong Zhang | fb092d3 | 2019-08-12 09:45:44 -0700 | [diff] [blame] | 404 | mService->addResource(kTestPid1, kTestUid1, getId(mTestClient1), mTestClient1, resources1); |
| 405 | |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 406 | std::vector<MediaResourceParcel> resources11; |
| 407 | resources11.push_back(MediaResource(MediaResource::Type::kGraphicMemory, 200)); |
Chong Zhang | fb092d3 | 2019-08-12 09:45:44 -0700 | [diff] [blame] | 408 | mService->addResource(kTestPid1, kTestUid1, getId(mTestClient1), mTestClient1, resources11); |
| 409 | |
| 410 | const PidResourceInfosMap &map = mService->mMap; |
| 411 | EXPECT_EQ(1u, map.size()); |
| 412 | ssize_t index1 = map.indexOfKey(kTestPid1); |
| 413 | ASSERT_GE(index1, 0); |
| 414 | const ResourceInfos &infos1 = map[index1]; |
| 415 | EXPECT_EQ(1u, infos1.size()); |
| 416 | |
| 417 | // test partial removal |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 418 | resources11[0].value = 100; |
Chong Zhang | fb092d3 | 2019-08-12 09:45:44 -0700 | [diff] [blame] | 419 | mService->removeResource(kTestPid1, getId(mTestClient1), resources11); |
| 420 | |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 421 | std::vector<MediaResourceParcel> expected; |
| 422 | expected.push_back(MediaResource(MediaResource::Type::kSecureCodec, 1)); |
| 423 | expected.push_back(MediaResource(MediaResource::Type::kGraphicMemory, 100)); |
| 424 | expectEqResourceInfo(infos1.valueFor(getId(mTestClient1)), kTestUid1, mTestClient1, expected); |
| 425 | |
| 426 | // test removal request with negative value, should be ignored |
| 427 | resources11[0].value = -10000; |
| 428 | mService->removeResource(kTestPid1, getId(mTestClient1), resources11); |
| 429 | |
Chong Zhang | fb092d3 | 2019-08-12 09:45:44 -0700 | [diff] [blame] | 430 | expectEqResourceInfo(infos1.valueFor(getId(mTestClient1)), kTestUid1, mTestClient1, expected); |
| 431 | |
| 432 | // test complete removal with overshoot value |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 433 | resources11[0].value = 1000; |
Chong Zhang | fb092d3 | 2019-08-12 09:45:44 -0700 | [diff] [blame] | 434 | mService->removeResource(kTestPid1, getId(mTestClient1), resources11); |
| 435 | |
| 436 | expected.clear(); |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 437 | expected.push_back(MediaResource(MediaResource::Type::kSecureCodec, 1)); |
Chong Zhang | fb092d3 | 2019-08-12 09:45:44 -0700 | [diff] [blame] | 438 | expectEqResourceInfo(infos1.valueFor(getId(mTestClient1)), kTestUid1, mTestClient1, expected); |
| 439 | } |
| 440 | |
| 441 | void testRemoveClient() { |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 442 | addResource(); |
| 443 | |
Chong Zhang | fb092d3 | 2019-08-12 09:45:44 -0700 | [diff] [blame] | 444 | mService->removeClient(kTestPid2, getId(mTestClient2)); |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 445 | |
| 446 | const PidResourceInfosMap &map = mService->mMap; |
| 447 | EXPECT_EQ(2u, map.size()); |
| 448 | const ResourceInfos &infos1 = map.valueFor(kTestPid1); |
| 449 | const ResourceInfos &infos2 = map.valueFor(kTestPid2); |
| 450 | EXPECT_EQ(1u, infos1.size()); |
| 451 | EXPECT_EQ(1u, infos2.size()); |
| 452 | // mTestClient2 has been removed. |
Chong Zhang | fb092d3 | 2019-08-12 09:45:44 -0700 | [diff] [blame] | 453 | // (OK to use infos2[0] as there is only 1 entry) |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 454 | EXPECT_EQ(mTestClient3, infos2[0].client); |
| 455 | } |
| 456 | |
| 457 | void testGetAllClients() { |
| 458 | addResource(); |
| 459 | |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 460 | MediaResource::Type type = MediaResource::Type::kSecureCodec; |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 461 | Vector<sp<IResourceManagerClient> > clients; |
Ronghua Wu | 05d89f1 | 2015-07-07 16:47:42 -0700 | [diff] [blame] | 462 | EXPECT_FALSE(mService->getAllClients_l(kLowPriorityPid, type, &clients)); |
Ronghua Wu | 67e7f54 | 2015-03-13 10:47:08 -0700 | [diff] [blame] | 463 | // some higher priority process (e.g. kTestPid2) owns the resource, so getAllClients_l |
| 464 | // will fail. |
Ronghua Wu | 05d89f1 | 2015-07-07 16:47:42 -0700 | [diff] [blame] | 465 | EXPECT_FALSE(mService->getAllClients_l(kMidPriorityPid, type, &clients)); |
Ronghua Wu | 05d89f1 | 2015-07-07 16:47:42 -0700 | [diff] [blame] | 466 | EXPECT_TRUE(mService->getAllClients_l(kHighPriorityPid, type, &clients)); |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 467 | |
| 468 | EXPECT_EQ(2u, clients.size()); |
Chong Zhang | fb092d3 | 2019-08-12 09:45:44 -0700 | [diff] [blame] | 469 | // (OK to require ordering in clients[], as the pid map is sorted) |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 470 | EXPECT_EQ(mTestClient3, clients[0]); |
| 471 | EXPECT_EQ(mTestClient1, clients[1]); |
| 472 | } |
| 473 | |
| 474 | void testReclaimResourceSecure() { |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 475 | bool result; |
| 476 | std::vector<MediaResourceParcel> resources; |
| 477 | resources.push_back(MediaResource(MediaResource::Type::kSecureCodec, 1)); |
| 478 | resources.push_back(MediaResource(MediaResource::Type::kGraphicMemory, 150)); |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 479 | |
| 480 | // ### secure codec can't coexist and secure codec can coexist with non-secure codec ### |
| 481 | { |
| 482 | addResource(); |
| 483 | mService->mSupportsMultipleSecureCodecs = false; |
| 484 | mService->mSupportsSecureWithNonSecureCodec = true; |
| 485 | |
| 486 | // priority too low |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 487 | CHECK_STATUS_FALSE(mService->reclaimResource(kLowPriorityPid, resources, &result)); |
| 488 | CHECK_STATUS_FALSE(mService->reclaimResource(kMidPriorityPid, resources, &result)); |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 489 | |
| 490 | // reclaim all secure codecs |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 491 | CHECK_STATUS_TRUE(mService->reclaimResource(kHighPriorityPid, resources, &result)); |
Ronghua Wu | 05d89f1 | 2015-07-07 16:47:42 -0700 | [diff] [blame] | 492 | verifyClients(true /* c1 */, false /* c2 */, true /* c3 */); |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 493 | |
| 494 | // call again should reclaim one largest graphic memory from lowest process |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 495 | CHECK_STATUS_TRUE(mService->reclaimResource(kHighPriorityPid, resources, &result)); |
Ronghua Wu | 05d89f1 | 2015-07-07 16:47:42 -0700 | [diff] [blame] | 496 | verifyClients(false /* c1 */, true /* c2 */, false /* c3 */); |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 497 | |
| 498 | // nothing left |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 499 | CHECK_STATUS_FALSE(mService->reclaimResource(kHighPriorityPid, resources, &result)); |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 500 | } |
| 501 | |
| 502 | // ### secure codecs can't coexist and secure codec can't coexist with non-secure codec ### |
| 503 | { |
| 504 | addResource(); |
| 505 | mService->mSupportsMultipleSecureCodecs = false; |
| 506 | mService->mSupportsSecureWithNonSecureCodec = false; |
| 507 | |
| 508 | // priority too low |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 509 | CHECK_STATUS_FALSE(mService->reclaimResource(kLowPriorityPid, resources, &result)); |
| 510 | CHECK_STATUS_FALSE(mService->reclaimResource(kMidPriorityPid, resources, &result)); |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 511 | |
| 512 | // reclaim all secure and non-secure codecs |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 513 | CHECK_STATUS_TRUE(mService->reclaimResource(kHighPriorityPid, resources, &result)); |
Ronghua Wu | 05d89f1 | 2015-07-07 16:47:42 -0700 | [diff] [blame] | 514 | verifyClients(true /* c1 */, true /* c2 */, true /* c3 */); |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 515 | |
| 516 | // nothing left |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 517 | CHECK_STATUS_FALSE(mService->reclaimResource(kHighPriorityPid, resources, &result)); |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 518 | } |
| 519 | |
| 520 | |
| 521 | // ### secure codecs can coexist but secure codec can't coexist with non-secure codec ### |
| 522 | { |
| 523 | addResource(); |
| 524 | mService->mSupportsMultipleSecureCodecs = true; |
| 525 | mService->mSupportsSecureWithNonSecureCodec = false; |
| 526 | |
| 527 | // priority too low |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 528 | CHECK_STATUS_FALSE(mService->reclaimResource(kLowPriorityPid, resources, &result)); |
| 529 | CHECK_STATUS_FALSE(mService->reclaimResource(kMidPriorityPid, resources, &result)); |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 530 | |
| 531 | // reclaim all non-secure codecs |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 532 | CHECK_STATUS_TRUE(mService->reclaimResource(kHighPriorityPid, resources, &result)); |
Ronghua Wu | 05d89f1 | 2015-07-07 16:47:42 -0700 | [diff] [blame] | 533 | verifyClients(false /* c1 */, true /* c2 */, false /* c3 */); |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 534 | |
| 535 | // call again should reclaim one largest graphic memory from lowest process |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 536 | CHECK_STATUS_TRUE(mService->reclaimResource(kHighPriorityPid, resources, &result)); |
Ronghua Wu | 05d89f1 | 2015-07-07 16:47:42 -0700 | [diff] [blame] | 537 | verifyClients(true /* c1 */, false /* c2 */, false /* c3 */); |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 538 | |
| 539 | // call again should reclaim another largest graphic memory from lowest process |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 540 | CHECK_STATUS_TRUE(mService->reclaimResource(kHighPriorityPid, resources, &result)); |
Ronghua Wu | 05d89f1 | 2015-07-07 16:47:42 -0700 | [diff] [blame] | 541 | verifyClients(false /* c1 */, false /* c2 */, true /* c3 */); |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 542 | |
| 543 | // nothing left |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 544 | CHECK_STATUS_FALSE(mService->reclaimResource(kHighPriorityPid, resources, &result)); |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 545 | } |
| 546 | |
| 547 | // ### secure codecs can coexist and secure codec can coexist with non-secure codec ### |
| 548 | { |
| 549 | addResource(); |
| 550 | mService->mSupportsMultipleSecureCodecs = true; |
| 551 | mService->mSupportsSecureWithNonSecureCodec = true; |
| 552 | |
| 553 | // priority too low |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 554 | CHECK_STATUS_FALSE(mService->reclaimResource(kLowPriorityPid, resources, &result)); |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 555 | |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 556 | CHECK_STATUS_TRUE(mService->reclaimResource(kHighPriorityPid, resources, &result)); |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 557 | // one largest graphic memory from lowest process got reclaimed |
Ronghua Wu | 05d89f1 | 2015-07-07 16:47:42 -0700 | [diff] [blame] | 558 | verifyClients(true /* c1 */, false /* c2 */, false /* c3 */); |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 559 | |
| 560 | // call again should reclaim another graphic memory from lowest process |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 561 | CHECK_STATUS_TRUE(mService->reclaimResource(kHighPriorityPid, resources, &result)); |
Ronghua Wu | 05d89f1 | 2015-07-07 16:47:42 -0700 | [diff] [blame] | 562 | verifyClients(false /* c1 */, true /* c2 */, false /* c3 */); |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 563 | |
| 564 | // call again should reclaim another graphic memory from lowest process |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 565 | CHECK_STATUS_TRUE(mService->reclaimResource(kHighPriorityPid, resources, &result)); |
Ronghua Wu | 05d89f1 | 2015-07-07 16:47:42 -0700 | [diff] [blame] | 566 | verifyClients(false /* c1 */, false /* c2 */, true /* c3 */); |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 567 | |
| 568 | // nothing left |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 569 | CHECK_STATUS_FALSE(mService->reclaimResource(kHighPriorityPid, resources, &result)); |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 570 | } |
Ronghua Wu | 67e7f54 | 2015-03-13 10:47:08 -0700 | [diff] [blame] | 571 | |
| 572 | // ### secure codecs can coexist and secure codec can coexist with non-secure codec ### |
| 573 | { |
| 574 | addResource(); |
| 575 | mService->mSupportsMultipleSecureCodecs = true; |
| 576 | mService->mSupportsSecureWithNonSecureCodec = true; |
| 577 | |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 578 | std::vector<MediaResourceParcel> resources; |
| 579 | resources.push_back(MediaResource(MediaResource::Type::kSecureCodec, 1)); |
Ronghua Wu | 67e7f54 | 2015-03-13 10:47:08 -0700 | [diff] [blame] | 580 | |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 581 | CHECK_STATUS_TRUE(mService->reclaimResource(kHighPriorityPid, resources, &result)); |
Ronghua Wu | 67e7f54 | 2015-03-13 10:47:08 -0700 | [diff] [blame] | 582 | // secure codec from lowest process got reclaimed |
Ronghua Wu | 05d89f1 | 2015-07-07 16:47:42 -0700 | [diff] [blame] | 583 | verifyClients(true /* c1 */, false /* c2 */, false /* c3 */); |
Ronghua Wu | 67e7f54 | 2015-03-13 10:47:08 -0700 | [diff] [blame] | 584 | |
| 585 | // call again should reclaim another secure codec from lowest process |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 586 | CHECK_STATUS_TRUE(mService->reclaimResource(kHighPriorityPid, resources, &result)); |
Ronghua Wu | 05d89f1 | 2015-07-07 16:47:42 -0700 | [diff] [blame] | 587 | verifyClients(false /* c1 */, false /* c2 */, true /* c3 */); |
Ronghua Wu | 67e7f54 | 2015-03-13 10:47:08 -0700 | [diff] [blame] | 588 | |
Ronghua Wu | 05d89f1 | 2015-07-07 16:47:42 -0700 | [diff] [blame] | 589 | // no more secure codec, non-secure codec will be reclaimed. |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 590 | CHECK_STATUS_TRUE(mService->reclaimResource(kHighPriorityPid, resources, &result)); |
Ronghua Wu | 05d89f1 | 2015-07-07 16:47:42 -0700 | [diff] [blame] | 591 | verifyClients(false /* c1 */, true /* c2 */, false /* c3 */); |
Ronghua Wu | 67e7f54 | 2015-03-13 10:47:08 -0700 | [diff] [blame] | 592 | } |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 593 | } |
| 594 | |
| 595 | void testReclaimResourceNonSecure() { |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 596 | bool result; |
| 597 | std::vector<MediaResourceParcel> resources; |
| 598 | resources.push_back(MediaResource(MediaResource::Type::kNonSecureCodec, 1)); |
| 599 | resources.push_back(MediaResource(MediaResource::Type::kGraphicMemory, 150)); |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 600 | |
| 601 | // ### secure codec can't coexist with non-secure codec ### |
| 602 | { |
| 603 | addResource(); |
| 604 | mService->mSupportsSecureWithNonSecureCodec = false; |
| 605 | |
| 606 | // priority too low |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 607 | CHECK_STATUS_FALSE(mService->reclaimResource(kLowPriorityPid, resources, &result)); |
| 608 | CHECK_STATUS_FALSE(mService->reclaimResource(kMidPriorityPid, resources, &result)); |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 609 | |
| 610 | // reclaim all secure codecs |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 611 | CHECK_STATUS_TRUE(mService->reclaimResource(kHighPriorityPid, resources, &result)); |
Ronghua Wu | 05d89f1 | 2015-07-07 16:47:42 -0700 | [diff] [blame] | 612 | verifyClients(true /* c1 */, false /* c2 */, true /* c3 */); |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 613 | |
| 614 | // call again should reclaim one graphic memory from lowest process |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 615 | CHECK_STATUS_TRUE(mService->reclaimResource(kHighPriorityPid, resources, &result)); |
Ronghua Wu | 05d89f1 | 2015-07-07 16:47:42 -0700 | [diff] [blame] | 616 | verifyClients(false /* c1 */, true /* c2 */, false /* c3 */); |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 617 | |
| 618 | // nothing left |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 619 | CHECK_STATUS_FALSE(mService->reclaimResource(kHighPriorityPid, resources, &result)); |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 620 | } |
| 621 | |
| 622 | |
| 623 | // ### secure codec can coexist with non-secure codec ### |
| 624 | { |
| 625 | addResource(); |
| 626 | mService->mSupportsSecureWithNonSecureCodec = true; |
| 627 | |
| 628 | // priority too low |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 629 | CHECK_STATUS_FALSE(mService->reclaimResource(kLowPriorityPid, resources, &result)); |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 630 | |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 631 | CHECK_STATUS_TRUE(mService->reclaimResource(kHighPriorityPid, resources, &result)); |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 632 | // one largest graphic memory from lowest process got reclaimed |
Ronghua Wu | 05d89f1 | 2015-07-07 16:47:42 -0700 | [diff] [blame] | 633 | verifyClients(true /* c1 */, false /* c2 */, false /* c3 */); |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 634 | |
| 635 | // call again should reclaim another graphic memory from lowest process |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 636 | CHECK_STATUS_TRUE(mService->reclaimResource(kHighPriorityPid, resources, &result)); |
Ronghua Wu | 05d89f1 | 2015-07-07 16:47:42 -0700 | [diff] [blame] | 637 | verifyClients(false /* c1 */, true /* c2 */, false /* c3 */); |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 638 | |
| 639 | // call again should reclaim another graphic memory from lowest process |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 640 | CHECK_STATUS_TRUE(mService->reclaimResource(kHighPriorityPid, resources, &result)); |
Ronghua Wu | 05d89f1 | 2015-07-07 16:47:42 -0700 | [diff] [blame] | 641 | verifyClients(false /* c1 */, false /* c2 */, true /* c3 */); |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 642 | |
| 643 | // nothing left |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 644 | CHECK_STATUS_FALSE(mService->reclaimResource(kHighPriorityPid, resources, &result)); |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 645 | } |
Ronghua Wu | 67e7f54 | 2015-03-13 10:47:08 -0700 | [diff] [blame] | 646 | |
| 647 | // ### secure codec can coexist with non-secure codec ### |
| 648 | { |
| 649 | addResource(); |
| 650 | mService->mSupportsSecureWithNonSecureCodec = true; |
| 651 | |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 652 | std::vector<MediaResourceParcel> resources; |
| 653 | resources.push_back(MediaResource(MediaResource::Type::kNonSecureCodec, 1)); |
Ronghua Wu | 67e7f54 | 2015-03-13 10:47:08 -0700 | [diff] [blame] | 654 | |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 655 | CHECK_STATUS_TRUE(mService->reclaimResource(kHighPriorityPid, resources, &result)); |
Ronghua Wu | 67e7f54 | 2015-03-13 10:47:08 -0700 | [diff] [blame] | 656 | // one non secure codec from lowest process got reclaimed |
Ronghua Wu | 05d89f1 | 2015-07-07 16:47:42 -0700 | [diff] [blame] | 657 | verifyClients(false /* c1 */, true /* c2 */, false /* c3 */); |
Ronghua Wu | 67e7f54 | 2015-03-13 10:47:08 -0700 | [diff] [blame] | 658 | |
Ronghua Wu | 05d89f1 | 2015-07-07 16:47:42 -0700 | [diff] [blame] | 659 | // no more non-secure codec, secure codec from lowest priority process will be reclaimed |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 660 | CHECK_STATUS_TRUE(mService->reclaimResource(kHighPriorityPid, resources, &result)); |
Ronghua Wu | 05d89f1 | 2015-07-07 16:47:42 -0700 | [diff] [blame] | 661 | verifyClients(true /* c1 */, false /* c2 */, false /* c3 */); |
Ronghua Wu | 67e7f54 | 2015-03-13 10:47:08 -0700 | [diff] [blame] | 662 | |
Ronghua Wu | 05d89f1 | 2015-07-07 16:47:42 -0700 | [diff] [blame] | 663 | // clean up client 3 which still left |
Chong Zhang | fb092d3 | 2019-08-12 09:45:44 -0700 | [diff] [blame] | 664 | mService->removeClient(kTestPid2, getId(mTestClient3)); |
Ronghua Wu | 67e7f54 | 2015-03-13 10:47:08 -0700 | [diff] [blame] | 665 | } |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 666 | } |
| 667 | |
| 668 | void testGetLowestPriorityBiggestClient() { |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 669 | MediaResource::Type type = MediaResource::Type::kGraphicMemory; |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 670 | sp<IResourceManagerClient> client; |
Ronghua Wu | 05d89f1 | 2015-07-07 16:47:42 -0700 | [diff] [blame] | 671 | EXPECT_FALSE(mService->getLowestPriorityBiggestClient_l(kHighPriorityPid, type, &client)); |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 672 | |
| 673 | addResource(); |
| 674 | |
Ronghua Wu | 05d89f1 | 2015-07-07 16:47:42 -0700 | [diff] [blame] | 675 | EXPECT_FALSE(mService->getLowestPriorityBiggestClient_l(kLowPriorityPid, type, &client)); |
| 676 | EXPECT_TRUE(mService->getLowestPriorityBiggestClient_l(kHighPriorityPid, type, &client)); |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 677 | |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 678 | // kTestPid1 is the lowest priority process with MediaResource::Type::kGraphicMemory. |
| 679 | // mTestClient1 has the largest MediaResource::Type::kGraphicMemory within kTestPid1. |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 680 | EXPECT_EQ(mTestClient1, client); |
| 681 | } |
| 682 | |
| 683 | void testGetLowestPriorityPid() { |
| 684 | int pid; |
| 685 | int priority; |
| 686 | TestProcessInfo processInfo; |
| 687 | |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 688 | MediaResource::Type type = MediaResource::Type::kGraphicMemory; |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 689 | EXPECT_FALSE(mService->getLowestPriorityPid_l(type, &pid, &priority)); |
| 690 | |
| 691 | addResource(); |
| 692 | |
| 693 | EXPECT_TRUE(mService->getLowestPriorityPid_l(type, &pid, &priority)); |
| 694 | EXPECT_EQ(kTestPid1, pid); |
| 695 | int priority1; |
| 696 | processInfo.getPriority(kTestPid1, &priority1); |
| 697 | EXPECT_EQ(priority1, priority); |
| 698 | |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 699 | type = MediaResource::Type::kNonSecureCodec; |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 700 | EXPECT_TRUE(mService->getLowestPriorityPid_l(type, &pid, &priority)); |
| 701 | EXPECT_EQ(kTestPid2, pid); |
| 702 | int priority2; |
| 703 | processInfo.getPriority(kTestPid2, &priority2); |
| 704 | EXPECT_EQ(priority2, priority); |
| 705 | } |
| 706 | |
| 707 | void testGetBiggestClient() { |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 708 | MediaResource::Type type = MediaResource::Type::kGraphicMemory; |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 709 | sp<IResourceManagerClient> client; |
| 710 | EXPECT_FALSE(mService->getBiggestClient_l(kTestPid2, type, &client)); |
| 711 | |
| 712 | addResource(); |
| 713 | |
| 714 | EXPECT_TRUE(mService->getBiggestClient_l(kTestPid2, type, &client)); |
| 715 | EXPECT_EQ(mTestClient2, client); |
| 716 | } |
| 717 | |
| 718 | void testIsCallingPriorityHigher() { |
| 719 | EXPECT_FALSE(mService->isCallingPriorityHigher_l(101, 100)); |
| 720 | EXPECT_FALSE(mService->isCallingPriorityHigher_l(100, 100)); |
| 721 | EXPECT_TRUE(mService->isCallingPriorityHigher_l(99, 100)); |
| 722 | } |
| 723 | |
Chong Zhang | dd72680 | 2019-08-21 17:24:13 -0700 | [diff] [blame] | 724 | void testBatteryStats() { |
| 725 | // reset should always be called when ResourceManagerService is created (restarted) |
| 726 | EXPECT_EQ(1u, mSystemCB->eventCount()); |
| 727 | EXPECT_EQ(EventType::VIDEO_RESET, mSystemCB->lastEventType()); |
| 728 | |
| 729 | // new client request should cause VIDEO_ON |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 730 | std::vector<MediaResourceParcel> resources1; |
| 731 | resources1.push_back(MediaResource(MediaResource::Type::kBattery, MediaResource::SubType::kVideoCodec, 1)); |
Chong Zhang | dd72680 | 2019-08-21 17:24:13 -0700 | [diff] [blame] | 732 | mService->addResource(kTestPid1, kTestUid1, getId(mTestClient1), mTestClient1, resources1); |
| 733 | EXPECT_EQ(2u, mSystemCB->eventCount()); |
| 734 | EXPECT_EQ(EventEntry({EventType::VIDEO_ON, kTestUid1}), mSystemCB->lastEvent()); |
| 735 | |
| 736 | // each client should only cause 1 VIDEO_ON |
| 737 | mService->addResource(kTestPid1, kTestUid1, getId(mTestClient1), mTestClient1, resources1); |
| 738 | EXPECT_EQ(2u, mSystemCB->eventCount()); |
| 739 | |
| 740 | // new client request should cause VIDEO_ON |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 741 | std::vector<MediaResourceParcel> resources2; |
| 742 | resources2.push_back(MediaResource(MediaResource::Type::kBattery, MediaResource::SubType::kVideoCodec, 2)); |
Chong Zhang | dd72680 | 2019-08-21 17:24:13 -0700 | [diff] [blame] | 743 | mService->addResource(kTestPid2, kTestUid2, getId(mTestClient2), mTestClient2, resources2); |
| 744 | EXPECT_EQ(3u, mSystemCB->eventCount()); |
| 745 | EXPECT_EQ(EventEntry({EventType::VIDEO_ON, kTestUid2}), mSystemCB->lastEvent()); |
| 746 | |
| 747 | // partially remove mTestClient1's request, shouldn't be any VIDEO_OFF |
| 748 | mService->removeResource(kTestPid1, getId(mTestClient1), resources1); |
| 749 | EXPECT_EQ(3u, mSystemCB->eventCount()); |
| 750 | |
| 751 | // remove mTestClient1's request, should be VIDEO_OFF for kTestUid1 |
| 752 | // (use resource2 to test removing more instances than previously requested) |
| 753 | mService->removeResource(kTestPid1, getId(mTestClient1), resources2); |
| 754 | EXPECT_EQ(4u, mSystemCB->eventCount()); |
| 755 | EXPECT_EQ(EventEntry({EventType::VIDEO_OFF, kTestUid1}), mSystemCB->lastEvent()); |
| 756 | |
| 757 | // remove mTestClient2, should be VIDEO_OFF for kTestUid2 |
| 758 | mService->removeClient(kTestPid2, getId(mTestClient2)); |
| 759 | EXPECT_EQ(5u, mSystemCB->eventCount()); |
| 760 | EXPECT_EQ(EventEntry({EventType::VIDEO_OFF, kTestUid2}), mSystemCB->lastEvent()); |
| 761 | } |
| 762 | |
| 763 | void testCpusetBoost() { |
| 764 | // reset should always be called when ResourceManagerService is created (restarted) |
| 765 | EXPECT_EQ(1u, mSystemCB->eventCount()); |
| 766 | EXPECT_EQ(EventType::VIDEO_RESET, mSystemCB->lastEventType()); |
| 767 | |
| 768 | // new client request should cause CPUSET_ENABLE |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 769 | std::vector<MediaResourceParcel> resources1; |
| 770 | resources1.push_back(MediaResource(MediaResource::Type::kCpuBoost, 1)); |
Chong Zhang | dd72680 | 2019-08-21 17:24:13 -0700 | [diff] [blame] | 771 | mService->addResource(kTestPid1, kTestUid1, getId(mTestClient1), mTestClient1, resources1); |
| 772 | EXPECT_EQ(2u, mSystemCB->eventCount()); |
| 773 | EXPECT_EQ(EventType::CPUSET_ENABLE, mSystemCB->lastEventType()); |
| 774 | |
| 775 | // each client should only cause 1 CPUSET_ENABLE |
| 776 | mService->addResource(kTestPid1, kTestUid1, getId(mTestClient1), mTestClient1, resources1); |
| 777 | EXPECT_EQ(2u, mSystemCB->eventCount()); |
| 778 | |
| 779 | // new client request should cause CPUSET_ENABLE |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 780 | std::vector<MediaResourceParcel> resources2; |
| 781 | resources2.push_back(MediaResource(MediaResource::Type::kCpuBoost, 2)); |
Chong Zhang | dd72680 | 2019-08-21 17:24:13 -0700 | [diff] [blame] | 782 | mService->addResource(kTestPid2, kTestUid2, getId(mTestClient2), mTestClient2, resources2); |
| 783 | EXPECT_EQ(3u, mSystemCB->eventCount()); |
| 784 | EXPECT_EQ(EventType::CPUSET_ENABLE, mSystemCB->lastEventType()); |
| 785 | |
| 786 | // remove mTestClient2 should not cause CPUSET_DISABLE, mTestClient1 still active |
| 787 | mService->removeClient(kTestPid2, getId(mTestClient2)); |
| 788 | EXPECT_EQ(3u, mSystemCB->eventCount()); |
| 789 | |
| 790 | // remove 1 cpuboost from mTestClient1, should not be CPUSET_DISABLE (still 1 left) |
| 791 | mService->removeResource(kTestPid1, getId(mTestClient1), resources1); |
| 792 | EXPECT_EQ(3u, mSystemCB->eventCount()); |
| 793 | |
| 794 | // remove 2 cpuboost from mTestClient1, should be CPUSET_DISABLE |
| 795 | // (use resource2 to test removing more than previously requested) |
| 796 | mService->removeResource(kTestPid1, getId(mTestClient1), resources2); |
| 797 | EXPECT_EQ(4u, mSystemCB->eventCount()); |
| 798 | EXPECT_EQ(EventType::CPUSET_DISABLE, mSystemCB->lastEventType()); |
| 799 | } |
| 800 | |
| 801 | sp<TestSystemCallback> mSystemCB; |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 802 | sp<ResourceManagerService> mService; |
| 803 | sp<IResourceManagerClient> mTestClient1; |
| 804 | sp<IResourceManagerClient> mTestClient2; |
| 805 | sp<IResourceManagerClient> mTestClient3; |
| 806 | }; |
| 807 | |
| 808 | TEST_F(ResourceManagerServiceTest, config) { |
| 809 | testConfig(); |
| 810 | } |
| 811 | |
| 812 | TEST_F(ResourceManagerServiceTest, addResource) { |
| 813 | addResource(); |
| 814 | } |
| 815 | |
Chong Zhang | fb092d3 | 2019-08-12 09:45:44 -0700 | [diff] [blame] | 816 | TEST_F(ResourceManagerServiceTest, combineResource) { |
| 817 | testCombineResource(); |
| 818 | } |
| 819 | |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 820 | TEST_F(ResourceManagerServiceTest, combineResourceNegative) { |
| 821 | testCombineResourceWithNegativeValues(); |
| 822 | } |
| 823 | |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 824 | TEST_F(ResourceManagerServiceTest, removeResource) { |
| 825 | testRemoveResource(); |
| 826 | } |
| 827 | |
Chong Zhang | fb092d3 | 2019-08-12 09:45:44 -0700 | [diff] [blame] | 828 | TEST_F(ResourceManagerServiceTest, removeClient) { |
| 829 | testRemoveClient(); |
| 830 | } |
| 831 | |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 832 | TEST_F(ResourceManagerServiceTest, reclaimResource) { |
| 833 | testReclaimResourceSecure(); |
| 834 | testReclaimResourceNonSecure(); |
| 835 | } |
| 836 | |
| 837 | TEST_F(ResourceManagerServiceTest, getAllClients_l) { |
| 838 | testGetAllClients(); |
| 839 | } |
| 840 | |
| 841 | TEST_F(ResourceManagerServiceTest, getLowestPriorityBiggestClient_l) { |
| 842 | testGetLowestPriorityBiggestClient(); |
| 843 | } |
| 844 | |
| 845 | TEST_F(ResourceManagerServiceTest, getLowestPriorityPid_l) { |
| 846 | testGetLowestPriorityPid(); |
| 847 | } |
| 848 | |
| 849 | TEST_F(ResourceManagerServiceTest, getBiggestClient_l) { |
| 850 | testGetBiggestClient(); |
| 851 | } |
| 852 | |
| 853 | TEST_F(ResourceManagerServiceTest, isCallingPriorityHigher_l) { |
| 854 | testIsCallingPriorityHigher(); |
| 855 | } |
| 856 | |
Chong Zhang | dd72680 | 2019-08-21 17:24:13 -0700 | [diff] [blame] | 857 | TEST_F(ResourceManagerServiceTest, testBatteryStats) { |
| 858 | testBatteryStats(); |
| 859 | } |
| 860 | |
| 861 | TEST_F(ResourceManagerServiceTest, testCpusetBoost) { |
| 862 | testCpusetBoost(); |
| 863 | } |
| 864 | |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame^] | 865 | } // namespace media |
Ronghua Wu | 231c3d1 | 2015-03-11 15:10:32 -0700 | [diff] [blame] | 866 | } // namespace android |