xref: /aosp_15_r20/external/lz4/build/meson/meson/tests/meson.build (revision 27162e4e17433d5aa7cb38e7b6a433a09405fc7f)
1# #############################################################################
2# Copyright (c) 2018-present        lzutao <taolzu(at)gmail.com>
3# Copyright (c) 2022-present        Tristan Partin <tristan(at)partin.io>
4# All rights reserved.
5#
6# This source code is licensed under both the BSD-style license (found in the
7# LICENSE file in the root directory of this source tree) and the GPLv2 (found
8# in the COPYING file in the root directory of this source tree).
9# #############################################################################
10
11lz4_source_root = '../../../..'
12
13fuzzer_time = 90
14test_exes = {
15  'abiTest': {
16    'sources': files(lz4_source_root / 'tests/abiTest.c'),
17    'test': false,
18  },
19  'checkFrame': {
20    'sources': files(lz4_source_root / 'tests/checkFrame.c'),
21    'include_directories': include_directories(lz4_source_root / 'programs'),
22  },
23  'checkTag': {
24    'sources': files(lz4_source_root / 'tests/checkTag.c'),
25    'test': false,
26  },
27  'datagen': {
28    'sources': files(
29        lz4_source_root / 'programs/lorem.c',
30        lz4_source_root / 'tests/datagencli.c',
31        lz4_source_root / 'tests/datagen.c',
32        lz4_source_root / 'tests/loremOut.c',
33        ),
34    'include_directories': include_directories(lz4_source_root / 'programs'),
35  },
36  'decompress-partial-usingDict.c': {
37    'sources': files(lz4_source_root / 'tests/decompress-partial-usingDict.c'),
38  },
39  'decompress-partial.c': {
40    'sources': files(lz4_source_root / 'tests/decompress-partial.c'),
41  },
42  'frametest': {
43    'sources': files(lz4_source_root / 'tests/frametest.c'),
44    'include_directories': include_directories(lz4_source_root / 'programs'),
45    'args': ['-v', '-T@0@s'.format(fuzzer_time)],
46    'test': false,
47  },
48  'freestanding': {
49    'sources': files(lz4_source_root / 'tests/freestanding.c'),
50    'c_args': ['-ffreestanding', '-Wno-unused-parameter', '-Wno-declaration-after-statement'],
51    'link_args': ['-nostdlib'],
52    'build': cc.get_id() in ['gcc', 'clang'] and
53      host_machine.system() == 'linux' and host_machine.cpu_family() == 'x86_64',
54    'override_options': ['optimization=1'],
55  },
56  'fullbench': {
57    'sources': files(lz4_source_root / 'tests/fullbench.c'),
58    'include_directories': include_directories(lz4_source_root / 'programs'),
59    'args': ['--no-prompt', '-i1', files(lz4_source_root / 'tests/COPYING')],
60    'test': false,
61  },
62  'fuzzer': {
63    'sources': files(lz4_source_root / 'tests/fuzzer.c'),
64    'include_directories': include_directories(lz4_source_root / 'programs'),
65    'args': ['-T@0@s'.format(fuzzer_time)],
66    'test': false,
67  },
68  'roundTripTest': {
69    'sources': files(lz4_source_root / 'tests/roundTripTest.c'),
70    'test': false,
71  },
72}
73
74targets = {}
75
76foreach e, attrs : test_exes
77  if not attrs.get('build', true)
78    targets += {e: disabler()}
79    continue
80  endif
81
82  t = executable(
83    e,
84    attrs.get('sources'),
85    c_args: attrs.get('c_args', []),
86    link_args: attrs.get('link_args', []),
87    objects: attrs.get('objects', []),
88    dependencies: [liblz4_internal_dep],
89    include_directories: attrs.get('include_directories', []),
90    install: false,
91    override_options: attrs.get('override_options', [])
92  )
93
94  targets += {e: t}
95
96  if not attrs.get('test', true)
97    continue
98  endif
99
100  test(
101    e,
102    t,
103    args: attrs.get('params', []),
104    timeout: 120
105  )
106endforeach
107
108fs = import('fs')
109
110run_env.prepend('PATH', meson.current_build_dir())
111
112test_scripts = {
113  'lz4-basic': {
114    'depends': [lz4, lz4cat, unlz4, targets['datagen']],
115  },
116  'lz4-dict': {
117    'depends': [lz4, targets['datagen']],
118  },
119  'lz4-contentSize': {
120    'depends': [lz4, targets['datagen']],
121  },
122  'lz4-fast-hugefile': {
123    'depends': [lz4, targets['datagen']],
124  },
125  'lz4-frame-concatenation': {
126    'depends': [lz4, targets['datagen']],
127  },
128  'lz4-multiple': {
129    'depends': [lz4, targets['datagen']],
130  },
131  'lz4-multiple-legacy': {
132    'depends': [lz4, targets['datagen']],
133  },
134  'lz4-opt-parser': {
135    'depends': [lz4, targets['datagen']],
136  },
137  'lz4-skippable': {
138    'depends': [lz4],
139  },
140  'lz4-sparse': {
141    'depends': [lz4, targets['datagen']],
142  },
143  'lz4-testmode': {
144    'depends': [lz4, targets['datagen']],
145  },
146  'lz4hc-hugefile': {
147    'depends': [lz4, targets['datagen']],
148  },
149}
150
151foreach s, attrs : test_scripts
152  script = find_program(lz4_source_root / 'tests/test-@[email protected]'.format(s))
153
154  test(
155    '@0@'.format(s),
156    script,
157    depends: attrs.get('depends', []),
158    workdir: fs.parent(script.full_path()),
159    env: run_env,
160    timeout: 360
161  )
162endforeach
163