• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2021-2024 Huawei Device Co., Ltd.
2# Licensed under the Apache License, Version 2.0 (the "License");
3# you may not use this file except in compliance with the License.
4# You may obtain a copy of the License at
5#
6# http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS,
10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11# See the License for the specific language governing permissions and
12# limitations under the License.
13
14set(atomics_tests
15    # --- Simple non-concurrent tests
16    nonconcurrent_store_load_islockfree
17    nonconcurrent_increment
18    nonconcurrent_compare_exchange
19    # nonconcurrent_wait_timeout
20
21    # --- Concurrent tests without synchronization
22    concurrent_store_load
23    concurrent_increment
24    concurrent_compare_exchange
25
26    # --- Non-concurrent wait/notify tests
27    nonconcurrent_notify_zero
28    nonconcurrent_wait_not_equal
29    nonconcurrent_wait_i32_not_equal
30    nonconcurrent_wait_i64_not_equal
31    nonconcurrent_waitasync_store_notify
32
33    # --- Concurrent wait/notify tests
34    concurrent_wait_store_notify
35    concurrent_countdownlatch
36    # rendezvous_channel
37    # cyclic_barrier
38)
39
40set(tests_in_dir "${CMAKE_CURRENT_SOURCE_DIR}")
41set(tests_out_dir "${CMAKE_CURRENT_BINARY_DIR}")
42
43set(coroutine_options --coroutine-impl=threaded --coroutine-js-mode=false --coroutine-workers-count=10 --gc-type=g1-gc)
44
45add_custom_target(ets_test_suite_atomics)
46
47# This is a 'run_int_jit_aot_ets_code' function but without JIT
48function(run_atomics_tests ETS_SRC WORK_DIR TARGET)
49    set(oneValueArgs OPT_LEVEL)
50    set(noValues SKIP_ARM32_COMPILER)
51    set(multiValueArgs RUNTIME_EXTRA_OPTIONS)
52    cmake_parse_arguments(ARG "${noValues}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
53
54    add_custom_target(${TARGET})
55
56    # TODO(egor-porsev): Add jit and aot. Currently, they do not work because of the data race issue #13551
57    # int
58    run_int_ets_code(${ETS_SRC} ${WORK_DIR} ${TARGET}-ets-int OPT_LEVEL ${ARG_OPT_LEVEL} RUNTIME_EXTRA_OPTIONS ${ARG_RUNTIME_EXTRA_OPTIONS})
59    if(TARGET ${TARGET}-ets-int)
60        add_dependencies(${TARGET} ${TARGET}-ets-int)
61    endif()
62endfunction()
63
64foreach(test ${atomics_tests})
65    set(test_in "${tests_in_dir}/${test}.sts")
66    set(test_out_dir "${tests_out_dir}/${test}")
67    file(MAKE_DIRECTORY ${test_out_dir})
68    set(target ets_test_suite_atomics_${test})
69
70    run_atomics_tests(${test_in} ${test_out_dir} ${target} OPT_LEVEL 0 RUNTIME_EXTRA_OPTIONS ${coroutine_options})
71
72    if(TARGET ${target})
73        add_dependencies(ets_test_suite_atomics ${target})
74    endif()
75endforeach()
76