Skip to content

Commit

Permalink
Control sys/cdefs checking with new tests-cdefs option
Browse files Browse the repository at this point in the history
This is a three/way (true/false/auto) option which selects whether to
validate the include files for correctly including sys/cdefs.h. When
set to 'auto', then these tests are enabled if the regular libary
tests are enabled.

Signed-off-by: Keith Packard <keithp@keithp.com>
  • Loading branch information
keith-packard committed Jul 26, 2024
1 parent f0f279b commit 3f13cf3
Show file tree
Hide file tree
Showing 20 changed files with 26 additions and 19 deletions.
7 changes: 6 additions & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,11 @@ enable_picocrt = get_option('picocrt')
enable_picocrt_lib = get_option('picocrt-lib')
enable_semihost = get_option('semihost')
enable_tests = get_option('tests')
if get_option('tests-cdefs') == 'auto'
enable_cdefs_tests = enable_tests
else
enable_cdefs_tests = get_option('tests-cdefs') == 'true'
endif
enable_native_tests = get_option('native-tests')
enable_native_math_tests = enable_native_tests and get_option('native-math-tests')
tests_enable_stack_protector = get_option('tests-enable-stack-protector')
Expand Down Expand Up @@ -260,7 +265,7 @@ if nm.found()
duplicate_names = find_program('scripts/duplicate-names', required : true)
endif

if enable_tests
if enable_cdefs_tests
validate_cdefs = find_program ('scripts/validate-cdefs', required : true)
endif

