diff options
author | Xusong Wang <xusongw@google.com> | 2021-06-10 17:20:43 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2021-06-10 17:20:43 +0000 |
commit | 682be89aa0fc15c23f7544e531145a4e57a9833f (patch) | |
tree | 7a14ed3f24bb27f7aa01b1cc4e9d41cdacba3bf1 | |
parent | f8d0d4850d81a189bf82a53ba5ca806feb112a10 (diff) | |
parent | 2b741abac987b31e1db8656c6b9902067ad6b084 (diff) | |
download | NeuralNetworks-682be89aa0fc15c23f7544e531145a4e57a9833f.tar.gz |
Release the sync fence ownership before AHardwareBuffer_lock. am: 2b741abac9
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/NeuralNetworks/+/14924634
Change-Id: I950f8b3fd1a27f3fad26227dc16d15d8fb6ea287
-rw-r--r-- | runtime/test/TestGpuNnapi.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/runtime/test/TestGpuNnapi.cpp b/runtime/test/TestGpuNnapi.cpp index c527d7865..730511477 100644 --- a/runtime/test/TestGpuNnapi.cpp +++ b/runtime/test/TestGpuNnapi.cpp @@ -947,18 +947,19 @@ class GpuNnapiTest : public testing::TestWithParam<NameAndDevice> { auto [nnapiSuccess, nnapiSyncFd] = nnapi->run(gpuSyncFd); ASSERT_TRUE(nnapiSuccess); - checkResults<dataType>(nnapiSyncFd); + checkResults<dataType>(std::move(nnapiSyncFd)); } } template <Type dataType> - void checkResults(const base::unique_fd& syncFd) { + void checkResults(base::unique_fd syncFd) { using ElementType = typename TestTypeHelper<dataType>::ElementType; // Lock the buffer with the sync fence + // AHardwareBuffer_lock will take the ownership and close the sync fence even on errors void* data; ASSERT_EQ(AHardwareBuffer_lock(mNnapiOutput, AHARDWAREBUFFER_USAGE_CPU_READ_OFTEN, - syncFd.get(), /*rect=*/nullptr, &data), + syncFd.release(), /*rect=*/nullptr, &data), 0); // Compare the actual results with the expect value |