18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * sync fence merge tests 38c2ecf20Sopenharmony_ci * Copyright 2015-2016 Collabora Ltd. 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Based on the implementation from the Android Open Source Project, 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * Copyright 2012 Google, Inc 88c2ecf20Sopenharmony_ci * 98c2ecf20Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 108c2ecf20Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 118c2ecf20Sopenharmony_ci * to deal in the Software without restriction, including without limitation 128c2ecf20Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense, 138c2ecf20Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 148c2ecf20Sopenharmony_ci * Software is furnished to do so, subject to the following conditions: 158c2ecf20Sopenharmony_ci * 168c2ecf20Sopenharmony_ci * The above copyright notice and this permission notice shall be included in 178c2ecf20Sopenharmony_ci * all copies or substantial portions of the Software. 188c2ecf20Sopenharmony_ci * 198c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 208c2ecf20Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 218c2ecf20Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 228c2ecf20Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 238c2ecf20Sopenharmony_ci * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 248c2ecf20Sopenharmony_ci * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 258c2ecf20Sopenharmony_ci * OTHER DEALINGS IN THE SOFTWARE. 268c2ecf20Sopenharmony_ci */ 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci#include "sync.h" 298c2ecf20Sopenharmony_ci#include "sw_sync.h" 308c2ecf20Sopenharmony_ci#include "synctest.h" 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ciint test_fence_merge_same_fence(void) 338c2ecf20Sopenharmony_ci{ 348c2ecf20Sopenharmony_ci int fence, valid, merged; 358c2ecf20Sopenharmony_ci int timeline = sw_sync_timeline_create(); 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci valid = sw_sync_timeline_is_valid(timeline); 388c2ecf20Sopenharmony_ci ASSERT(valid, "Failure allocating timeline\n"); 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ci fence = sw_sync_fence_create(timeline, "allocFence", 5); 418c2ecf20Sopenharmony_ci valid = sw_sync_fence_is_valid(fence); 428c2ecf20Sopenharmony_ci ASSERT(valid, "Failure allocating fence\n"); 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ci merged = sync_merge("mergeFence", fence, fence); 458c2ecf20Sopenharmony_ci valid = sw_sync_fence_is_valid(fence); 468c2ecf20Sopenharmony_ci ASSERT(valid, "Failure merging fence\n"); 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_ci ASSERT(sync_fence_count_with_status(merged, FENCE_STATUS_SIGNALED) == 0, 498c2ecf20Sopenharmony_ci "fence signaled too early!\n"); 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ci sw_sync_timeline_inc(timeline, 5); 528c2ecf20Sopenharmony_ci ASSERT(sync_fence_count_with_status(merged, FENCE_STATUS_SIGNALED) == 1, 538c2ecf20Sopenharmony_ci "fence did not signal!\n"); 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_ci sw_sync_fence_destroy(merged); 568c2ecf20Sopenharmony_ci sw_sync_fence_destroy(fence); 578c2ecf20Sopenharmony_ci sw_sync_timeline_destroy(timeline); 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ci return 0; 608c2ecf20Sopenharmony_ci} 61