diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/.clang-tidy | 8 | ||||
| -rw-r--r-- | test/atom_test_utils.c | 20 | ||||
| -rw-r--r-- | test/cpp/.clang-tidy | 10 | ||||
| -rw-r--r-- | test/cpp/test_build.cpp | 64 | ||||
| -rw-r--r-- | test/headers/.clang-tidy | 8 | ||||
| -rw-r--r-- | test/headers/meson.build | 4 | ||||
| -rw-r--r-- | test/headers/test_headers.c | 60 | ||||
| -rw-r--r-- | test/meson.build | 261 | ||||
| -rw-r--r-- | test/test_atom.c | 19 | ||||
| -rw-r--r-- | test/test_build.c | 60 | ||||
| -rw-r--r-- | test/test_forge_overflow.c | 14 |
11 files changed, 352 insertions, 176 deletions
diff --git a/test/.clang-tidy b/test/.clang-tidy index f6fe1d6..a622e62 100644 --- a/test/.clang-tidy +++ b/test/.clang-tidy @@ -1,15 +1,9 @@ -# Copyright 2020-2022 David Robillard <d@drobilla.net> +# Copyright 2020-2025 David Robillard <d@drobilla.net> # SPDX-License-Identifier: 0BSD OR ISC Checks: > -*-else-after-return, - -bugprone-easily-swappable-parameters, -bugprone-suspicious-include, - -cert-err33-c, - -clang-diagnostic-unused-parameter, - -cppcoreguidelines-avoid-non-const-global-variables, - -llvmlibc-implementation-in-namespace, - -misc-unused-parameters, -modernize-use-trailing-return-type, -readability-function-cognitive-complexity, InheritParentConfig: true diff --git a/test/atom_test_utils.c b/test/atom_test_utils.c index e7d45d0..5c313a5 100644 --- a/test/atom_test_utils.c +++ b/test/atom_test_utils.c @@ -1,12 +1,15 @@ // Copyright 2012-2018 David Robillard <d@drobilla.net> // SPDX-License-Identifier: ISC -#include "lv2/atom/atom.h" -#include "lv2/atom/forge.h" -#include "lv2/atom/util.h" -#include "lv2/log/log.h" -#include "lv2/urid/urid.h" +#undef NDEBUG +#include <lv2/atom/atom.h> +#include <lv2/atom/forge.h> +#include <lv2/atom/util.h> +#include <lv2/log/log.h> +#include <lv2/urid/urid.h> + +#include <assert.h> #include <stdarg.h> #include <stdio.h> #include <stdlib.h> @@ -32,8 +35,11 @@ urid_map(LV2_URID_Map_Handle handle, const char* uri) } } - uris = (char**)realloc(uris, ++n_uris * sizeof(char*)); - uris[n_uris - 1] = copy_string(uri); + char** const new_uris = (char**)realloc(uris, (n_uris + 1) * sizeof(char*)); + assert(new_uris); + + uris = new_uris; + uris[n_uris++] = copy_string(uri); return n_uris; } diff --git a/test/cpp/.clang-tidy b/test/cpp/.clang-tidy index 02d730c..02ee4b8 100644 --- a/test/cpp/.clang-tidy +++ b/test/cpp/.clang-tidy @@ -1,11 +1,10 @@ -# Copyright 2020-2022 David Robillard <d@drobilla.net> +# Copyright 2020-2025 David Robillard <d@drobilla.net> # SPDX-License-Identifier: 0BSD OR ISC Checks: > - -*-avoid-c-arrays, - -*-deprecated-headers, -*-no-malloc, -*-use-auto, + -*-use-nullptr, -bugprone-reserved-identifier, -cert-dcl37-c, -cert-dcl50-cpp, @@ -16,11 +15,10 @@ Checks: > -cppcoreguidelines-pro-bounds-pointer-arithmetic, -cppcoreguidelines-pro-type-cstyle-cast, -cppcoreguidelines-pro-type-vararg, + -cppcoreguidelines-use-enum-class, -hicpp-no-array-decay, -hicpp-vararg, - -llvmlibc-callee-namespace, - -modernize-use-nullptr, -modernize-use-using, + -performance-enum-size, -readability-implicit-bool-conversion, InheritParentConfig: true - diff --git a/test/cpp/test_build.cpp b/test/cpp/test_build.cpp index c8b2ca0..19e8e56 100644 --- a/test/cpp/test_build.cpp +++ b/test/cpp/test_build.cpp @@ -1,7 +1,7 @@ // Copyright 2022 David Robillard <d@drobilla.net> // SPDX-License-Identifier: ISC -#if defined(__clang__) +#ifdef __clang__ _Pragma("clang diagnostic push") _Pragma("clang diagnostic ignored \"-Wold-style-cast\"") _Pragma("clang diagnostic ignored \"-Wzero-as-null-pointer-constant\"") @@ -10,36 +10,36 @@ _Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Wsuggest-attribute=const\"") #endif -#include "lv2/atom/atom.h" // IWYU pragma: keep -#include "lv2/atom/forge.h" // IWYU pragma: keep -#include "lv2/atom/util.h" // IWYU pragma: keep -#include "lv2/buf-size/buf-size.h" // IWYU pragma: keep -#include "lv2/core/attributes.h" // IWYU pragma: keep -#include "lv2/core/lv2.h" // IWYU pragma: keep -#include "lv2/core/lv2_util.h" // IWYU pragma: keep -#include "lv2/data-access/data-access.h" // IWYU pragma: keep -#include "lv2/dynmanifest/dynmanifest.h" // IWYU pragma: keep -#include "lv2/event/event-helpers.h" // IWYU pragma: keep -#include "lv2/event/event.h" // IWYU pragma: keep -#include "lv2/instance-access/instance-access.h" // IWYU pragma: keep -#include "lv2/log/log.h" // IWYU pragma: keep -#include "lv2/log/logger.h" // IWYU pragma: keep -#include "lv2/midi/midi.h" // IWYU pragma: keep -#include "lv2/morph/morph.h" // IWYU pragma: keep -#include "lv2/options/options.h" // IWYU pragma: keep -#include "lv2/parameters/parameters.h" // IWYU pragma: keep -#include "lv2/patch/patch.h" // IWYU pragma: keep -#include "lv2/port-groups/port-groups.h" // IWYU pragma: keep -#include "lv2/port-props/port-props.h" // IWYU pragma: keep -#include "lv2/presets/presets.h" // IWYU pragma: keep -#include "lv2/resize-port/resize-port.h" // IWYU pragma: keep -#include "lv2/state/state.h" // IWYU pragma: keep -#include "lv2/time/time.h" // IWYU pragma: keep -#include "lv2/ui/ui.h" // IWYU pragma: keep -#include "lv2/units/units.h" // IWYU pragma: keep -#include "lv2/uri-map/uri-map.h" // IWYU pragma: keep -#include "lv2/urid/urid.h" // IWYU pragma: keep -#include "lv2/worker/worker.h" // IWYU pragma: keep +#include <lv2/atom/atom.h> // IWYU pragma: keep +#include <lv2/atom/forge.h> // IWYU pragma: keep +#include <lv2/atom/util.h> // IWYU pragma: keep +#include <lv2/buf-size/buf-size.h> // IWYU pragma: keep +#include <lv2/core/attributes.h> // IWYU pragma: keep +#include <lv2/core/lv2.h> // IWYU pragma: keep +#include <lv2/core/lv2_util.h> // IWYU pragma: keep +#include <lv2/data-access/data-access.h> // IWYU pragma: keep +#include <lv2/dynmanifest/dynmanifest.h> // IWYU pragma: keep +#include <lv2/event/event-helpers.h> // IWYU pragma: keep +#include <lv2/event/event.h> // IWYU pragma: keep +#include <lv2/instance-access/instance-access.h> // IWYU pragma: keep +#include <lv2/log/log.h> // IWYU pragma: keep +#include <lv2/log/logger.h> // IWYU pragma: keep +#include <lv2/midi/midi.h> // IWYU pragma: keep +#include <lv2/morph/morph.h> // IWYU pragma: keep +#include <lv2/options/options.h> // IWYU pragma: keep +#include <lv2/parameters/parameters.h> // IWYU pragma: keep +#include <lv2/patch/patch.h> // IWYU pragma: keep +#include <lv2/port-groups/port-groups.h> // IWYU pragma: keep +#include <lv2/port-props/port-props.h> // IWYU pragma: keep +#include <lv2/presets/presets.h> // IWYU pragma: keep +#include <lv2/resize-port/resize-port.h> // IWYU pragma: keep +#include <lv2/state/state.h> // IWYU pragma: keep +#include <lv2/time/time.h> // IWYU pragma: keep +#include <lv2/ui/ui.h> // IWYU pragma: keep +#include <lv2/units/units.h> // IWYU pragma: keep +#include <lv2/uri-map/uri-map.h> // IWYU pragma: keep +#include <lv2/urid/urid.h> // IWYU pragma: keep +#include <lv2/worker/worker.h> // IWYU pragma: keep int main() @@ -47,7 +47,7 @@ main() return 0; } -#if defined(__clang__) +#ifdef __clang__ _Pragma("clang diagnostic pop") #elif defined(__GNUC__) _Pragma("GCC diagnostic pop") diff --git a/test/headers/.clang-tidy b/test/headers/.clang-tidy index dd0b95f..60c4447 100644 --- a/test/headers/.clang-tidy +++ b/test/headers/.clang-tidy @@ -1,16 +1,14 @@ -# Copyright 2020-2022 David Robillard <d@drobilla.net> +# Copyright 2020-2025 David Robillard <d@drobilla.net> # SPDX-License-Identifier: 0BSD OR ISC Checks: > *, + -*-macro-to-enum, -*-magic-numbers, -altera-*, - -bugprone-assignment-in-if-condition, -bugprone-easily-swappable-parameters, -bugprone-macro-parentheses, - -llvmlibc-restrict-system-libc-headers, - -modernize-macro-to-enum, - -performance-no-int-to-ptr, + -llvmlibc-*, -readability-identifier-length, CheckOptions: - key: hicpp-uppercase-literal-suffix.NewSuffixes diff --git a/test/headers/meson.build b/test/headers/meson.build index 6e9ac7a..89ee4b8 100644 --- a/test/headers/meson.build +++ b/test/headers/meson.build @@ -10,6 +10,7 @@ if get_option('warning_level') == 'everything' '-Wno-cast-qual', '-Wno-declaration-after-statement', '-Wno-padded', + '-Wno-unsafe-buffer-usage', ] if not meson.is_cross_build() @@ -53,6 +54,8 @@ if cc.get_id() == 'clang' ] endif +header_c_suppressions = cc.get_supported_arguments(header_c_suppressions) + test( 'headers', executable( @@ -60,6 +63,7 @@ test( files('test_headers.c'), c_args: header_c_suppressions, dependencies: [lv2_dep], + implicit_include_directories: false, ), suite: 'unit', ) diff --git a/test/headers/test_headers.c b/test/headers/test_headers.c index 5736b44..d62b000 100644 --- a/test/headers/test_headers.c +++ b/test/headers/test_headers.c @@ -1,36 +1,36 @@ // Copyright 2022 David Robillard <d@drobilla.net> // SPDX-License-Identifier: ISC -#include "lv2/atom/atom.h" // IWYU pragma: keep -#include "lv2/atom/forge.h" // IWYU pragma: keep -#include "lv2/atom/util.h" // IWYU pragma: keep -#include "lv2/buf-size/buf-size.h" // IWYU pragma: keep -#include "lv2/core/attributes.h" // IWYU pragma: keep -#include "lv2/core/lv2.h" // IWYU pragma: keep -#include "lv2/core/lv2_util.h" // IWYU pragma: keep -#include "lv2/data-access/data-access.h" // IWYU pragma: keep -#include "lv2/dynmanifest/dynmanifest.h" // IWYU pragma: keep -#include "lv2/event/event-helpers.h" // IWYU pragma: keep -#include "lv2/event/event.h" // IWYU pragma: keep -#include "lv2/instance-access/instance-access.h" // IWYU pragma: keep -#include "lv2/log/log.h" // IWYU pragma: keep -#include "lv2/log/logger.h" // IWYU pragma: keep -#include "lv2/midi/midi.h" // IWYU pragma: keep -#include "lv2/morph/morph.h" // IWYU pragma: keep -#include "lv2/options/options.h" // IWYU pragma: keep -#include "lv2/parameters/parameters.h" // IWYU pragma: keep -#include "lv2/patch/patch.h" // IWYU pragma: keep -#include "lv2/port-groups/port-groups.h" // IWYU pragma: keep -#include "lv2/port-props/port-props.h" // IWYU pragma: keep -#include "lv2/presets/presets.h" // IWYU pragma: keep -#include "lv2/resize-port/resize-port.h" // IWYU pragma: keep -#include "lv2/state/state.h" // IWYU pragma: keep -#include "lv2/time/time.h" // IWYU pragma: keep -#include "lv2/ui/ui.h" // IWYU pragma: keep -#include "lv2/units/units.h" // IWYU pragma: keep -#include "lv2/uri-map/uri-map.h" // IWYU pragma: keep -#include "lv2/urid/urid.h" // IWYU pragma: keep -#include "lv2/worker/worker.h" // IWYU pragma: keep +#include <lv2/atom/atom.h> // IWYU pragma: keep +#include <lv2/atom/forge.h> // IWYU pragma: keep +#include <lv2/atom/util.h> // IWYU pragma: keep +#include <lv2/buf-size/buf-size.h> // IWYU pragma: keep +#include <lv2/core/attributes.h> // IWYU pragma: keep +#include <lv2/core/lv2.h> // IWYU pragma: keep +#include <lv2/core/lv2_util.h> // IWYU pragma: keep +#include <lv2/data-access/data-access.h> // IWYU pragma: keep +#include <lv2/dynmanifest/dynmanifest.h> // IWYU pragma: keep +#include <lv2/event/event-helpers.h> // IWYU pragma: keep +#include <lv2/event/event.h> // IWYU pragma: keep +#include <lv2/instance-access/instance-access.h> // IWYU pragma: keep +#include <lv2/log/log.h> // IWYU pragma: keep +#include <lv2/log/logger.h> // IWYU pragma: keep +#include <lv2/midi/midi.h> // IWYU pragma: keep +#include <lv2/morph/morph.h> // IWYU pragma: keep +#include <lv2/options/options.h> // IWYU pragma: keep +#include <lv2/parameters/parameters.h> // IWYU pragma: keep +#include <lv2/patch/patch.h> // IWYU pragma: keep +#include <lv2/port-groups/port-groups.h> // IWYU pragma: keep +#include <lv2/port-props/port-props.h> // IWYU pragma: keep +#include <lv2/presets/presets.h> // IWYU pragma: keep +#include <lv2/resize-port/resize-port.h> // IWYU pragma: keep +#include <lv2/state/state.h> // IWYU pragma: keep +#include <lv2/time/time.h> // IWYU pragma: keep +#include <lv2/ui/ui.h> // IWYU pragma: keep +#include <lv2/units/units.h> // IWYU pragma: keep +#include <lv2/uri-map/uri-map.h> // IWYU pragma: keep +#include <lv2/urid/urid.h> // IWYU pragma: keep +#include <lv2/worker/worker.h> // IWYU pragma: keep #ifdef __GNUC__ __attribute__((const)) diff --git a/test/meson.build b/test/meson.build index 2919735..7144349 100644 --- a/test/meson.build +++ b/test/meson.build @@ -6,6 +6,13 @@ ######## if get_option('lint') + # Check licensing metadata + reuse = find_program('reuse', required: false) + if reuse.found() + reuse_args = ['--root', lv2_source_root, 'lint'] + test('REUSE', reuse, args: reuse_args, suite: 'data') + endif + # Check for spelling errors codespell = find_program('codespell', required: get_option('tests')) if codespell.found() @@ -20,12 +27,11 @@ if get_option('lint') codespell, args: [ '-d', - '-q', '3', - '-S', ','.join(ignore), + ['-q', '3'], + ['-S', ','.join(ignore)], lv2_source_root / 'doc', lv2_source_root / 'lv2', lv2_source_root / 'lv2specgen', - lv2_source_root / 'plugins', lv2_source_root / 'schemas.lv2', ], suite: 'data', @@ -36,52 +42,219 @@ if get_option('lint') serdi = find_program( 'serdi', required: get_option('tests'), - version: '>= 0.31.5', + version: '>= 0.32.0', + ) + native_build = ( + not meson.is_cross_build() + and host_machine.system() != 'windows' ) - native_build = not meson.is_cross_build() and host_machine.system() != 'windows' if serdi.found() and native_build - lv2_check_syntax = files(lv2_source_root / 'scripts' / 'lv2_check_syntax.py') + lv2_check_syntax = files( + lv2_source_root / 'scripts' / 'lv2_check_syntax.py', + ) - test('syntax', - lv2_check_syntax, - args: ['--serdi', serdi.full_path()] + spec_files + schema_data, - suite: 'data') + test( + 'syntax', + lv2_check_syntax, + args: ['--serdi', serdi.full_path()] + spec_files + schema_data, + suite: 'data', + ) endif # Check that specification data validates sord_validate = find_program('sord_validate', required: get_option('tests')) if sord_validate.found() - test('valid', - sord_validate, - args: spec_files + schema_data, - suite: 'data') + test('valid', sord_validate, args: spec_files + schema_data, suite: 'data') endif endif +############################# +# Compilers and Build Tools # +############################# + +cc = meson.get_compiler('c') + +if add_languages(['cpp'], native: false, required: get_option('tests')) + cpp = meson.get_compiler('cpp') +endif + +######################## +# Warning Suppressions # +######################## + +warning_level = get_option('warning_level') + +# C +test_c_suppressions = [] +if cc.get_id() in ['clang', 'emscripten'] + if warning_level == 'everything' + test_c_suppressions += [ + '-Wno-cast-align', + '-Wno-cast-qual', + '-Wno-declaration-after-statement', + '-Wno-documentation-unknown-command', + '-Wno-double-promotion', + '-Wno-float-equal', + '-Wno-padded', + '-Wno-reserved-id-macro', + '-Wno-unsafe-buffer-usage', + ] + + if not meson.is_cross_build() + test_c_suppressions += ['-Wno-poison-system-directories'] + endif + + if host_machine.system() == 'windows' + test_c_suppressions += ['-Wno-format-nonliteral'] + endif + endif + + if warning_level in ['everything', '3', '2'] + test_c_suppressions += ['-Wno-unused-parameter'] + endif + +elif cc.get_id() == 'gcc' + if warning_level == 'everything' + test_c_suppressions += [ + '-Wno-cast-align', + '-Wno-cast-qual', + '-Wno-double-promotion', + '-Wno-float-equal', + '-Wno-inline', + '-Wno-padded', + '-Wno-suggest-attribute=const', + '-Wno-suggest-attribute=malloc', + '-Wno-suggest-attribute=pure', + '-Wno-unsuffixed-float-constants', + '-Wno-unused-const-variable', + ] + + if target_machine.system() == 'windows' + test_c_suppressions += [ + '-Wno-sign-conversion', + '-Wno-suggest-attribute=format', + ] + endif + endif + + if warning_level in ['everything', '3', '2'] + test_c_suppressions += ['-Wno-unused-parameter'] + endif + +elif cc.get_id() == 'msvc' + if warning_level == 'everything' + test_c_suppressions += [ + '/wd4061', # enumerator in switch is not explicitly handled + '/wd4244', # conversion with possible loss of data + '/wd4365', # signed/unsigned mismatch + '/wd4514', # unreferenced inline function has been removed + '/wd4710', # function not inlined + '/wd4711', # function selected for automatic inline expansion + '/wd4820', # padding added after construct + '/wd5045', # will insert Spectre mitigation for memory load + ] + endif + + if warning_level in ['everything', '3'] + test_c_suppressions += [ + '/wd4100', # unreferenced formal parameter + ] + endif + + if warning_level in ['everything', '3', '2'] + test_c_suppressions += [ + '/wd4267', # conversion from size_t to a smaller type + ] + endif +endif + +test_c_suppressions = cc.get_supported_arguments(test_c_suppressions) + +# C++ +if is_variable('cpp') + test_cpp_suppressions = [] + + if warning_level == 'everything' + if cpp.get_id() in ['clang', 'emscripten'] + test_cpp_suppressions += [ + '-Wno-c++98-compat', + '-Wno-cast-align', + '-Wno-cast-qual', + '-Wno-documentation-unknown-command', + '-Wno-nullability-extension', + '-Wno-padded', + '-Wno-reserved-id-macro', + '-Wno-unsafe-buffer-usage', + ] + + if not meson.is_cross_build() + test_cpp_suppressions += ['-Wno-poison-system-directories'] + endif + + if host_machine.system() == 'windows' + test_cpp_suppressions += ['-Wno-format-nonliteral'] + endif + + elif cpp.get_id() == 'gcc' + test_cpp_suppressions += [ + '-Wno-cast-align', + '-Wno-cast-qual', + '-Wno-inline', + '-Wno-padded', + '-Wno-unused-const-variable', + '-Wno-useless-cast', + ] + + if target_machine.system() == 'windows' + test_cpp_suppressions += ['-Wno-suggest-attribute=format'] + endif + + elif cpp.get_id() == 'msvc' + test_cpp_suppressions += [ + '/wd4514', # unreferenced inline function has been removed + '/wd4706', # assignment within conditional expression + '/wd4710', # function not inlined + '/wd4711', # function selected for automatic inline expansion + '/wd4820', # padding added after data member + '/wd5045', # will insert Spectre mitigation + '/wd5264', # const variable is not used + ] + endif + endif + + test_cpp_suppressions = cpp.get_supported_arguments(test_cpp_suppressions) +endif + ######## # Code # ######## # Check that all the headers compile cleanly in C -test('c', - executable( - 'test_build_c', - files('test_build.c'), - c_args: c_suppressions, - dependencies: [lv2_dep], - ), - suite: 'build') +test( + 'c', + executable( + 'test_build_c', + files('test_build.c'), + c_args: test_c_suppressions, + dependencies: [lv2_dep], + implicit_include_directories: false, + ), + suite: 'build', +) # Check that all the headers compile cleanly in C++ if is_variable('cpp') - test('cpp', - executable( - 'test_build_cpp', - files('cpp/test_build.cpp'), - cpp_args: cpp_suppressions, - dependencies: [lv2_dep], - ), - suite: 'build') + test( + 'cpp', + executable( + 'test_build_cpp', + files('cpp/test_build.cpp'), + cpp_args: test_cpp_suppressions, + dependencies: [lv2_dep], + implicit_include_directories: false, + ), + suite: 'build', + ) endif ########## @@ -89,34 +262,32 @@ endif ########## if get_option('lint') - # Scripts that don't pass with pylint - lax_python_scripts = files( + python_scripts = lv2_scripts + files( '../lv2specgen/lv2docgen.py', '../lv2specgen/lv2specgen.py', ) - # Scripts that pass with everything including pylint - strict_python_scripts = lv2_scripts + files('../plugins/literasc.py') - - all_python_scripts = lax_python_scripts + strict_python_scripts - # Check script formatting black = find_program('black', required: get_option('tests')) if black.found() black_opts = ['-l', '79', '-q', '--check'] - test('black', black, args: black_opts + all_python_scripts, suite: 'scripts') + test( + 'black', + black, + args: black_opts + python_scripts, + suite: 'scripts', + ) endif # Check scripts for errors with flake8 flake8 = find_program('flake8', required: get_option('tests')) if flake8.found() - test('flake8', flake8, args: all_python_scripts, suite: 'scripts') + test('flake8', flake8, args: python_scripts, suite: 'scripts') endif # Check scripts for errors with pylint pylint = find_program('pylint', required: get_option('tests')) if pylint.found() - pymod = import('python') lint_py = pymod.find_installation( 'python3', modules: ['pygments', 'rdflib'], @@ -124,7 +295,7 @@ if get_option('lint') ) if lint_py.found() - test('pylint', pylint, args: strict_python_scripts, suite: 'scripts') + test('pylint', pylint, args: python_scripts, suite: 'scripts') endif endif endif @@ -144,6 +315,11 @@ test_names = [ 'forge_overflow', ] +atom_test_suppressions = [] +if cc.get_id() == 'gcc' + atom_test_suppressions += ['-Wno-stringop-overflow'] +endif + # Build and run tests foreach test_name : test_names test( @@ -151,8 +327,9 @@ foreach test_name : test_names executable( test_name, files('test_@0@.c'.format(test_name)), - c_args: c_suppressions, + c_args: test_c_suppressions + atom_test_suppressions, dependencies: [lv2_dep], + implicit_include_directories: false, ), suite: 'unit', ) diff --git a/test/test_atom.c b/test/test_atom.c index beac05c..df684dc 100644 --- a/test/test_atom.c +++ b/test/test_atom.c @@ -3,14 +3,13 @@ #include "atom_test_utils.c" -#include "lv2/atom/atom.h" -#include "lv2/atom/forge.h" -#include "lv2/atom/util.h" -#include "lv2/urid/urid.h" +#include <lv2/atom/atom.h> +#include <lv2/atom/forge.h> +#include <lv2/atom/util.h> +#include <lv2/urid/urid.h> #include <stdbool.h> #include <stdint.h> -#include <stdlib.h> #include <string.h> int @@ -101,7 +100,7 @@ main(void) lv2_atom_forge_key(&forge, eg_path); LV2_Atom_String* path = (LV2_Atom_String*)lv2_atom_forge_deref( &forge, lv2_atom_forge_uri(&forge, pstr, pstr_len)); - char* pbody = (char*)LV2_ATOM_BODY(path); + char* pbody = (char*)&path[1]; if (!!strcmp(pbody, pstr)) { return test_fail("%s != \"%s\"\n", pbody, pstr); } @@ -112,7 +111,7 @@ main(void) lv2_atom_forge_key(&forge, eg_uri); LV2_Atom_String* uri = (LV2_Atom_String*)lv2_atom_forge_deref( &forge, lv2_atom_forge_uri(&forge, ustr, ustr_len)); - char* ubody = (char*)LV2_ATOM_BODY(uri); + char* ubody = (char*)&uri[1]; if (!!strcmp(ubody, ustr)) { return test_fail("%s != \"%s\"\n", ubody, ustr); } @@ -130,7 +129,7 @@ main(void) lv2_atom_forge_key(&forge, eg_string); LV2_Atom_String* string = (LV2_Atom_String*)lv2_atom_forge_deref( &forge, lv2_atom_forge_string(&forge, "hello", strlen("hello"))); - char* sbody = (char*)LV2_ATOM_BODY(string); + char* sbody = (char*)&string[1]; if (!!strcmp(sbody, "hello")) { return test_fail("%s != \"hello\"\n", sbody); } @@ -144,7 +143,7 @@ main(void) strlen("bonjour"), 0, urid_map(NULL, "http://lexvo.org/id/term/fr"))); - char* lbody = (char*)LV2_ATOM_CONTENTS(LV2_Atom_Literal, literal); + char* lbody = (char*)&literal[1]; if (!!strcmp(lbody, "bonjour")) { return test_fail("%s != \"bonjour\"\n", lbody); } @@ -186,7 +185,7 @@ main(void) LV2_Atom_Vector* vector = (LV2_Atom_Vector*)lv2_atom_forge_deref( &forge, lv2_atom_forge_vector(&forge, sizeof(int32_t), forge.Int, 4, elems)); - void* vec_body = LV2_ATOM_CONTENTS(LV2_Atom_Vector, vector); + const void* vec_body = LV2_ATOM_CONTENTS_CONST(LV2_Atom_Vector, vector); if (!!memcmp(elems, vec_body, sizeof(elems))) { return test_fail("Corrupt vector\n"); } diff --git a/test/test_build.c b/test/test_build.c index bdc47f6..83a69df 100644 --- a/test/test_build.c +++ b/test/test_build.c @@ -1,36 +1,36 @@ // Copyright 2022 David Robillard <d@drobilla.net> // SPDX-License-Identifier: ISC -#include "lv2/atom/atom.h" // IWYU pragma: keep -#include "lv2/atom/forge.h" // IWYU pragma: keep -#include "lv2/atom/util.h" // IWYU pragma: keep -#include "lv2/buf-size/buf-size.h" // IWYU pragma: keep -#include "lv2/core/attributes.h" // IWYU pragma: keep -#include "lv2/core/lv2.h" // IWYU pragma: keep -#include "lv2/core/lv2_util.h" // IWYU pragma: keep -#include "lv2/data-access/data-access.h" // IWYU pragma: keep -#include "lv2/dynmanifest/dynmanifest.h" // IWYU pragma: keep -#include "lv2/event/event-helpers.h" // IWYU pragma: keep -#include "lv2/event/event.h" // IWYU pragma: keep -#include "lv2/instance-access/instance-access.h" // IWYU pragma: keep -#include "lv2/log/log.h" // IWYU pragma: keep -#include "lv2/log/logger.h" // IWYU pragma: keep -#include "lv2/midi/midi.h" // IWYU pragma: keep -#include "lv2/morph/morph.h" // IWYU pragma: keep -#include "lv2/options/options.h" // IWYU pragma: keep -#include "lv2/parameters/parameters.h" // IWYU pragma: keep -#include "lv2/patch/patch.h" // IWYU pragma: keep -#include "lv2/port-groups/port-groups.h" // IWYU pragma: keep -#include "lv2/port-props/port-props.h" // IWYU pragma: keep -#include "lv2/presets/presets.h" // IWYU pragma: keep -#include "lv2/resize-port/resize-port.h" // IWYU pragma: keep -#include "lv2/state/state.h" // IWYU pragma: keep -#include "lv2/time/time.h" // IWYU pragma: keep -#include "lv2/ui/ui.h" // IWYU pragma: keep -#include "lv2/units/units.h" // IWYU pragma: keep -#include "lv2/uri-map/uri-map.h" // IWYU pragma: keep -#include "lv2/urid/urid.h" // IWYU pragma: keep -#include "lv2/worker/worker.h" // IWYU pragma: keep +#include <lv2/atom/atom.h> // IWYU pragma: keep +#include <lv2/atom/forge.h> // IWYU pragma: keep +#include <lv2/atom/util.h> // IWYU pragma: keep +#include <lv2/buf-size/buf-size.h> // IWYU pragma: keep +#include <lv2/core/attributes.h> // IWYU pragma: keep +#include <lv2/core/lv2.h> // IWYU pragma: keep +#include <lv2/core/lv2_util.h> // IWYU pragma: keep +#include <lv2/data-access/data-access.h> // IWYU pragma: keep +#include <lv2/dynmanifest/dynmanifest.h> // IWYU pragma: keep +#include <lv2/event/event-helpers.h> // IWYU pragma: keep +#include <lv2/event/event.h> // IWYU pragma: keep +#include <lv2/instance-access/instance-access.h> // IWYU pragma: keep +#include <lv2/log/log.h> // IWYU pragma: keep +#include <lv2/log/logger.h> // IWYU pragma: keep +#include <lv2/midi/midi.h> // IWYU pragma: keep +#include <lv2/morph/morph.h> // IWYU pragma: keep +#include <lv2/options/options.h> // IWYU pragma: keep +#include <lv2/parameters/parameters.h> // IWYU pragma: keep +#include <lv2/patch/patch.h> // IWYU pragma: keep +#include <lv2/port-groups/port-groups.h> // IWYU pragma: keep +#include <lv2/port-props/port-props.h> // IWYU pragma: keep +#include <lv2/presets/presets.h> // IWYU pragma: keep +#include <lv2/resize-port/resize-port.h> // IWYU pragma: keep +#include <lv2/state/state.h> // IWYU pragma: keep +#include <lv2/time/time.h> // IWYU pragma: keep +#include <lv2/ui/ui.h> // IWYU pragma: keep +#include <lv2/units/units.h> // IWYU pragma: keep +#include <lv2/uri-map/uri-map.h> // IWYU pragma: keep +#include <lv2/urid/urid.h> // IWYU pragma: keep +#include <lv2/worker/worker.h> // IWYU pragma: keep int main(void) diff --git a/test/test_forge_overflow.c b/test/test_forge_overflow.c index 95e9b87..7e97ae4 100644 --- a/test/test_forge_overflow.c +++ b/test/test_forge_overflow.c @@ -3,9 +3,9 @@ #include "atom_test_utils.c" -#include "lv2/atom/atom.h" -#include "lv2/atom/forge.h" -#include "lv2/urid/urid.h" +#include <lv2/atom/atom.h> +#include <lv2/atom/forge.h> +#include <lv2/urid/urid.h> #include <assert.h> #include <stdint.h> @@ -90,7 +90,7 @@ test_literal_overflow(void) static int test_sequence_overflow(void) { - static const size_t size = sizeof(LV2_Atom_Sequence) + 6 * sizeof(LV2_Atom); + static const size_t size = sizeof(LV2_Atom_Sequence) + (6 * sizeof(LV2_Atom)); LV2_URID_Map map = {NULL, urid_map}; // Test over a range that fails in the sequence header and event components @@ -121,7 +121,7 @@ test_sequence_overflow(void) static int test_vector_head_overflow(void) { - static const size_t size = sizeof(LV2_Atom_Vector) + 3 * sizeof(LV2_Atom); + static const size_t size = sizeof(LV2_Atom_Vector) + (3 * sizeof(LV2_Atom)); LV2_URID_Map map = {NULL, urid_map}; // Test over a range that fails in the vector header and elements @@ -154,7 +154,7 @@ test_vector_head_overflow(void) static int test_vector_overflow(void) { - static const size_t size = sizeof(LV2_Atom_Vector) + 3 * sizeof(LV2_Atom); + static const size_t size = sizeof(LV2_Atom_Vector) + (3 * sizeof(LV2_Atom)); static const int32_t vec[] = {1, 2, 3}; LV2_URID_Map map = {NULL, urid_map}; @@ -181,7 +181,7 @@ test_vector_overflow(void) static int test_tuple_overflow(void) { - static const size_t size = sizeof(LV2_Atom_Tuple) + 3 * sizeof(LV2_Atom); + static const size_t size = sizeof(LV2_Atom_Tuple) + (3 * sizeof(LV2_Atom)); LV2_URID_Map map = {NULL, urid_map}; // Test over a range that fails in the tuple header and elements |