From 7254c2dfc39cbd1b0f18ed71705deec7c3244d7d Mon Sep 17 00:00:00 2001 From: Steve Lhomme Date: Wed, 19 Feb 2025 16:00:52 +0100 Subject: [PATCH] meson: add compat tests Just as with autotools it may not test the actual compat version of a function, but the one provided by the toolchain. That allows validating the tests with the real thing. --- compat/meson.build | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/compat/meson.build b/compat/meson.build index e371c4d8f9..64f728ac19 100644 --- a/compat/meson.build +++ b/compat/meson.build @@ -11,3 +11,49 @@ if libcompat_sources.length() > 0 install_dir: get_option('libdir') / 'vlc' ) endif + +heap_alloc_env = environment({'ASAN_OPTIONS': 'allocator_may_return_null=1'}) +vlc_tests += { + 'name': 'heap', + 'sources': files('test/heap.c'), + 'suite': ['compat'], + 'link_with': [vlc_libcompat], + 'env': heap_alloc_env, +} + +vlc_tests += { + 'name': 'strnstr', + 'sources': files('test/strnstr.c'), + 'suite': ['compat'], + 'link_with': [vlc_libcompat], +} + +vlc_tests += { + 'name': 'ckd_ckd', + 'sources': files('test/ckd.c'), + 'c_args': ['-DTEST_CKD'], + 'suite': ['compat'], + 'link_with': [vlc_libcompat], +} + +ckd_builtin_cargs = ['-DTEST_BUILTIN'] +if cdata.has('HAVE_STDCKDINT_H') + ckd_builtin_cargs += '-DHAVE_CKD' +endif +vlc_tests += { + 'name': 'ckd_builtin', + 'sources': files('test/ckd.c'), + 'c_args': ckd_builtin_cargs, + 'suite': ['compat'], + 'link_with': [vlc_libcompat], +} + +vlc_tests += { + 'name': 'ckd_compat', + 'sources': files('test/ckd.c'), + 'c_args': ['-DTEST_COMPAT'], + 'suite': ['compat'], + 'link_with': [vlc_libcompat], +} + +#TODO: add clock_nanosleep test for Darwin