1 /*
2 * Copyright (C) 2018 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 #include <errno.h>
18 #include <sys/types.h>
19 #include <sys/socket.h>
20 #include <sys/un.h>
21 #include <unistd.h>
22
23 #include <limits>
24 #include <sstream>
25 #include <string>
26
27 #include <android/hardware_buffer.h>
28 #include <android/log.h>
29 #include <gtest/gtest.h>
30 #include <gmock/gmock.h>
31
32 //#define LOG_NDEBUG 0
33
34 #define BAD_VALUE -EINVAL
35 #define INVALID_OPERATION -ENOSYS
36 #define NO_ERROR 0
37
38 #define LOG_TAG "AHBTest"
39 #define ALOGI(...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)
40
41 namespace {
42
43 using testing::AnyOf;
44 using testing::Eq;
45
46 #define FORMAT_CASE(x) case AHARDWAREBUFFER_FORMAT_ ## x: os << #x ; break
47
PrintAhbFormat(std::ostream & os,uint64_t format)48 void PrintAhbFormat(std::ostream& os, uint64_t format) {
49 switch (format) {
50 FORMAT_CASE(R8G8B8A8_UNORM);
51 FORMAT_CASE(R8G8B8X8_UNORM);
52 FORMAT_CASE(R8G8B8_UNORM);
53 FORMAT_CASE(R5G6B5_UNORM);
54 FORMAT_CASE(R16G16B16A16_FLOAT);
55 FORMAT_CASE(R10G10B10A2_UNORM);
56 FORMAT_CASE(BLOB);
57 FORMAT_CASE(D16_UNORM);
58 FORMAT_CASE(D24_UNORM);
59 FORMAT_CASE(D24_UNORM_S8_UINT);
60 FORMAT_CASE(D32_FLOAT);
61 FORMAT_CASE(D32_FLOAT_S8_UINT);
62 FORMAT_CASE(S8_UINT);
63 default: os << "unknown"; break;
64 }
65 }
66
67 #define BITS_CASE(x) case AHARDWAREBUFFER_USAGE_ ## x: os << #x ; break
68 #define PRINT_FLAG(x) \
69 do { if (usage & AHARDWAREBUFFER_USAGE_ ## x) { os << #x << " "; } } while (0)
70
PrintAhbUsage(std::ostream & os,uint64_t usage)71 void PrintAhbUsage(std::ostream& os, uint64_t usage) {
72 if (usage == 0) {
73 os << "none";
74 return;
75 }
76 switch (usage & AHARDWAREBUFFER_USAGE_CPU_READ_MASK) {
77 BITS_CASE(CPU_READ_NEVER);
78 BITS_CASE(CPU_READ_RARELY);
79 BITS_CASE(CPU_READ_OFTEN);
80 default: break;
81 }
82 switch (usage & AHARDWAREBUFFER_USAGE_CPU_WRITE_MASK) {
83 BITS_CASE(CPU_WRITE_NEVER);
84 BITS_CASE(CPU_WRITE_RARELY);
85 BITS_CASE(CPU_WRITE_OFTEN);
86 default: break;
87 }
88
89 PRINT_FLAG(GPU_SAMPLED_IMAGE);
90 PRINT_FLAG(GPU_COLOR_OUTPUT);
91 PRINT_FLAG(PROTECTED_CONTENT);
92 PRINT_FLAG(VIDEO_ENCODE);
93 PRINT_FLAG(SENSOR_DIRECT_DATA);
94 PRINT_FLAG(GPU_DATA_BUFFER);
95 PRINT_FLAG(GPU_CUBE_MAP);
96 PRINT_FLAG(GPU_MIPMAP_COMPLETE);
97
98 PRINT_FLAG(VENDOR_0);
99 PRINT_FLAG(VENDOR_1);
100 PRINT_FLAG(VENDOR_2);
101 PRINT_FLAG(VENDOR_3);
102 PRINT_FLAG(VENDOR_4);
103 PRINT_FLAG(VENDOR_5);
104 PRINT_FLAG(VENDOR_6);
105 PRINT_FLAG(VENDOR_7);
106 PRINT_FLAG(VENDOR_8);
107 PRINT_FLAG(VENDOR_9);
108 PRINT_FLAG(VENDOR_10);
109 PRINT_FLAG(VENDOR_11);
110 PRINT_FLAG(VENDOR_12);
111 PRINT_FLAG(VENDOR_13);
112 PRINT_FLAG(VENDOR_14);
113 PRINT_FLAG(VENDOR_15);
114 PRINT_FLAG(VENDOR_16);
115 PRINT_FLAG(VENDOR_17);
116 PRINT_FLAG(VENDOR_18);
117 PRINT_FLAG(VENDOR_19);
118 }
119
GetDescription(AHardwareBuffer * buffer)120 AHardwareBuffer_Desc GetDescription(AHardwareBuffer* buffer) {
121 AHardwareBuffer_Desc description;
122 AHardwareBuffer_describe(buffer, &description);
123 return description;
124 }
125
126 } // namespace
127
128 // GTest printer for AHardwareBuffer_Desc. Has to be in the global namespace.
PrintTo(const AHardwareBuffer_Desc & desc,::std::ostream * os)129 void PrintTo(const AHardwareBuffer_Desc& desc, ::std::ostream* os) {
130 *os << "AHardwareBuffer_Desc " << desc.width << "x" << desc.height;
131 if (desc.layers > 1) {
132 *os << ", " << desc.layers << " layers";
133 }
134 *os << ", usage = ";
135 PrintAhbUsage(*os, desc.usage);
136 *os << ", format = ";
137 PrintAhbFormat(*os, desc.format);
138 }
139
140 // Equality operators for AHardwareBuffer_Desc. Have to be in the global namespace.
operator ==(const AHardwareBuffer_Desc & a,const AHardwareBuffer_Desc & b)141 bool operator==(const AHardwareBuffer_Desc& a, const AHardwareBuffer_Desc& b) {
142 return a.width == b.width && a.height == b.height && a.layers == b.layers &&
143 a.usage == b.usage && a.format == b.format;
144 }
operator !=(const AHardwareBuffer_Desc & a,const AHardwareBuffer_Desc & b)145 bool operator!=(const AHardwareBuffer_Desc& a, const AHardwareBuffer_Desc& b) {
146 return !(a == b);
147 }
148
149 namespace android {
150
151 // Test that passing in NULL values to allocate works as expected.
TEST(AHardwareBufferTest,AllocateFailsWithNullInput)152 TEST(AHardwareBufferTest, AllocateFailsWithNullInput) {
153 AHardwareBuffer* buffer;
154 AHardwareBuffer_Desc desc;
155
156 memset(&desc, 0, sizeof(AHardwareBuffer_Desc));
157
158 int res = AHardwareBuffer_allocate(&desc, NULL);
159 EXPECT_EQ(BAD_VALUE, res);
160 res = AHardwareBuffer_allocate(NULL, &buffer);
161 EXPECT_EQ(BAD_VALUE, res);
162 res = AHardwareBuffer_allocate(NULL, NULL);
163 EXPECT_EQ(BAD_VALUE, res);
164 }
165
166 // Test that passing in NULL values to allocate works as expected.
TEST(AHardwareBufferTest,BlobFormatRequiresHeight1)167 TEST(AHardwareBufferTest, BlobFormatRequiresHeight1) {
168 AHardwareBuffer* buffer;
169 AHardwareBuffer_Desc desc = {};
170
171 desc.width = 2;
172 desc.height = 4;
173 desc.layers = 1;
174 desc.usage = AHARDWAREBUFFER_USAGE_CPU_READ_RARELY;
175 desc.format = AHARDWAREBUFFER_FORMAT_BLOB;
176 int res = AHardwareBuffer_allocate(&desc, &buffer);
177 EXPECT_EQ(BAD_VALUE, res);
178
179 desc.height = 1;
180 res = AHardwareBuffer_allocate(&desc, &buffer);
181 EXPECT_EQ(NO_ERROR, res);
182 EXPECT_EQ(desc, GetDescription(buffer));
183 AHardwareBuffer_release(buffer);
184 buffer = NULL;
185 }
186
187 // Test that allocate can create an AHardwareBuffer correctly.
TEST(AHardwareBufferTest,AllocateSucceeds)188 TEST(AHardwareBufferTest, AllocateSucceeds) {
189 AHardwareBuffer* buffer = NULL;
190 AHardwareBuffer_Desc desc = {};
191
192 desc.width = 2;
193 desc.height = 4;
194 desc.layers = 1;
195 desc.usage = AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE;
196 desc.format = AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM;
197 int res = AHardwareBuffer_allocate(&desc, &buffer);
198 EXPECT_EQ(NO_ERROR, res);
199 EXPECT_EQ(desc, GetDescription(buffer));
200 AHardwareBuffer_release(buffer);
201 buffer = NULL;
202
203 desc.width = 4;
204 desc.height = 12;
205 desc.layers = 1;
206 desc.usage = AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE;
207 desc.format = AHARDWAREBUFFER_FORMAT_R5G6B5_UNORM;
208 res = AHardwareBuffer_allocate(&desc, &buffer);
209 EXPECT_EQ(NO_ERROR, res);
210 EXPECT_EQ(desc, GetDescription(buffer));
211 AHardwareBuffer_release(buffer);
212 }
213
214 // Test that allocate can create YUV AHardwareBuffers correctly.
TEST(AHardwareBufferTest,YuvAllocateSucceeds)215 TEST(AHardwareBufferTest, YuvAllocateSucceeds) {
216 AHardwareBuffer* buffer = NULL;
217 AHardwareBuffer_Desc desc = {};
218
219 desc.width = 16;
220 desc.height = 16;
221 desc.layers = 1;
222 desc.usage = AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE;
223 desc.format = AHARDWAREBUFFER_FORMAT_Y8Cb8Cr8_420;
224 int res = AHardwareBuffer_allocate(&desc, &buffer);
225 EXPECT_EQ(NO_ERROR, res);
226 EXPECT_EQ(desc, GetDescription(buffer));
227 AHardwareBuffer_release(buffer);
228 buffer = NULL;
229 }
230
TEST(AHardwareBufferTest,DescribeSucceeds)231 TEST(AHardwareBufferTest, DescribeSucceeds) {
232 AHardwareBuffer* buffer = NULL;
233 AHardwareBuffer_Desc desc = {};
234
235 desc.width = 2;
236 desc.height = 4;
237 desc.layers = 1;
238 desc.usage = AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE;
239 desc.format = AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM;
240 int res = AHardwareBuffer_allocate(&desc, &buffer);
241 EXPECT_EQ(NO_ERROR, res);
242
243 // Description of a null buffer should be all zeros.
244 AHardwareBuffer_Desc scratch_desc;
245 memset(&scratch_desc, 0, sizeof(AHardwareBuffer_Desc));
246 AHardwareBuffer_describe(NULL, &scratch_desc);
247 EXPECT_EQ(0U, scratch_desc.width);
248 EXPECT_EQ(0U, scratch_desc.height);
249
250 // This shouldn't crash.
251 AHardwareBuffer_describe(buffer, NULL);
252
253 // Description of created buffer should match requsted description.
254 EXPECT_EQ(desc, GetDescription(buffer));
255 AHardwareBuffer_release(buffer);
256 }
257
258 struct ClientData {
259 int fd;
260 AHardwareBuffer* buffer;
ClientDataandroid::ClientData261 ClientData(int fd_in, AHardwareBuffer* buffer_in)
262 : fd(fd_in), buffer(buffer_in) {}
263 };
264
clientFunction(void * data)265 static void* clientFunction(void* data) {
266 ClientData* pdata = reinterpret_cast<ClientData*>(data);
267 int err = AHardwareBuffer_sendHandleToUnixSocket(pdata->buffer, pdata->fd);
268 EXPECT_EQ(NO_ERROR, err);
269 close(pdata->fd);
270 return 0;
271 }
272
TEST(AHardwareBufferTest,SendAndRecvSucceeds)273 TEST(AHardwareBufferTest, SendAndRecvSucceeds) {
274 AHardwareBuffer* buffer = NULL;
275 AHardwareBuffer_Desc desc = {};
276
277 desc.width = 2;
278 desc.height = 4;
279 desc.layers = 1;
280 desc.usage = AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE;
281 desc.format = AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM;
282
283 // Test that an invalid buffer fails.
284 int err = AHardwareBuffer_sendHandleToUnixSocket(NULL, 0);
285 EXPECT_EQ(BAD_VALUE, err);
286 err = 0;
287 err = AHardwareBuffer_sendHandleToUnixSocket(buffer, 0);
288 EXPECT_EQ(BAD_VALUE, err);
289
290 // Allocate the buffer.
291 err = AHardwareBuffer_allocate(&desc, &buffer);
292 EXPECT_EQ(NO_ERROR, err);
293
294 int fds[2];
295 err = socketpair(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0, fds);
296
297 // Launch a client that will send the buffer back.
298 ClientData data(fds[1], buffer);
299 pthread_t thread;
300 EXPECT_EQ(0, pthread_create(&thread, NULL, clientFunction, &data));
301
302 // Receive the buffer.
303 err = AHardwareBuffer_recvHandleFromUnixSocket(fds[0], NULL);
304 EXPECT_EQ(BAD_VALUE, err);
305
306 AHardwareBuffer* received = NULL;
307 err = AHardwareBuffer_recvHandleFromUnixSocket(fds[0], &received);
308 EXPECT_EQ(NO_ERROR, err);
309 EXPECT_TRUE(received != NULL);
310 EXPECT_EQ(desc, GetDescription(received));
311
312 void* ret_val;
313 EXPECT_EQ(0, pthread_join(thread, &ret_val));
314 EXPECT_EQ(NULL, ret_val);
315 close(fds[0]);
316
317 AHardwareBuffer_release(buffer);
318 AHardwareBuffer_release(received);
319 }
320
TEST(AHardwareBufferTest,LockAndGetInfoAndUnlockSucceed)321 TEST(AHardwareBufferTest, LockAndGetInfoAndUnlockSucceed) {
322 AHardwareBuffer* buffer = nullptr;
323 AHardwareBuffer_Desc desc = {};
324
325 desc.width = 2;
326 desc.height = 4;
327 desc.layers = 1;
328 desc.usage = AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE | AHARDWAREBUFFER_USAGE_CPU_READ_RARELY;
329 desc.format = AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM;
330
331 int32_t bytesPerPixel = std::numeric_limits<int32_t>::min();
332 int32_t bytesPerStride = std::numeric_limits<int32_t>::min();
333
334 // Test that an invalid buffer fails.
335 int err = AHardwareBuffer_lockAndGetInfo(NULL, 0, -1, NULL, NULL, &bytesPerPixel, &bytesPerStride);
336 EXPECT_EQ(BAD_VALUE, err);
337
338 err = AHardwareBuffer_allocate(&desc, &buffer);
339 EXPECT_EQ(NO_ERROR, err);
340 void* bufferData = NULL;
341
342 // Test invalid usage flag
343 err = AHardwareBuffer_lockAndGetInfo(buffer, ~(AHARDWAREBUFFER_USAGE_CPU_WRITE_MASK | AHARDWAREBUFFER_USAGE_CPU_READ_MASK), -1, NULL, &bufferData, &bytesPerPixel, &bytesPerStride);
344 EXPECT_EQ(BAD_VALUE, err);
345
346 err = AHardwareBuffer_lockAndGetInfo(buffer, AHARDWAREBUFFER_USAGE_CPU_READ_RARELY, -1, NULL, &bufferData, &bytesPerPixel, &bytesPerStride);
347
348 if (bytesPerPixel == -1 || bytesPerStride == -1) {
349 EXPECT_EQ(INVALID_OPERATION, err);
350 } else {
351 EXPECT_EQ(NO_ERROR, err);
352 EXPECT_LE(0, bytesPerPixel);
353 EXPECT_LE(0, bytesPerStride);
354 EXPECT_TRUE(bufferData != NULL);
355
356 int32_t fence = -1;
357 err = AHardwareBuffer_unlock(buffer, &fence);
358 EXPECT_EQ(NO_ERROR, err);
359 }
360 AHardwareBuffer_release(buffer);
361 }
362
TEST(AHardwareBufferTest,LockAndUnlockSucceed)363 TEST(AHardwareBufferTest, LockAndUnlockSucceed) {
364 AHardwareBuffer* buffer = NULL;
365 AHardwareBuffer_Desc desc = {};
366
367 desc.width = 2;
368 desc.height = 4;
369 desc.layers = 1;
370 desc.usage = AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE | AHARDWAREBUFFER_USAGE_CPU_READ_RARELY;
371 desc.format = AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM;
372
373 // Test that an invalid buffer fails.
374 int err = AHardwareBuffer_lock(NULL, 0, -1, NULL, NULL);
375 EXPECT_EQ(BAD_VALUE, err);
376 err = 0;
377
378 // Allocate the buffer.
379 err = AHardwareBuffer_allocate(&desc, &buffer);
380 EXPECT_EQ(NO_ERROR, err);
381 void* bufferData = NULL;
382 err = AHardwareBuffer_lock(buffer, AHARDWAREBUFFER_USAGE_CPU_READ_RARELY, -1,
383 NULL, &bufferData);
384 EXPECT_EQ(NO_ERROR, err);
385 EXPECT_TRUE(bufferData != NULL);
386 int32_t fence = -1;
387 err = AHardwareBuffer_unlock(buffer, &fence);
388
389 AHardwareBuffer_release(buffer);
390 }
391
TEST(AHardwareBufferTest,PlanarLockAndUnlockYuvSucceed)392 TEST(AHardwareBufferTest, PlanarLockAndUnlockYuvSucceed) {
393 AHardwareBuffer* buffer = NULL;
394 AHardwareBuffer_Desc desc = {};
395
396 desc.width = 16;
397 desc.height = 32;
398 desc.layers = 1;
399 desc.usage = AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE | AHARDWAREBUFFER_USAGE_CPU_READ_RARELY;
400 desc.format = AHARDWAREBUFFER_FORMAT_Y8Cb8Cr8_420;
401
402 // Test that an invalid buffer fails.
403 int err = AHardwareBuffer_lock(NULL, 0, -1, NULL, NULL);
404 EXPECT_EQ(BAD_VALUE, err);
405 err = 0;
406
407 // Allocate the buffer.
408 err = AHardwareBuffer_allocate(&desc, &buffer);
409 EXPECT_EQ(NO_ERROR, err);
410
411 // Lock its planes
412 AHardwareBuffer_Planes planes;
413 err = AHardwareBuffer_lockPlanes(buffer, AHARDWAREBUFFER_USAGE_CPU_READ_RARELY, -1, NULL,
414 &planes);
415
416 // Make sure everything looks right
417 EXPECT_EQ(NO_ERROR, err);
418 EXPECT_EQ(3U, planes.planeCount);
419
420 EXPECT_TRUE(planes.planes[0].data != NULL);
421 EXPECT_EQ(1U, planes.planes[0].pixelStride);
422 EXPECT_TRUE(planes.planes[0].rowStride >= 16);
423
424 EXPECT_TRUE(planes.planes[1].data != NULL);
425 EXPECT_THAT(planes.planes[1].pixelStride, AnyOf(Eq(1U), Eq(2U)));
426 EXPECT_TRUE(planes.planes[1].rowStride >= 8);
427
428 EXPECT_TRUE(planes.planes[2].data != NULL);
429 EXPECT_THAT(planes.planes[2].pixelStride, AnyOf(Eq(1U), Eq(2U)));
430 EXPECT_TRUE(planes.planes[2].rowStride >= 8);
431
432 // Unlock
433 int32_t fence = -1;
434 err = AHardwareBuffer_unlock(buffer, &fence);
435 EXPECT_EQ(NO_ERROR, err);
436
437 AHardwareBuffer_release(buffer);
438 }
439
TEST(AHardwareBufferTest,PlanarLockAndUnlockRgbaSucceed)440 TEST(AHardwareBufferTest, PlanarLockAndUnlockRgbaSucceed) {
441 AHardwareBuffer* buffer = NULL;
442 AHardwareBuffer_Desc desc = {};
443
444 desc.width = 16;
445 desc.height = 32;
446 desc.layers = 1;
447 desc.usage = AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE | AHARDWAREBUFFER_USAGE_CPU_READ_RARELY;
448 desc.format = AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM;
449
450 // Test that an invalid buffer fails.
451 int err = AHardwareBuffer_lock(NULL, 0, -1, NULL, NULL);
452 EXPECT_EQ(BAD_VALUE, err);
453 err = 0;
454
455 // Allocate the buffer.
456 err = AHardwareBuffer_allocate(&desc, &buffer);
457 EXPECT_EQ(NO_ERROR, err);
458
459 // Lock its planes
460 AHardwareBuffer_Planes planes;
461 err = AHardwareBuffer_lockPlanes(buffer, AHARDWAREBUFFER_USAGE_CPU_READ_RARELY, -1, NULL,
462 &planes);
463
464 // Make sure everything looks right
465 EXPECT_EQ(NO_ERROR, err);
466 EXPECT_EQ(1U, planes.planeCount);
467
468 EXPECT_TRUE(planes.planes[0].data != NULL);
469 EXPECT_EQ(4U, planes.planes[0].pixelStride);
470 EXPECT_TRUE(planes.planes[0].rowStride >= 64);
471
472 // Unlock
473 int32_t fence = -1;
474 err = AHardwareBuffer_unlock(buffer, &fence);
475 EXPECT_EQ(NO_ERROR, err);
476
477 AHardwareBuffer_release(buffer);
478 }
479
TEST(AHardwareBufferTest,ProtectedContentAndCpuReadIncompatible)480 TEST(AHardwareBufferTest, ProtectedContentAndCpuReadIncompatible) {
481 AHardwareBuffer* buffer = NULL;
482 AHardwareBuffer_Desc desc = {};
483 desc.width = 120;
484 desc.height = 240;
485 desc.layers = 1;
486 desc.usage = AHARDWAREBUFFER_USAGE_GPU_COLOR_OUTPUT | AHARDWAREBUFFER_USAGE_CPU_READ_OFTEN;
487 desc.format = AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM;
488
489 // Allocation of a CPU-readable buffer should succeed...
490 int err = AHardwareBuffer_allocate(&desc, &buffer);
491 EXPECT_EQ(NO_ERROR, err);
492 AHardwareBuffer_release(buffer);
493 buffer = nullptr;
494
495 // ...but not if it's a protected buffer.
496 desc.usage =
497 AHARDWAREBUFFER_USAGE_GPU_COLOR_OUTPUT |
498 AHARDWAREBUFFER_USAGE_CPU_READ_OFTEN |
499 AHARDWAREBUFFER_USAGE_PROTECTED_CONTENT;
500 err = AHardwareBuffer_allocate(&desc, &buffer);
501 EXPECT_NE(NO_ERROR, err);
502
503 desc.usage =
504 AHARDWAREBUFFER_USAGE_GPU_COLOR_OUTPUT |
505 AHARDWAREBUFFER_USAGE_CPU_READ_RARELY |
506 AHARDWAREBUFFER_USAGE_PROTECTED_CONTENT;
507 err = AHardwareBuffer_allocate(&desc, &buffer);
508 EXPECT_NE(NO_ERROR, err);
509 }
510
511 } // namespace android
512