1# Each entry in `api_tests` is an array of one or two elements. The first
2# element is the test name. The second is an optional timeout if the default
3# timeout of 30 seconds is too short. Try to keep the list sorted.
4api_default_timeout = 30
5
6lang_var = 'LANG=en_US.UTF-8'
7
8api_tests = [
9    ['ksh_debug'],
10]
11
12# Some tests need to be skipped because the platform has known incompatibilities that we're not
13# interested in dealing with. For example, `printf("%p", ptr)` does not include a leading `0x` on
14# Solaris. Unlike every other platform.
15tests_to_skip = [
16    ['sunos', 'ksh_debug'],
17]
18
19# ASAN has probably installed a SIGSEGV handler. The `ksh_debug` API test also does so. The two may
20# not be compatible. So avoid false negative test failures when ASAN is enabled.
21if get_option('ASAN') == true
22    tests_to_skip += [['*', 'ksh_debug']]
23endif
24
25foreach testspec : api_tests
26    test_name = testspec[0]
27    timeout = (testspec.length() == 2) ? testspec[1] : api_default_timeout
28    if timeout <= 0
29        parallel = false
30        timeout = timeout == 0 ? default_timeout : -timeout
31    else
32        parallel = true
33    endif
34
35    skip_test = false
36    foreach skip : tests_to_skip
37        if ('*' == skip[0] or system == skip[0]) and test_name == skip[1]
38            warning('skipping ' + test_name + ' on ' + system)
39            skip_test = true
40            # break  # Not until meson 0.49
41        endif
42    endforeach
43    if not skip_test
44        test_target = executable(
45            test_name, test_name + '.c', c_args: shared_c_args,
46            include_directories: [configuration_incdir, ksh93_incdir],
47            link_with: [libksh, libast, libcmd, libdll],
48            dependencies: [libm_dep, libexecinfo_dep, libdl_dep],
49            install: false)
50        test('API/ksh/' + test_name, ksh93_exe, timeout: timeout, is_parallel: parallel,
51            args: [test_driver, 'api', test_target, test_name],
52            env: [shell_var, lang_var, src_root, test_root, ld_library_path, libsample_path])
53    endif
54endforeach
55