182208160SEmilio López /*
282208160SEmilio López  *  sync tests
382208160SEmilio López  *  Copyright 2015-2016 Collabora Ltd.
482208160SEmilio López  *
582208160SEmilio López  *  Based on the implementation from the Android Open Source Project,
682208160SEmilio López  *
782208160SEmilio López  *  Copyright 2012 Google, Inc
882208160SEmilio López  *
982208160SEmilio López  *  Permission is hereby granted, free of charge, to any person obtaining a
1082208160SEmilio López  *  copy of this software and associated documentation files (the "Software"),
1182208160SEmilio López  *  to deal in the Software without restriction, including without limitation
1282208160SEmilio López  *  the rights to use, copy, modify, merge, publish, distribute, sublicense,
1382208160SEmilio López  *  and/or sell copies of the Software, and to permit persons to whom the
1482208160SEmilio López  *  Software is furnished to do so, subject to the following conditions:
1582208160SEmilio López  *
1682208160SEmilio López  *  The above copyright notice and this permission notice shall be included in
1782208160SEmilio López  *  all copies or substantial portions of the Software.
1882208160SEmilio López  *
1982208160SEmilio López  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2082208160SEmilio López  *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2182208160SEmilio López  *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
2282208160SEmilio López  *  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
2382208160SEmilio López  *  OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
2482208160SEmilio López  *  ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
2582208160SEmilio López  *  OTHER DEALINGS IN THE SOFTWARE.
2682208160SEmilio López  */
2782208160SEmilio López 
2882208160SEmilio López #ifndef SELFTESTS_SYNCTEST_H
2982208160SEmilio López #define SELFTESTS_SYNCTEST_H
3082208160SEmilio López 
3182208160SEmilio López #include <stdio.h>
32f471e1fdSShuah Khan #include "../kselftest.h"
3382208160SEmilio López 
3482208160SEmilio López #define ASSERT(cond, msg) do { \
3582208160SEmilio López 	if (!(cond)) { \
36f471e1fdSShuah Khan 		ksft_print_msg("[ERROR]\t%s", (msg)); \
3782208160SEmilio López 		return 1; \
3882208160SEmilio López 	} \
3982208160SEmilio López } while (0)
4082208160SEmilio López 
4182208160SEmilio López #define RUN_TEST(x) run_test((x), #x)
4282208160SEmilio López 
4382208160SEmilio López /* Allocation tests */
4482208160SEmilio López int test_alloc_timeline(void);
4582208160SEmilio López int test_alloc_fence(void);
4682208160SEmilio López int test_alloc_fence_negative(void);
4782208160SEmilio López 
486a5b7d2cSEmilio López /* Fence tests with one timeline */
496a5b7d2cSEmilio López int test_fence_one_timeline_wait(void);
506a5b7d2cSEmilio López int test_fence_one_timeline_merge(void);
516a5b7d2cSEmilio López 
521c5839c6SEmilio López /* Fence merge tests */
531c5839c6SEmilio López int test_fence_merge_same_fence(void);
541c5839c6SEmilio López 
55fdba7cffSEmilio López /* Fence wait tests */
56fdba7cffSEmilio López int test_fence_multi_timeline_wait(void);
57fdba7cffSEmilio López 
5854b519f3SEmilio López /* Stress test - parallelism */
5954b519f3SEmilio López int test_stress_two_threads_shared_timeline(void);
6054b519f3SEmilio López 
61c52dee50SEmilio López /* Stress test - consumer */
62c52dee50SEmilio López int test_consumer_stress_multi_producer_single_consumer(void);
63c52dee50SEmilio López 
64499a1d11SEmilio López /* Stress test - merging */
65499a1d11SEmilio López int test_merge_stress_random_merge(void);
66499a1d11SEmilio López 
6782208160SEmilio López #endif
68