From a24b65bc71ff038c6d690af939b0953005ce41ce Mon Sep 17 00:00:00 2001 From: Christian Brauner Date: Thu, 10 Sep 2026 11:55:18 +0200 Subject: [PATCH] meson: add an argument-comments test suite Run tools/check-argument-comments.py over the sources that are compiled, one test per top-level source directory, in a suite that a plain "meson test" leaves out like the other linters. The NSS, PAM and cryptsetup token modules don't end up in sources, so collect theirs as well. The source directory is passed explicitly, so the suite works without git, from a tarball say. The script exits with meson's skip code where the libclang python bindings are missing. --- meson.build | 35 ++++++++++++++++++++++++++++++++++- tools/meson.build | 1 + 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 487dd758f80..32d2ebfc608 100644 --- a/meson.build +++ b/meson.build @@ -16,7 +16,7 @@ project('systemd', 'c', add_test_setup( 'default', - exclude_suites : ['clang-tidy', 'coccinelle', 'unused-symbols', 'integration-tests'], + exclude_suites : ['clang-tidy', 'coccinelle', 'argument-comments', 'unused-symbols', 'integration-tests'], exe_wrapper : find_program('tools/test-crash-trace.sh'), is_default : true, ) @@ -2889,6 +2889,7 @@ test_dlopen = executables_by_name.get('test-dlopen') nss_targets = [] pam_targets = [] module_targets = [] +module_sources = [] modules_by_name = {} foreach dict : modules name = dict.get('name') @@ -2906,6 +2907,8 @@ foreach dict : modules continue endif + module_sources += dict.get('sources', []) + kwargs = {} foreach key, val : dict if key in ['name', 'conditions', 'version-script'] @@ -3275,6 +3278,36 @@ if meson.version().version_compare('>=1.4.0') endif endforeach endforeach + + # One test per top-level source directory over the compiled .c files, which covers the headers + # they include. Generated sources are not below src/ relative to the source directory. The NSS, + # PAM and cryptsetup token modules are not in sources. + argument_comments_sources = {} + foreach source : sources + module_sources + if not source.full_path().endswith('.c') or source.full_path().endswith('.bpf.c') + continue + endif + + source_parts = fs.relative_to(source.full_path(), meson.project_source_root()).split('/') + if source_parts.length() > 2 and source_parts[0] == 'src' + argument_comments_sources += { + source_parts[1] : argument_comments_sources.get(source_parts[1], []) + [source], + } + endif + endforeach + + argument_comments_args = ['-p', meson.project_build_root(), '--root', meson.project_source_root()] + foreach source_dir, source_dir_sources : argument_comments_sources + test( + 'argument-comments-@0@'.format(source_dir), + check_argument_comments_py, + args : argument_comments_args + source_dir_sources, + suite : 'argument-comments', + depends : generated_sources, + is_parallel : false, # the script parallelizes over its files by itself + timeout : 300, + ) + endforeach endif spatch = find_program('spatch', required : false) diff --git a/tools/meson.build b/tools/meson.build index e22ff11f983..da77368f644 100644 --- a/tools/meson.build +++ b/tools/meson.build @@ -1,6 +1,7 @@ # SPDX-License-Identifier: LGPL-2.1-or-later check_api_docs_sh = files('check-api-docs.sh') +check_argument_comments_py = files('check-argument-comments.py') check_coccinelle_sh = files('check-coccinelle.sh') check_efi_alignment_py = files('check-efi-alignment.py') check_help_sh = files('check-help.sh')