xref: /aosp_15_r20/external/libdav1d/tests/meson.build (revision c09093415860a1c2373dacd84c4fde00c507cdfd)
1# Copyright © 2018, VideoLAN and dav1d authors
2# All rights reserved.
3#
4# Redistribution and use in source and binary forms, with or without
5# modification, are permitted provided that the following conditions are met:
6#
7# 1. Redistributions of source code must retain the above copyright notice, this
8#    list of conditions and the following disclaimer.
9#
10# 2. Redistributions in binary form must reproduce the above copyright notice,
11#    this list of conditions and the following disclaimer in the documentation
12#    and/or other materials provided with the distribution.
13#
14# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
15# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
18# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
23# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
25#
26# Build definition for the dav1d tests
27#
28
29# Leave subdir if tests are disabled
30if not get_option('enable_tests')
31    subdir_done()
32endif
33
34if is_asm_enabled
35    checkasm_sources = files(
36        'checkasm/checkasm.c',
37        'checkasm/msac.c',
38        'checkasm/pal.c',
39        'checkasm/refmvs.c',
40    )
41
42    checkasm_tmpl_sources = files(
43        'checkasm/cdef.c',
44        'checkasm/filmgrain.c',
45        'checkasm/ipred.c',
46        'checkasm/itx.c',
47        'checkasm/loopfilter.c',
48        'checkasm/looprestoration.c',
49        'checkasm/mc.c',
50    )
51
52    checkasm_bitdepth_objs = []
53    foreach bitdepth : dav1d_bitdepths
54        checkasm_bitdepth_lib = static_library(
55            'checkasm_bitdepth_@0@'.format(bitdepth),
56            checkasm_tmpl_sources,
57            include_directories: dav1d_inc_dirs,
58            dependencies : [stdatomic_dependencies],
59            c_args: ['-DBITDEPTH=@0@'.format(bitdepth)],
60            install: false,
61            build_by_default: false,
62        )
63        checkasm_bitdepth_objs += checkasm_bitdepth_lib.extract_all_objects(recursive: true)
64    endforeach
65
66    checkasm_asm_objs = []
67    checkasm_asm_sources = []
68    if host_machine.cpu_family() == 'aarch64' or host_machine.cpu() == 'arm64'
69        checkasm_asm_sources += files('checkasm/arm/checkasm_64.S')
70    elif host_machine.cpu_family().startswith('arm')
71        checkasm_asm_sources += files('checkasm/arm/checkasm_32.S')
72    elif host_machine.cpu_family() == 'riscv64'
73        checkasm_asm_sources += files('checkasm/riscv/checkasm_64.S')
74    elif host_machine.cpu_family().startswith('x86')
75        checkasm_asm_objs += nasm_gen.process(files('checkasm/x86/checkasm.asm'))
76    elif host_machine.cpu_family().startswith('loongarch')
77        checkasm_asm_objs += files('checkasm/loongarch/checkasm.S')
78    endif
79
80    if use_gaspp
81        checkasm_asm_objs += gaspp_gen.process(checkasm_asm_sources)
82    else
83        checkasm_sources += checkasm_asm_sources
84    endif
85
86    checkasm = executable('checkasm',
87        checkasm_sources,
88        checkasm_asm_objs,
89
90        objects: [
91            checkasm_bitdepth_objs,
92            libdav1d.extract_all_objects(recursive: true),
93            ],
94
95        include_directories: dav1d_inc_dirs,
96        build_by_default: false,
97        dependencies : [
98            thread_dependency,
99            rt_dependency,
100            libdl_dependency,
101            libm_dependency,
102            ],
103        )
104
105    test('checkasm', checkasm, suite: 'checkasm', timeout: 180)
106    benchmark('checkasm', checkasm, suite: 'checkasm', timeout: 3600, args: '--bench')
107endif
108
109c99_extension_flag = cc.first_supported_argument(
110    '-Werror=c11-extensions',
111    '-Werror=c99-c11-compat',
112    '-Wc11-extensions',
113    '-Wc99-c11-compat',
114)
115
116# dav1d_api_headers
117foreach header : dav1d_api_headers
118    target = header + '_test'
119
120    header_test_exe = executable(target,
121        'header_test.c',
122        include_directories: dav1d_inc_dirs,
123        c_args: ['-DDAV1D_TEST_HEADER="@0@"'.format(header), c99_extension_flag],
124        build_by_default: true
125    )
126
127    test(target, header_test_exe, suite: 'headers')
128endforeach
129
130
131# fuzzing binaries
132subdir('libfuzzer')
133
134# seek stress test binary, depends on dav1d cli tool
135if (get_option('enable_tools') and get_option('enable_seek_stress'))
136    seek_stress_sources = files('seek_stress.c')
137    seek_stress = executable('seek_stress',
138        seek_stress_sources, rev_target,
139        objects: [
140            dav1d.extract_objects('dav1d_cli_parse.c'),
141            dav1d_input_objs.extract_objects('input/input.c', 'input/ivf.c'),
142        ],
143        include_directories: [dav1d_inc_dirs, include_directories('../tools')],
144        link_with: libdav1d,
145        dependencies: [
146            thread_dependency,
147            rt_dependency,
148            getopt_dependency,
149            libm_dependency,
150        ],
151    )
152endif
153
154# Include dav1d test data repository with additional tests
155if get_option('testdata_tests')
156    subdir('dav1d-test-data')
157endif
158