summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Hall2017-02-12 18:32:39 -0600
committerJesse Hall2017-02-23 20:44:50 -0600
commit836661616fcf4bc023b192d1c320f0727a9dfef9 (patch)
tree49e82464c7eca7aa4774f45ae099918ddb66d0e9 /libsync/tests
parent89530820d7f5837f00f3f04e18dfa05c7506eb68 (diff)
downloadplatform-system-core-836661616fcf4bc023b192d1c320f0727a9dfef9.tar.gz
platform-system-core-836661616fcf4bc023b192d1c320f0727a9dfef9.tar.xz
platform-system-core-836661616fcf4bc023b192d1c320f0727a9dfef9.zip
sync: implement sync_file_info
Also modifies sync-unit-test to use sync_file_info instead of the deprecated sync_fence_info, but check that they match in several tests. Bug: 35138793 Test: sync-unit-tests on bullhead Change-Id: Ic672d1c89798435a8b71469500e82c770a66bf4d
Diffstat (limited to 'libsync/tests')
-rw-r--r--libsync/tests/sync_test.cpp55
1 files changed, 47 insertions, 8 deletions
diff --git a/libsync/tests/sync_test.cpp b/libsync/tests/sync_test.cpp
index 401aaeee5..7770fcb3a 100644
--- a/libsync/tests/sync_test.cpp
+++ b/libsync/tests/sync_test.cpp
@@ -172,20 +172,20 @@ public:
172 return sync_wait(m_fd, timeout); 172 return sync_wait(m_fd, timeout);
173 } 173 }
174 vector<SyncPointInfo> getInfo() const { 174 vector<SyncPointInfo> getInfo() const {
175 struct sync_pt_info *pointInfo = nullptr;
176 vector<SyncPointInfo> fenceInfo; 175 vector<SyncPointInfo> fenceInfo;
177 sync_fence_info_data *info = sync_fence_info(getFd()); 176 struct sync_file_info *info = sync_file_info(getFd());
178 if (!info) { 177 if (!info) {
179 return fenceInfo; 178 return fenceInfo;
180 } 179 }
181 while ((pointInfo = sync_pt_info(info, pointInfo))) { 180 const auto fences = sync_get_fence_info(info);
181 for (uint32_t i = 0; i < info->num_fences; i++) {
182 fenceInfo.push_back(SyncPointInfo{ 182 fenceInfo.push_back(SyncPointInfo{
183 pointInfo->driver_name, 183 fences[i].driver_name,
184 pointInfo->obj_name, 184 fences[i].obj_name,
185 pointInfo->timestamp_ns, 185 fences[i].timestamp_ns,
186 pointInfo->status}); 186 fences[i].status});
187 } 187 }
188 sync_fence_info_free(info); 188 sync_file_info_free(info);
189 return fenceInfo; 189 return fenceInfo;
190 } 190 }
191 int getSize() const { 191 int getSize() const {
@@ -212,6 +212,32 @@ private:
212 } 212 }
213}; 213};
214 214
215static void CheckModernLegacyInfoMatch(const SyncFence& f) {
216 struct sync_file_info* modern = sync_file_info(f.getFd());
217 struct sync_fence_info_data* legacy = sync_fence_info(f.getFd());
218
219 ASSERT_TRUE(modern != NULL);
220 ASSERT_TRUE(legacy != NULL);
221
222 EXPECT_STREQ(modern->name, legacy->name);
223 EXPECT_EQ(modern->status, legacy->status);
224
225 uint32_t fenceIdx = 0;
226 struct sync_pt_info* pt = sync_pt_info(legacy, NULL);
227 const struct sync_fence_info* fences = sync_get_fence_info(modern);
228 while (fenceIdx < modern->num_fences && pt != NULL) {
229 EXPECT_STREQ(fences[fenceIdx].obj_name, pt->obj_name);
230 EXPECT_STREQ(fences[fenceIdx].driver_name, pt->driver_name);
231 EXPECT_EQ(fences[fenceIdx].status, pt->status);
232 EXPECT_EQ(fences[fenceIdx].timestamp_ns, pt->timestamp_ns);
233
234 fenceIdx++;
235 pt = sync_pt_info(legacy, pt);
236 }
237 EXPECT_EQ(fenceIdx, modern->num_fences);
238 EXPECT_EQ(NULL, pt);
239}
240
215int SyncFence::s_fenceCount = 0; 241int SyncFence::s_fenceCount = 0;
216 242
217TEST(AllocTest, Timeline) { 243TEST(AllocTest, Timeline) {
@@ -225,6 +251,7 @@ TEST(AllocTest, Fence) {
225 251
226 SyncFence fence(timeline, 1); 252 SyncFence fence(timeline, 1);
227 ASSERT_TRUE(fence.isValid()); 253 ASSERT_TRUE(fence.isValid());
254 CheckModernLegacyInfoMatch(fence);
228} 255}
229 256
230TEST(AllocTest, FenceNegative) { 257TEST(AllocTest, FenceNegative) {
@@ -321,15 +348,21 @@ TEST(FenceTest, OneTimelineMerge) {
321 timeline.inc(1); 348 timeline.inc(1);
322 ASSERT_EQ(a.getSignaledCount(), 1); 349 ASSERT_EQ(a.getSignaledCount(), 1);
323 ASSERT_EQ(d.getActiveCount(), 1); 350 ASSERT_EQ(d.getActiveCount(), 1);
351 CheckModernLegacyInfoMatch(a);
352 CheckModernLegacyInfoMatch(d);
324 353
325 timeline.inc(1); 354 timeline.inc(1);
326 ASSERT_EQ(b.getSignaledCount(), 1); 355 ASSERT_EQ(b.getSignaledCount(), 1);
327 ASSERT_EQ(d.getActiveCount(), 1); 356 ASSERT_EQ(d.getActiveCount(), 1);
357 CheckModernLegacyInfoMatch(b);
358 CheckModernLegacyInfoMatch(d);
328 359
329 timeline.inc(1); 360 timeline.inc(1);
330 ASSERT_EQ(c.getSignaledCount(), 1); 361 ASSERT_EQ(c.getSignaledCount(), 1);
331 ASSERT_EQ(d.getActiveCount(), 0); 362 ASSERT_EQ(d.getActiveCount(), 0);
332 ASSERT_EQ(d.getSignaledCount(), 1); 363 ASSERT_EQ(d.getSignaledCount(), 1);
364 CheckModernLegacyInfoMatch(c);
365 CheckModernLegacyInfoMatch(d);
333} 366}
334 367
335TEST(FenceTest, MergeSameFence) { 368TEST(FenceTest, MergeSameFence) {
@@ -343,9 +376,11 @@ TEST(FenceTest, MergeSameFence) {
343 ASSERT_TRUE(selfMergeFence.isValid()); 376 ASSERT_TRUE(selfMergeFence.isValid());
344 377
345 ASSERT_EQ(selfMergeFence.getSignaledCount(), 0); 378 ASSERT_EQ(selfMergeFence.getSignaledCount(), 0);
379 CheckModernLegacyInfoMatch(selfMergeFence);
346 380
347 timeline.inc(5); 381 timeline.inc(5);
348 ASSERT_EQ(selfMergeFence.getSignaledCount(), 1); 382 ASSERT_EQ(selfMergeFence.getSignaledCount(), 1);
383 CheckModernLegacyInfoMatch(selfMergeFence);
349} 384}
350 385
351TEST(FenceTest, PollOnDestroyedTimeline) { 386TEST(FenceTest, PollOnDestroyedTimeline) {
@@ -397,14 +432,17 @@ TEST(FenceTest, MultiTimelineWait) {
397 timelineA.inc(5); 432 timelineA.inc(5);
398 ASSERT_EQ(mergedFence.getActiveCount(), 2); 433 ASSERT_EQ(mergedFence.getActiveCount(), 2);
399 ASSERT_EQ(mergedFence.getSignaledCount(), 1); 434 ASSERT_EQ(mergedFence.getSignaledCount(), 1);
435 CheckModernLegacyInfoMatch(mergedFence);
400 436
401 timelineB.inc(5); 437 timelineB.inc(5);
402 ASSERT_EQ(mergedFence.getActiveCount(), 1); 438 ASSERT_EQ(mergedFence.getActiveCount(), 1);
403 ASSERT_EQ(mergedFence.getSignaledCount(), 2); 439 ASSERT_EQ(mergedFence.getSignaledCount(), 2);
440 CheckModernLegacyInfoMatch(mergedFence);
404 441
405 timelineC.inc(5); 442 timelineC.inc(5);
406 ASSERT_EQ(mergedFence.getActiveCount(), 0); 443 ASSERT_EQ(mergedFence.getActiveCount(), 0);
407 ASSERT_EQ(mergedFence.getSignaledCount(), 3); 444 ASSERT_EQ(mergedFence.getSignaledCount(), 3);
445 CheckModernLegacyInfoMatch(mergedFence);
408 446
409 // confirm you can successfully wait. 447 // confirm you can successfully wait.
410 ASSERT_EQ(mergedFence.wait(100), 0); 448 ASSERT_EQ(mergedFence.wait(100), 0);
@@ -560,6 +598,7 @@ TEST_P(MergeStressTest, RandomMerge) {
560 // Merge. 598 // Merge.
561 fence = SyncFence(fence, SyncFence(timeline, syncPoint)); 599 fence = SyncFence(fence, SyncFence(timeline, syncPoint));
562 ASSERT_TRUE(fence.isValid()); 600 ASSERT_TRUE(fence.isValid());
601 CheckModernLegacyInfoMatch(fence);
563 } 602 }
564 603
565 // Confirm our map matches the fence. 604 // Confirm our map matches the fence.