Expand Down
2 changes: 2 additions & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ option('native-math-tests', type: 'boolean', value: true,
description: 'Run math tests against native libm when native-tests is enable')
option('tests', type: 'boolean', value: false,
description: 'Enable tests')
option('tests-cdefs', type: 'combo', choices: ['true', 'false', 'auto'], value: 'auto',
description: 'Enable test of sys/cdefs.h. If set to auto, enable when tests are enabled')
option('tests-enable-stack-protector', type: 'boolean', value: true,
description: 'tests enable stack protector')
option('tests-enable-full-malloc-stress', type: 'boolean', value: false,
Expand Down
2 changes: 1 addition & 1 deletion newlib/libc/include/arpa/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ inc_arpa_headers = [
install_headers(inc_arpa_headers,
install_dir: include_dir / 'arpa')

if enable_tests
if enable_cdefs_tests
ignore_headers = []
foreach header : inc_arpa_headers
if not (header in ignore_headers) and not (header.startswith('_'))
Expand Down
2 changes: 1 addition & 1 deletion newlib/libc/include/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ install_headers(inc_headers,
install_headers(['bits/types/mbstate_t.h'],
install_dir: include_dir / 'bits/types')

if enable_tests
if enable_cdefs_tests

ignore_headers = ['cpio.h', 'paths.h', 'termios.h', 'newlib.h', 'regdef.h', 'tar.h', 'utmp.h']
foreach header : inc_headers
Expand Down
2 changes: 1 addition & 1 deletion newlib/libc/include/rpc/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ inc_rpc_headers = [
install_headers(inc_rpc_headers,
install_dir: include_dir / 'rpc')

if enable_tests
if enable_cdefs_tests
ignore_headers = []
foreach header : inc_rpc_headers
if not (header in ignore_headers) and not (header.startswith('_'))
Expand Down
2 changes: 1 addition & 1 deletion newlib/libc/include/sys/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ endforeach
install_headers(inc_sys_headers,
install_dir: include_dir / 'sys')

if enable_tests
if enable_cdefs_tests
ignore_headers = ['config.h', 'features.h', 'string.h', 'custom_file.h', 'dirent.h']
foreach header : inc_sys_headers
if not (header in ignore_headers) and not (header.startswith('_'))
Expand Down
2 changes: 1 addition & 1 deletion newlib/libc/machine/aarch64/sys/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ inc_sys_headers_machine = [
install_headers(inc_sys_headers_machine,
install_dir: include_dir / 'sys')

if enable_tests
if enable_cdefs_tests
ignore_headers = []
foreach header : inc_sys_headers_machine
if not (header in ignore_headers) and not (header.startswith('_'))
Expand Down
2 changes: 1 addition & 1 deletion newlib/libc/machine/arm/sys/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ inc_sys_headers_machine = [
install_headers(inc_sys_headers_machine,
install_dir: include_dir / 'sys')

if enable_tests
if enable_cdefs_tests
ignore_headers = []
foreach header : inc_sys_headers_machine
if not (header in ignore_headers) and not (header.startswith('_'))
Expand Down
2 changes: 1 addition & 1 deletion newlib/libc/machine/m68k/sys/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ inc_sys_headers_machine = [
install_headers(inc_sys_headers_machine,
install_dir: include_dir / 'sys')

if enable_tests
if enable_cdefs_tests
ignore_headers = []
foreach header : inc_sys_headers_machine
if not (header in ignore_headers) and not (header.startswith('_'))
Expand Down
2 changes: 1 addition & 1 deletion newlib/libc/machine/mips/sys/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ inc_sys_headers_machine = [
install_headers(inc_sys_headers_machine,
install_dir: include_dir / 'sys')

if enable_tests
if enable_cdefs_tests
ignore_headers = []
foreach header : inc_sys_headers_machine
if not (header in ignore_headers) and not (header.startswith('_'))
Expand Down
2 changes: 1 addition & 1 deletion newlib/libc/machine/powerpc/sys/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ inc_sys_headers_machine = [
install_headers(inc_sys_headers_machine,
install_dir: include_dir / 'sys')

if enable_tests
if enable_cdefs_tests
ignore_headers = []
foreach header : inc_sys_headers_machine
if not (header in ignore_headers) and not (header.startswith('_'))
Expand Down
2 changes: 1 addition & 1 deletion newlib/libc/machine/riscv/sys/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ inc_sys_headers_machine = [
install_headers(inc_sys_headers_machine,
install_dir: include_dir / 'sys')

if enable_tests
if enable_cdefs_tests
ignore_headers = []
foreach header : inc_sys_headers_machine
if not (header in ignore_headers) and not (header.startswith('_'))
Expand Down
2 changes: 1 addition & 1 deletion newlib/libc/machine/sh/sys/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ inc_sys_headers_machine = [
install_headers(inc_sys_headers_machine,
install_dir: include_dir / 'sys')

if enable_tests
if enable_cdefs_tests
ignore_headers = []
foreach header : inc_sys_headers_machine
if not (header in ignore_headers) and not (header.startswith('_'))
Expand Down
2 changes: 1 addition & 1 deletion newlib/libc/machine/sparc/sys/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ inc_sys_headers_machine = [
install_headers(inc_sys_headers_machine,
install_dir: include_dir / 'sys')

if enable_tests
if enable_cdefs_tests
ignore_headers = []
foreach header : inc_sys_headers_machine
if not (header in ignore_headers) and not (header.startswith('_'))
Expand Down
2 changes: 1 addition & 1 deletion newlib/libc/machine/x86/sys/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ inc_sys_headers_machine = [
install_headers(inc_sys_headers_machine,
install_dir: include_dir / 'sys')

if enable_tests
if enable_cdefs_tests
ignore_headers = []
foreach header : inc_sys_headers_machine
if not (header in ignore_headers) and not (header.startswith('_'))
Expand Down
2 changes: 1 addition & 1 deletion newlib/libc/machine/xtensa/sys/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ inc_sys_headers_machine = [
install_headers(inc_sys_headers_machine,
install_dir: include_dir / 'sys')

if enable_tests
if enable_cdefs_tests
ignore_headers = []
foreach header : inc_sys_headers_machine
if not (header in ignore_headers) and not (header.startswith('_'))
Expand Down
2 changes: 1 addition & 1 deletion newlib/libc/stdio/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ endforeach

src_stdio = files(srcs_stdio_use)

if enable_tests
if enable_cdefs_tests
foreach header : inc_headers
test_name = 'check-cdef-' + header
test(test_name,
Expand Down
2 changes: 1 addition & 1 deletion newlib/libc/stdio/sys/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ endforeach
install_headers(inc_stdio_sys_headers,
install_dir: include_dir / 'sys')

if enable_tests
if enable_cdefs_tests
foreach header : inc_stdio_sys_headers
test_name = 'check-cdef-sys-' + header
test(test_name,
Expand Down
2 changes: 1 addition & 1 deletion newlib/libc/tinystdio/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ endforeach

src_tinystdio = files(srcs_tinystdio_use)

if enable_tests
if enable_cdefs_tests
foreach header : inc_headers
test_name = 'check-cdef-' + header
test(test_name,
Expand Down
2 changes: 1 addition & 1 deletion semihost/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ if src_semihost != []

endforeach

if enable_tests
if enable_cdefs_tests
ignore_headers = []
foreach header : inc_headers

Expand Down

0 comments on commit 3f13cf3

Please sign in to comment.