blob: 9ee6d93cf0322750983cd97073a67dde597c3812 [file] [log] [blame]
ChengYou Ho10f8a482021-01-02 22:45:32 +08001/*
2 * Copyright (C) 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#include <aidl/Gtest.h>
17#include <aidl/Vintf.h>
18
19#include <aidl/android/hardware/weaver/IWeaver.h>
Eric Biggers31380e72023-07-18 02:34:00 +000020#include <android-base/file.h>
21#include <android-base/parseint.h>
22#include <android-base/strings.h>
ChengYou Ho10f8a482021-01-02 22:45:32 +080023#include <android/binder_manager.h>
24#include <android/binder_process.h>
Eric Biggersb59654f2023-07-18 02:33:59 +000025#include <android/hardware/weaver/1.0/IWeaver.h>
26#include <hidl/GtestPrinter.h>
27#include <hidl/ServiceManagement.h>
ChengYou Ho10f8a482021-01-02 22:45:32 +080028
29#include <limits>
30
31using ::aidl::android::hardware::weaver::IWeaver;
32using ::aidl::android::hardware::weaver::WeaverConfig;
33using ::aidl::android::hardware::weaver::WeaverReadResponse;
ChengYou Ho20c47b42022-11-30 17:51:17 +000034using ::aidl::android::hardware::weaver::WeaverReadStatus;
ChengYou Ho10f8a482021-01-02 22:45:32 +080035
Eric Biggersb59654f2023-07-18 02:33:59 +000036using HidlIWeaver = ::android::hardware::weaver::V1_0::IWeaver;
37using HidlWeaverConfig = ::android::hardware::weaver::V1_0::WeaverConfig;
38using HidlWeaverReadStatus = ::android::hardware::weaver::V1_0::WeaverReadStatus;
39using HidlWeaverReadResponse = ::android::hardware::weaver::V1_0::WeaverReadResponse;
40using HidlWeaverStatus = ::android::hardware::weaver::V1_0::WeaverStatus;
ChengYou Ho10f8a482021-01-02 22:45:32 +080041
Eric Biggers31380e72023-07-18 02:34:00 +000042const std::string kSlotMapFile = "/metadata/password_slots/slot_map";
ChengYou Ho10f8a482021-01-02 22:45:32 +080043const std::vector<uint8_t> KEY{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16};
44const std::vector<uint8_t> WRONG_KEY{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
45const std::vector<uint8_t> VALUE{16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1};
46const std::vector<uint8_t> OTHER_VALUE{0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 255, 255};
47
Eric Biggersb59654f2023-07-18 02:33:59 +000048class WeaverAdapter {
49 public:
50 virtual ~WeaverAdapter() {}
51 virtual bool isReady() = 0;
52 virtual ::ndk::ScopedAStatus getConfig(WeaverConfig* _aidl_return) = 0;
53 virtual ::ndk::ScopedAStatus read(int32_t in_slotId, const std::vector<uint8_t>& in_key,
54 WeaverReadResponse* _aidl_return) = 0;
55 virtual ::ndk::ScopedAStatus write(int32_t in_slotId, const std::vector<uint8_t>& in_key,
56 const std::vector<uint8_t>& in_value) = 0;
57};
58
59class WeaverAidlAdapter : public WeaverAdapter {
60 public:
61 WeaverAidlAdapter(const std::string& param)
62 : aidl_weaver_(IWeaver::fromBinder(
63 ::ndk::SpAIBinder(AServiceManager_waitForService(param.c_str())))) {}
64 ~WeaverAidlAdapter() {}
65
66 bool isReady() { return aidl_weaver_ != nullptr; }
67
68 ::ndk::ScopedAStatus getConfig(WeaverConfig* _aidl_return) {
69 return aidl_weaver_->getConfig(_aidl_return);
ChengYou Ho10f8a482021-01-02 22:45:32 +080070 }
71
Eric Biggersb59654f2023-07-18 02:33:59 +000072 ::ndk::ScopedAStatus read(int32_t in_slotId, const std::vector<uint8_t>& in_key,
73 WeaverReadResponse* _aidl_return) {
74 return aidl_weaver_->read(in_slotId, in_key, _aidl_return);
75 }
ChengYou Ho10f8a482021-01-02 22:45:32 +080076
Eric Biggersb59654f2023-07-18 02:33:59 +000077 ::ndk::ScopedAStatus write(int32_t in_slotId, const std::vector<uint8_t>& in_key,
78 const std::vector<uint8_t>& in_value) {
79 return aidl_weaver_->write(in_slotId, in_key, in_value);
80 }
81
82 private:
83 std::shared_ptr<IWeaver> aidl_weaver_;
ChengYou Ho10f8a482021-01-02 22:45:32 +080084};
85
Eric Biggersb59654f2023-07-18 02:33:59 +000086class WeaverHidlAdapter : public WeaverAdapter {
87 public:
88 WeaverHidlAdapter(const std::string& param) : hidl_weaver_(HidlIWeaver::getService(param)) {}
89 ~WeaverHidlAdapter() {}
90
91 bool isReady() { return hidl_weaver_ != nullptr; }
92
93 ::ndk::ScopedAStatus getConfig(WeaverConfig* _aidl_return) {
94 bool callbackCalled = false;
95 HidlWeaverStatus status;
96 HidlWeaverConfig config;
97 auto ret = hidl_weaver_->getConfig([&](HidlWeaverStatus s, HidlWeaverConfig c) {
98 callbackCalled = true;
99 status = s;
100 config = c;
101 });
102 if (!ret.isOk() || !callbackCalled || status != HidlWeaverStatus::OK) {
103 return ::ndk::ScopedAStatus::fromStatus(STATUS_FAILED_TRANSACTION);
104 }
105 _aidl_return->slots = config.slots;
106 _aidl_return->keySize = config.keySize;
107 _aidl_return->valueSize = config.valueSize;
108 return ::ndk::ScopedAStatus::ok();
109 }
110
111 ::ndk::ScopedAStatus read(int32_t in_slotId, const std::vector<uint8_t>& in_key,
112 WeaverReadResponse* _aidl_return) {
113 bool callbackCalled = false;
114 HidlWeaverReadStatus status;
115 std::vector<uint8_t> value;
116 uint32_t timeout;
117 auto ret = hidl_weaver_->read(in_slotId, in_key,
118 [&](HidlWeaverReadStatus s, HidlWeaverReadResponse r) {
119 callbackCalled = true;
120 status = s;
121 value = r.value;
122 timeout = r.timeout;
123 });
124 if (!ret.isOk() || !callbackCalled) {
125 return ::ndk::ScopedAStatus::fromStatus(STATUS_FAILED_TRANSACTION);
126 }
127 switch (status) {
128 case HidlWeaverReadStatus::OK:
129 _aidl_return->status = WeaverReadStatus::OK;
130 break;
131 case HidlWeaverReadStatus::FAILED:
132 _aidl_return->status = WeaverReadStatus::FAILED;
133 break;
134 case HidlWeaverReadStatus::INCORRECT_KEY:
135 _aidl_return->status = WeaverReadStatus::INCORRECT_KEY;
136 break;
137 case HidlWeaverReadStatus::THROTTLE:
138 _aidl_return->status = WeaverReadStatus::THROTTLE;
139 break;
140 default:
141 ADD_FAILURE() << "Unknown HIDL read status: " << static_cast<uint32_t>(status);
142 _aidl_return->status = WeaverReadStatus::FAILED;
143 break;
144 }
145 _aidl_return->value = value;
146 _aidl_return->timeout = timeout;
147 return ::ndk::ScopedAStatus::ok();
148 }
149
150 ::ndk::ScopedAStatus write(int32_t in_slotId, const std::vector<uint8_t>& in_key,
151 const std::vector<uint8_t>& in_value) {
152 auto status = hidl_weaver_->write(in_slotId, in_key, in_value);
153 switch (status) {
154 case HidlWeaverStatus::OK:
155 return ::ndk::ScopedAStatus::ok();
156 case HidlWeaverStatus::FAILED:
157 return ::ndk::ScopedAStatus::fromStatus(STATUS_FAILED_TRANSACTION);
158 default:
159 ADD_FAILURE() << "Unknown HIDL write status: " << status.description();
160 return ::ndk::ScopedAStatus::fromStatus(STATUS_FAILED_TRANSACTION);
161 }
162 }
163
164 private:
165 android::sp<HidlIWeaver> hidl_weaver_;
166};
167
168class WeaverTest : public ::testing::TestWithParam<std::tuple<std::string, std::string>> {
169 protected:
170 void SetUp() override;
171 void TearDown() override {}
Eric Biggers31380e72023-07-18 02:34:00 +0000172 void FindFreeSlots();
Eric Biggersb59654f2023-07-18 02:33:59 +0000173
Eric Biggers961a1382023-07-18 02:34:00 +0000174 std::unique_ptr<WeaverAdapter> weaver_;
175 WeaverConfig config_;
Eric Biggers31380e72023-07-18 02:34:00 +0000176 uint32_t first_free_slot_;
177 uint32_t last_free_slot_;
Eric Biggersb59654f2023-07-18 02:33:59 +0000178};
179
180void WeaverTest::SetUp() {
181 std::string api, instance_name;
182 std::tie(api, instance_name) = GetParam();
183 if (api == "hidl") {
Eric Biggers961a1382023-07-18 02:34:00 +0000184 weaver_.reset(new WeaverHidlAdapter(instance_name));
Eric Biggersb59654f2023-07-18 02:33:59 +0000185 } else if (api == "aidl") {
Eric Biggers961a1382023-07-18 02:34:00 +0000186 weaver_.reset(new WeaverAidlAdapter(instance_name));
Eric Biggersb59654f2023-07-18 02:33:59 +0000187 } else {
188 FAIL() << "Bad test parameterization";
189 }
Eric Biggers961a1382023-07-18 02:34:00 +0000190 ASSERT_TRUE(weaver_->isReady());
191
192 auto ret = weaver_->getConfig(&config_);
193 ASSERT_TRUE(ret.isOk());
194 ASSERT_GT(config_.slots, 0);
195 GTEST_LOG_(INFO) << "WeaverConfig: slots=" << config_.slots << ", keySize=" << config_.keySize
196 << ", valueSize=" << config_.valueSize;
Eric Biggers31380e72023-07-18 02:34:00 +0000197
198 FindFreeSlots();
199 GTEST_LOG_(INFO) << "First free slot is " << first_free_slot_ << ", last free slot is "
200 << last_free_slot_;
201}
202
203void WeaverTest::FindFreeSlots() {
204 // Determine which Weaver slots are in use by the system. These slots can't be used by the test.
205 std::set<uint32_t> used_slots;
206 if (access(kSlotMapFile.c_str(), F_OK) == 0) {
207 std::string contents;
208 ASSERT_TRUE(android::base::ReadFileToString(kSlotMapFile, &contents))
209 << "Failed to read " << kSlotMapFile;
210 for (const auto& line : android::base::Split(contents, "\n")) {
211 auto trimmed_line = android::base::Trim(line);
212 if (trimmed_line[0] == '#' || trimmed_line[0] == '\0') continue;
213 auto slot_and_user = android::base::Split(trimmed_line, "=");
214 uint32_t slot;
215 ASSERT_TRUE(slot_and_user.size() == 2 &&
216 android::base::ParseUint(slot_and_user[0], &slot))
217 << "Error parsing " << kSlotMapFile << " at \"" << line << "\"";
218 GTEST_LOG_(INFO) << "Slot " << slot << " is in use by " << slot_and_user[1];
219 ASSERT_LT(slot, config_.slots);
220 used_slots.insert(slot);
221 }
222 }
223 // Starting in Android 14, the system will always use at least one Weaver slot if Weaver is
224 // supported at all. Make sure we saw at least one.
225 // TODO: uncomment after Android 14 is merged into AOSP
226 // ASSERT_FALSE(used_slots.empty())
227 //<< "Could not determine which Weaver slots are in use by the system";
228
229 // Find the first free slot.
230 int found = 0;
231 for (uint32_t i = 0; i < config_.slots; i++) {
232 if (used_slots.find(i) == used_slots.end()) {
233 first_free_slot_ = i;
234 found++;
235 break;
236 }
237 }
238 // Find the last free slot.
239 for (uint32_t i = config_.slots; i > 0; i--) {
240 if (used_slots.find(i - 1) == used_slots.end()) {
241 last_free_slot_ = i - 1;
242 found++;
243 break;
244 }
245 }
246 ASSERT_EQ(found, 2) << "All Weaver slots are already in use by the system";
Eric Biggersb59654f2023-07-18 02:33:59 +0000247}
248
ChengYou Ho10f8a482021-01-02 22:45:32 +0800249/*
250 * Checks config values are suitably large
251 */
Eric Biggersb59654f2023-07-18 02:33:59 +0000252TEST_P(WeaverTest, GetConfig) {
Eric Biggers961a1382023-07-18 02:34:00 +0000253 EXPECT_GE(config_.slots, 16u);
254 EXPECT_GE(config_.keySize, 16u);
255 EXPECT_GE(config_.valueSize, 16u);
ChengYou Ho10f8a482021-01-02 22:45:32 +0800256}
257
258/*
259 * Gets the config twice and checks they are the same
260 */
Eric Biggersb59654f2023-07-18 02:33:59 +0000261TEST_P(WeaverTest, GettingConfigMultipleTimesGivesSameResult) {
ChengYou Ho10f8a482021-01-02 22:45:32 +0800262 WeaverConfig config2;
263
Eric Biggers961a1382023-07-18 02:34:00 +0000264 auto ret = weaver_->getConfig(&config2);
ChengYou Ho10f8a482021-01-02 22:45:32 +0800265 ASSERT_TRUE(ret.isOk());
266
Eric Biggers961a1382023-07-18 02:34:00 +0000267 EXPECT_EQ(config_, config2);
ChengYou Ho10f8a482021-01-02 22:45:32 +0800268}
269
270/*
Eric Biggers31380e72023-07-18 02:34:00 +0000271 * Writes a key and value to the last free slot
ChengYou Ho10f8a482021-01-02 22:45:32 +0800272 */
Eric Biggersb59654f2023-07-18 02:33:59 +0000273TEST_P(WeaverTest, WriteToLastSlot) {
Eric Biggers31380e72023-07-18 02:34:00 +0000274 const auto writeRet = weaver_->write(last_free_slot_, KEY, VALUE);
ChengYou Ho10f8a482021-01-02 22:45:32 +0800275 ASSERT_TRUE(writeRet.isOk());
276}
277
278/*
279 * Writes a key and value to a slot
280 * Reads the slot with the same key and receives the value that was previously written
281 */
Eric Biggersb59654f2023-07-18 02:33:59 +0000282TEST_P(WeaverTest, WriteFollowedByReadGivesTheSameValue) {
Eric Biggers31380e72023-07-18 02:34:00 +0000283 const uint32_t slotId = first_free_slot_;
Eric Biggers961a1382023-07-18 02:34:00 +0000284 const auto ret = weaver_->write(slotId, KEY, VALUE);
ChengYou Ho10f8a482021-01-02 22:45:32 +0800285 ASSERT_TRUE(ret.isOk());
286
287 WeaverReadResponse response;
Eric Biggers961a1382023-07-18 02:34:00 +0000288 const auto readRet = weaver_->read(slotId, KEY, &response);
ChengYou Ho10f8a482021-01-02 22:45:32 +0800289 ASSERT_TRUE(readRet.isOk());
Eric Biggers961a1382023-07-18 02:34:00 +0000290 EXPECT_EQ(response.value, VALUE);
291 EXPECT_EQ(response.timeout, 0u);
292 EXPECT_EQ(response.status, WeaverReadStatus::OK);
ChengYou Ho10f8a482021-01-02 22:45:32 +0800293}
294
295/*
296 * Writes a key and value to a slot
297 * Overwrites the slot with a new key and value
298 * Reads the slot with the new key and receives the new value
299 */
Eric Biggersb59654f2023-07-18 02:33:59 +0000300TEST_P(WeaverTest, OverwritingSlotUpdatesTheValue) {
Eric Biggers31380e72023-07-18 02:34:00 +0000301 const uint32_t slotId = first_free_slot_;
Eric Biggers961a1382023-07-18 02:34:00 +0000302 const auto initialWriteRet = weaver_->write(slotId, WRONG_KEY, VALUE);
ChengYou Ho10f8a482021-01-02 22:45:32 +0800303 ASSERT_TRUE(initialWriteRet.isOk());
304
Eric Biggers961a1382023-07-18 02:34:00 +0000305 const auto overwriteRet = weaver_->write(slotId, KEY, OTHER_VALUE);
ChengYou Ho10f8a482021-01-02 22:45:32 +0800306 ASSERT_TRUE(overwriteRet.isOk());
307
308 WeaverReadResponse response;
Eric Biggers961a1382023-07-18 02:34:00 +0000309 const auto readRet = weaver_->read(slotId, KEY, &response);
ChengYou Ho10f8a482021-01-02 22:45:32 +0800310 ASSERT_TRUE(readRet.isOk());
Eric Biggers961a1382023-07-18 02:34:00 +0000311 EXPECT_EQ(response.value, OTHER_VALUE);
312 EXPECT_EQ(response.timeout, 0u);
313 EXPECT_EQ(response.status, WeaverReadStatus::OK);
ChengYou Ho10f8a482021-01-02 22:45:32 +0800314}
315
316/*
317 * Writes a key and value to a slot
318 * Reads the slot with a different key so does not receive the value
319 */
Eric Biggersb59654f2023-07-18 02:33:59 +0000320TEST_P(WeaverTest, WriteFollowedByReadWithWrongKeyDoesNotGiveTheValue) {
Eric Biggers31380e72023-07-18 02:34:00 +0000321 const uint32_t slotId = first_free_slot_;
Eric Biggers961a1382023-07-18 02:34:00 +0000322 const auto writeRet = weaver_->write(slotId, KEY, VALUE);
323 ASSERT_TRUE(writeRet.isOk());
ChengYou Ho10f8a482021-01-02 22:45:32 +0800324
325 WeaverReadResponse response;
Eric Biggers961a1382023-07-18 02:34:00 +0000326 const auto readRet = weaver_->read(slotId, WRONG_KEY, &response);
ChengYou Ho20c47b42022-11-30 17:51:17 +0000327 ASSERT_TRUE(readRet.isOk());
Eric Biggers961a1382023-07-18 02:34:00 +0000328 EXPECT_TRUE(response.value.empty());
329 EXPECT_EQ(response.status, WeaverReadStatus::INCORRECT_KEY);
ChengYou Ho10f8a482021-01-02 22:45:32 +0800330}
331
332/*
333 * Writing to an invalid slot fails
334 */
Eric Biggersb59654f2023-07-18 02:33:59 +0000335TEST_P(WeaverTest, WritingToInvalidSlotFails) {
Eric Biggers961a1382023-07-18 02:34:00 +0000336 if (config_.slots == std::numeric_limits<uint32_t>::max()) {
ChengYou Ho10f8a482021-01-02 22:45:32 +0800337 // If there are no invalid slots then pass
338 return;
339 }
340
Eric Biggers961a1382023-07-18 02:34:00 +0000341 const auto writeRet = weaver_->write(config_.slots, KEY, VALUE);
ChengYou Ho10f8a482021-01-02 22:45:32 +0800342 ASSERT_FALSE(writeRet.isOk());
343}
344
345/*
346 * Reading from an invalid slot fails rather than incorrect key
347 */
Eric Biggersb59654f2023-07-18 02:33:59 +0000348TEST_P(WeaverTest, ReadingFromInvalidSlotFails) {
Eric Biggers961a1382023-07-18 02:34:00 +0000349 if (config_.slots == std::numeric_limits<uint32_t>::max()) {
ChengYou Ho10f8a482021-01-02 22:45:32 +0800350 // If there are no invalid slots then pass
351 return;
352 }
353
354 WeaverReadResponse response;
Eric Biggers961a1382023-07-18 02:34:00 +0000355 const auto readRet = weaver_->read(config_.slots, KEY, &response);
ChengYou Ho20c47b42022-11-30 17:51:17 +0000356 ASSERT_TRUE(readRet.isOk());
Eric Biggers961a1382023-07-18 02:34:00 +0000357 EXPECT_TRUE(response.value.empty());
358 EXPECT_EQ(response.timeout, 0u);
359 EXPECT_EQ(response.status, WeaverReadStatus::FAILED);
ChengYou Ho10f8a482021-01-02 22:45:32 +0800360}
361
362/*
363 * Writing a key that is too large fails
364 */
Eric Biggersb59654f2023-07-18 02:33:59 +0000365TEST_P(WeaverTest, WriteWithTooLargeKeyFails) {
Eric Biggers961a1382023-07-18 02:34:00 +0000366 std::vector<uint8_t> bigKey(config_.keySize + 1);
ChengYou Ho10f8a482021-01-02 22:45:32 +0800367
Eric Biggers31380e72023-07-18 02:34:00 +0000368 const auto writeRet = weaver_->write(first_free_slot_, bigKey, VALUE);
ChengYou Ho10f8a482021-01-02 22:45:32 +0800369 ASSERT_FALSE(writeRet.isOk());
370}
371
372/*
373 * Writing a value that is too large fails
374 */
Eric Biggersb59654f2023-07-18 02:33:59 +0000375TEST_P(WeaverTest, WriteWithTooLargeValueFails) {
Eric Biggers961a1382023-07-18 02:34:00 +0000376 std::vector<uint8_t> bigValue(config_.valueSize + 1);
ChengYou Ho10f8a482021-01-02 22:45:32 +0800377
Eric Biggers31380e72023-07-18 02:34:00 +0000378 const auto writeRet = weaver_->write(first_free_slot_, KEY, bigValue);
ChengYou Ho10f8a482021-01-02 22:45:32 +0800379 ASSERT_FALSE(writeRet.isOk());
380}
381
382/*
Eric Biggers961a1382023-07-18 02:34:00 +0000383 * Reading with a key that is too large fails
ChengYou Ho10f8a482021-01-02 22:45:32 +0800384 */
Eric Biggersb59654f2023-07-18 02:33:59 +0000385TEST_P(WeaverTest, ReadWithTooLargeKeyFails) {
Eric Biggers961a1382023-07-18 02:34:00 +0000386 std::vector<uint8_t> bigKey(config_.keySize + 1);
ChengYou Ho10f8a482021-01-02 22:45:32 +0800387
ChengYou Ho10f8a482021-01-02 22:45:32 +0800388 WeaverReadResponse response;
Eric Biggers31380e72023-07-18 02:34:00 +0000389 const auto readRet = weaver_->read(first_free_slot_, bigKey, &response);
ChengYou Ho20c47b42022-11-30 17:51:17 +0000390 ASSERT_TRUE(readRet.isOk());
Eric Biggers961a1382023-07-18 02:34:00 +0000391 EXPECT_TRUE(response.value.empty());
392 EXPECT_EQ(response.timeout, 0u);
393 EXPECT_EQ(response.status, WeaverReadStatus::FAILED);
ChengYou Ho10f8a482021-01-02 22:45:32 +0800394}
395
Eric Biggersb59654f2023-07-18 02:33:59 +0000396// Instantiate the test for each HIDL Weaver service.
ChengYou Ho10f8a482021-01-02 22:45:32 +0800397INSTANTIATE_TEST_SUITE_P(
Eric Biggersb59654f2023-07-18 02:33:59 +0000398 PerHidlInstance, WeaverTest,
399 testing::Combine(testing::Values("hidl"),
400 testing::ValuesIn(android::hardware::getAllHalInstanceNames(
401 HidlIWeaver::descriptor))),
402 [](const testing::TestParamInfo<std::tuple<std::string, std::string>>& info) {
403 return android::hardware::PrintInstanceNameToString(
404 testing::TestParamInfo<std::string>{std::get<1>(info.param), info.index});
405 });
406
407// Instantiate the test for each AIDL Weaver service.
408INSTANTIATE_TEST_SUITE_P(
409 PerAidlInstance, WeaverTest,
410 testing::Combine(testing::Values("aidl"),
411 testing::ValuesIn(android::getAidlHalInstanceNames(IWeaver::descriptor))),
412 [](const testing::TestParamInfo<std::tuple<std::string, std::string>>& info) {
413 // This name_generator makes the instance name be included in the test case names, e.g.
414 // "PerAidlInstance/WeaverTest#GetConfig/0_android_hardware_weaver_IWeaver_default"
415 // instead of "PerAidlInstance/WeaverTest#GetConfig/0".
416 return android::PrintInstanceNameToString(
417 testing::TestParamInfo<std::string>{std::get<1>(info.param), info.index});
418 });
ChengYou Ho10f8a482021-01-02 22:45:32 +0800419
420int main(int argc, char** argv) {
421 ::testing::InitGoogleTest(&argc, argv);
422 ABinderProcess_setThreadPoolMaxThreadCount(1);
423 ABinderProcess_startThreadPool();
424 return RUN_ALL_TESTS();
425}