Merge pull request #23246 from medhefgo/check-compilation

meson: Improve public header tests
This commit is contained in:
Evgeny Vereshchagin 2022-05-05 01:53:28 +03:00 committed by GitHub
commit 51cef2b56f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 28 additions and 14 deletions

View File

@ -61,6 +61,7 @@ if conf.get('ENABLE_HWDB') == 1
parse_hwdb_py = find_program('parse_hwdb.py') parse_hwdb_py = find_program('parse_hwdb.py')
test('parse-hwdb', test('parse-hwdb',
parse_hwdb_py, parse_hwdb_py,
suite : 'dist-check',
args : [hwdb_files_test, args : [hwdb_files_test,
auto_suspend_rules], auto_suspend_rules],
timeout : 90) timeout : 90)

View File

@ -226,6 +226,7 @@ update_dbus_docs = custom_target(
if conf.get('BUILD_MODE_DEVELOPER') == 1 if conf.get('BUILD_MODE_DEVELOPER') == 1
test('dbus-docs-fresh', test('dbus-docs-fresh',
update_dbus_docs_py, update_dbus_docs_py,
suite : 'dist-check',
args : ['--build-dir', project_build_root, '--test', dbus_docs], args : ['--build-dir', project_build_root, '--test', dbus_docs],
depends : dbus_programs) depends : dbus_programs)
endif endif

View File

@ -289,7 +289,6 @@ conf.set_quoted('STATUS_UNIT_FORMAT_DEFAULT_STR', status_unit_format
cc = meson.get_compiler('c') cc = meson.get_compiler('c')
pkgconfig = import('pkgconfig') pkgconfig = import('pkgconfig')
check_compilation_sh = find_program('tools/check-compilation.sh')
meson_build_sh = find_program('tools/meson-build.sh') meson_build_sh = find_program('tools/meson-build.sh')
want_tests = get_option('tests') want_tests = get_option('tests')
@ -3519,6 +3518,7 @@ if conf.get('ENABLE_HWDB') == 1
if want_tests != 'false' if want_tests != 'false'
test('hwdb-test', test('hwdb-test',
hwdb_test_sh, hwdb_test_sh,
suite : 'dist-check',
args : [systemd_hwdb.full_path()], args : [systemd_hwdb.full_path()],
timeout : 90) timeout : 90)
endif endif
@ -3879,6 +3879,7 @@ foreach tuple : fuzzers
if b == name if b == name
test('@0@_@1@'.format(b, c), test('@0@_@1@'.format(b, c),
exe, exe,
suite : 'fuzzers',
args : [project_source_root / p]) args : [project_source_root / p])
endif endif
endforeach endforeach
@ -3941,6 +3942,7 @@ jekyll = find_program('jekyll', required : false)
if get_option('mode') == 'developer' and want_tests != 'false' and jekyll.found() if get_option('mode') == 'developer' and want_tests != 'false' and jekyll.found()
test('github-pages', test('github-pages',
jekyll, jekyll,
suite : 'dist-check',
args : ['build', args : ['build',
'--source', project_source_root / 'docs', '--source', project_source_root / 'docs',
'--destination', project_build_root / '_site']) '--destination', project_build_root / '_site'])
@ -3956,11 +3958,13 @@ foreach exec : public_programs
if want_tests != 'false' if want_tests != 'false'
test('check-help-' + name, test('check-help-' + name,
check_help, check_help,
suite : 'dist-check',
args : exec.full_path(), args : exec.full_path(),
depends: exec) depends: exec)
test('check-version-' + name, test('check-version-' + name,
check_version, check_version,
suite : 'dist-check',
args : [exec.full_path(), args : [exec.full_path(),
meson.project_version()], meson.project_version()],
depends: exec) depends: exec)
@ -3974,6 +3978,7 @@ check_directives_sh = find_program('tools/check-directives.sh')
if want_tests != 'false' if want_tests != 'false'
test('check-directives', test('check-directives',
check_directives_sh, check_directives_sh,
suite : 'dist-check',
args : [project_source_root, project_build_root]) args : [project_source_root, project_build_root])
endif endif
@ -4013,6 +4018,7 @@ foreach tuple : sanitizers
if fuzz_tests if fuzz_tests
test('@0@_@1@_@2@'.format(b, c, sanitizer), test('@0@_@1@_@2@'.format(b, c, sanitizer),
env, env,
suite : 'fuzz+san',
env : ['UBSAN_OPTIONS=print_stacktrace=1:print_summary=1:halt_on_error=1'], env : ['UBSAN_OPTIONS=print_stacktrace=1:print_summary=1:halt_on_error=1'],
timeout : 60, timeout : 60,
args : [exe.full_path(), args : [exe.full_path(),

View File

@ -46,6 +46,10 @@ install_headers(
############################################################ ############################################################
if want_tests == 'false'
subdir_done()
endif
opts = [['c'], opts = [['c'],
['c', '-ansi'], ['c', '-ansi'],
['c', '-std=iso9899:1990'], ['c', '-std=iso9899:1990'],
@ -73,13 +77,17 @@ endif
foreach header : _systemd_headers + _not_installed_headers + [libudev_h_path] foreach header : _systemd_headers + _not_installed_headers + [libudev_h_path]
foreach opt : opts foreach opt : opts
std_name = opt.length() == 2 ? '_'.join(opt[1].split(':')) : '' std_name = opt.length() == 2 ? '_'.join(opt[1].split(':')) : ''
name = ''.join(['cc-', header.split('/')[-1], '_', opt[0], std_name]) test('cc-' + header.split('/')[-1] + '_' + opt[0] + std_name,
if want_tests != 'false' env,
test(name, suite : 'headers',
check_compilation_sh, args : [cc.cmd_array(),
args : cc.cmd_array() + ['-c', '-x'] + opt + '-c',
['-Werror', '-include', '-x', opt,
meson.current_source_dir() / header]) '-Wall',
endif '-Wextra',
'-Werror',
'-include', meson.current_source_dir() / header,
'-o/dev/null',
'/dev/null'])
endforeach endforeach
endforeach endforeach

View File

@ -112,6 +112,7 @@ rule_syntax_check_py = find_program('rule-syntax-check.py')
if want_tests != 'false' if want_tests != 'false'
test('rule-syntax-check', test('rule-syntax-check',
rule_syntax_check_py, rule_syntax_check_py,
suite : 'dist-check',
args : all_rules) args : all_rules)
endif endif
@ -162,6 +163,7 @@ if rpm.found() and rpmspec.found()
if want_tests != 'false' if want_tests != 'false'
test('test-rpm-macros', test('test-rpm-macros',
test_rpm_macros, test_rpm_macros,
suite : 'dist-check',
args : [project_build_root]) args : [project_build_root])
endif endif
else else
@ -191,6 +193,7 @@ if want_tests != 'false' and dmi_arches.contains(host_machine.cpu_family())
test(name, test(name,
udev_dmi_memory_id_test, udev_dmi_memory_id_test,
suite : 'dist-check',
args : [udev_prog_paths['dmi_memory_id'].full_path(), args : [udev_prog_paths['dmi_memory_id'].full_path(),
source, source,
source + '.txt'], source + '.txt'],

View File

@ -1,5 +0,0 @@
#!/bin/sh
# SPDX-License-Identifier: LGPL-2.1-or-later
set -eu
"$@" '-' -o/dev/null </dev/null