Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  *  sync fence merge tests
0003  *  Copyright 2015-2016 Collabora Ltd.
0004  *
0005  *  Based on the implementation from the Android Open Source Project,
0006  *
0007  *  Copyright 2012 Google, Inc
0008  *
0009  *  Permission is hereby granted, free of charge, to any person obtaining a
0010  *  copy of this software and associated documentation files (the "Software"),
0011  *  to deal in the Software without restriction, including without limitation
0012  *  the rights to use, copy, modify, merge, publish, distribute, sublicense,
0013  *  and/or sell copies of the Software, and to permit persons to whom the
0014  *  Software is furnished to do so, subject to the following conditions:
0015  *
0016  *  The above copyright notice and this permission notice shall be included in
0017  *  all copies or substantial portions of the Software.
0018  *
0019  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0020  *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0021  *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
0022  *  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
0023  *  OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
0024  *  ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
0025  *  OTHER DEALINGS IN THE SOFTWARE.
0026  */
0027 
0028 #include "sync.h"
0029 #include "sw_sync.h"
0030 #include "synctest.h"
0031 
0032 int test_fence_merge_same_fence(void)
0033 {
0034     int fence, valid, merged;
0035     int timeline = sw_sync_timeline_create();
0036 
0037     valid = sw_sync_timeline_is_valid(timeline);
0038     ASSERT(valid, "Failure allocating timeline\n");
0039 
0040     fence = sw_sync_fence_create(timeline, "allocFence", 5);
0041     valid = sw_sync_fence_is_valid(fence);
0042     ASSERT(valid, "Failure allocating fence\n");
0043 
0044     merged = sync_merge("mergeFence", fence, fence);
0045     valid = sw_sync_fence_is_valid(fence);
0046     ASSERT(valid, "Failure merging fence\n");
0047 
0048     ASSERT(sync_fence_count_with_status(merged, FENCE_STATUS_SIGNALED) == 0,
0049            "fence signaled too early!\n");
0050 
0051     sw_sync_timeline_inc(timeline, 5);
0052     ASSERT(sync_fence_count_with_status(merged, FENCE_STATUS_SIGNALED) == 1,
0053            "fence did not signal!\n");
0054 
0055     sw_sync_fence_destroy(merged);
0056     sw_sync_fence_destroy(fence);
0057     sw_sync_timeline_destroy(timeline);
0058 
0059     return 0;
0060 }