18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci *  sync allocation 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_alloc_timeline(void)
338c2ecf20Sopenharmony_ci{
348c2ecf20Sopenharmony_ci	int timeline, valid;
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ci	timeline = sw_sync_timeline_create();
378c2ecf20Sopenharmony_ci	valid = sw_sync_timeline_is_valid(timeline);
388c2ecf20Sopenharmony_ci	ASSERT(valid, "Failure allocating timeline\n");
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ci	sw_sync_timeline_destroy(timeline);
418c2ecf20Sopenharmony_ci	return 0;
428c2ecf20Sopenharmony_ci}
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_ciint test_alloc_fence(void)
458c2ecf20Sopenharmony_ci{
468c2ecf20Sopenharmony_ci	int timeline, fence, valid;
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_ci	timeline = sw_sync_timeline_create();
498c2ecf20Sopenharmony_ci	valid = sw_sync_timeline_is_valid(timeline);
508c2ecf20Sopenharmony_ci	ASSERT(valid, "Failure allocating timeline\n");
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ci	fence = sw_sync_fence_create(timeline, "allocFence", 1);
538c2ecf20Sopenharmony_ci	valid = sw_sync_fence_is_valid(fence);
548c2ecf20Sopenharmony_ci	ASSERT(valid, "Failure allocating fence\n");
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_ci	sw_sync_fence_destroy(fence);
578c2ecf20Sopenharmony_ci	sw_sync_timeline_destroy(timeline);
588c2ecf20Sopenharmony_ci	return 0;
598c2ecf20Sopenharmony_ci}
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_ciint test_alloc_fence_negative(void)
628c2ecf20Sopenharmony_ci{
638c2ecf20Sopenharmony_ci	int fence, timeline;
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_ci	timeline = sw_sync_timeline_create();
668c2ecf20Sopenharmony_ci	ASSERT(timeline > 0, "Failure allocating timeline\n");
678c2ecf20Sopenharmony_ci
688c2ecf20Sopenharmony_ci	fence = sw_sync_fence_create(-1, "fence", 1);
698c2ecf20Sopenharmony_ci	ASSERT(fence < 0, "Success allocating negative fence\n");
708c2ecf20Sopenharmony_ci
718c2ecf20Sopenharmony_ci	sw_sync_fence_destroy(fence);
728c2ecf20Sopenharmony_ci	sw_sync_timeline_destroy(timeline);
738c2ecf20Sopenharmony_ci	return 0;
748c2ecf20Sopenharmony_ci}
75