Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  *  sync allocation 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_alloc_timeline(void)
0033 {
0034     int timeline, valid;
0035 
0036     timeline = sw_sync_timeline_create();
0037     valid = sw_sync_timeline_is_valid(timeline);
0038     ASSERT(valid, "Failure allocating timeline\n");
0039 
0040     sw_sync_timeline_destroy(timeline);
0041     return 0;
0042 }
0043 
0044 int test_alloc_fence(void)
0045 {
0046     int timeline, fence, valid;
0047 
0048     timeline = sw_sync_timeline_create();
0049     valid = sw_sync_timeline_is_valid(timeline);
0050     ASSERT(valid, "Failure allocating timeline\n");
0051 
0052     fence = sw_sync_fence_create(timeline, "allocFence", 1);
0053     valid = sw_sync_fence_is_valid(fence);
0054     ASSERT(valid, "Failure allocating fence\n");
0055 
0056     sw_sync_fence_destroy(fence);
0057     sw_sync_timeline_destroy(timeline);
0058     return 0;
0059 }
0060 
0061 int test_alloc_fence_negative(void)
0062 {
0063     int fence, timeline;
0064 
0065     timeline = sw_sync_timeline_create();
0066     ASSERT(timeline > 0, "Failure allocating timeline\n");
0067 
0068     fence = sw_sync_fence_create(-1, "fence", 1);
0069     ASSERT(fence < 0, "Success allocating negative fence\n");
0070 
0071     sw_sync_fence_destroy(fence);
0072     sw_sync_timeline_destroy(timeline);
0073     return 0;
0074 }