Skip to content

Commit

Permalink
autotest: meson build script clean up
Browse files Browse the repository at this point in the history
unselected test were built and may failed if the corresponding feature
is not available and/or not defined un devicetree (e.g. SHM)
  • Loading branch information
fvalette-ledger committed Jan 6, 2025
1 parent 1ae1963 commit 1d26e31
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 32 deletions.
8 changes: 7 additions & 1 deletion autotest/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ if BUILD_TARGET_AUTOTEST

menu "Autotest configuration"

config AUTOTEST_TIMER_DRIVER
bool
default n

config TEST_YIELD
bool "yield test suite"
default y
Expand Down Expand Up @@ -46,11 +50,13 @@ config TEST_SHM
default y

config TEST_DMA
bool "Shared memory manipulation test suite"
bool "Direct Memory Access test suite"
select TEST_SHM
default n

config TEST_IRQ
bool "User interrupts test suite, need timer support at autotest level"
select AUTOTEST_TIMER_DRIVER
default n

endmenu
Expand Down
16 changes: 10 additions & 6 deletions autotest/include/meson.build
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
# SPDX-FileCopyrightText: 2023-2024 Ledger SAS
# SPDX-FileCopyrightText: 2023 - 2025 Ledger SAS
# SPDX-License-Identifier: Apache-2.0

autotest_inc = include_directories('.')

autotest_headerset.add(
files(
'testlib/assert.h',
'testlib/log.h',
)
)

devices_template_h = files(['devices-dt.h.in'])
devices_dtsgen_h = dtsgen.process(devices_template_h)
autotest_headerset.add(devices_dtsgen_h)

shm_template_h = files(['shms-dt.h.in'])
shm_dtsgen_h = dtsgen.process(shm_template_h)

autotest_headers = files(
'testlib/assert.h',
'testlib/log.h',
)
autotest_headerset.add(when: 'CONFIG_TEST_SHM', if_true: shm_dtsgen_h)
12 changes: 9 additions & 3 deletions autotest/meson.build
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2023-2024 Ledger SAS
# SPDX-FileCopyrightText: 2023 - 2025 Ledger SAS
# SPDX-License-Identifier: Apache-2.0

if not with_autotest
Expand All @@ -9,6 +9,8 @@ if meson.is_subproject()
warning('!!! Are you sure you want to build the autotest task as a subproject ?')
endif

ssmod = import('sourceset')

# local tool for easy ELF parsing to json file
parseelf = find_program('parseelf.py', required: true, dirs: [meson.project_source_root() / 'tools'])

Expand All @@ -21,11 +23,15 @@ userspace_args = [

# populated in src
autotest_ldscript_template = files()
autotest_drivers_src = []
autotest_sourceset = ssmod.source_set()
autotest_headerset = ssmod.source_set()

subdir('include')
subdir('src')

autotest_sources = autotest_sourceset.apply(kconfig_data, strict: false).sources()
autotest_headers = autotest_headerset.apply(kconfig_data, strict: false).sources()

autotest_ldscript = custom_target('autotest_ldscript',
input: autotest_ldscript_template,
output: '@BASENAME@',
Expand All @@ -45,7 +51,7 @@ uapi_inc = include_directories('../uapi/include')
autotest_elf = executable(
autotest_task_name,
name_suffix: 'elf',
sources: [autotest_sources, autotest_headers, devices_dtsgen_h, shm_dtsgen_h, autotest_drivers_src ],
sources: [ autotest_sources, autotest_headers ],
include_directories: [ uapi_inc, autotest_inc ],
dependencies: [ sentry_c_uapi_dep ],
c_args: [ target_arch_args, global_build_args, userspace_args ],
Expand Down
7 changes: 4 additions & 3 deletions autotest/src/drivers/timer/meson.build
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2024 Ledger SAS
# SPDX-FileCopyrightText: 2024 - 2025 Ledger SAS
# SPDX-License-Identifier: Apache-2.0

# NOTE: the timer identifier may vary from SoC familly to another, and as such
Expand All @@ -19,10 +19,11 @@ stm32_timer_dts_template_h = files('stm32-basic-timer-dt.h.in')
stm32_timer_dts_dtsgen_c = dtsgen.process(stm32_timer_dts_template_c)
stm32_timer_dts_dtsgen_h = dtsgen.process(stm32_timer_dts_template_h)

autotest_drivers_src += [
autotest_driver_timer_src += [
timer_h,
stm32_timer_dts_dtsgen_c,
stm32_timer_dts_dtsgen_h,
files('stm32-basic-timer.c'),
]

autotest_sources += files('stm32-basic-timer.c')
autotest_sourceset.add(when: 'CONFIG_AUTOTEST_TIMER_DRIVER', if_true: autotest_driver_timer_src)
29 changes: 10 additions & 19 deletions autotest/src/meson.build
Original file line number Diff line number Diff line change
@@ -1,27 +1,18 @@
# SPDX-FileCopyrightText: 2023 Ledger SAS
# SPDX-FileCopyrightText: 2023 - 2025 Ledger SAS
# SPDX-License-Identifier: Apache-2.0


# note: to avoid printf implementation redundancy, the kernel lexer for debug
# print mode is used as-is
autotest_sources = files(
'main.c',
'printf.c',
'ssp.c',
'tests/test_ipc.c',
'tests/test_signal.c',
'tests/test_handle.c',
'tests/test_sleep.c',
'tests/test_cycles.c',
'tests/test_yield.c',
'tests/test_random.c',
'tests/test_gpio.c',
'tests/test_map.c',
'tests/test_shm.c',
'tests/test_dma.c',
'tests/test_irq.c',
'../../kernel/src/managers/debug/log_lexer.c',

autotest_sourceset.add(
files(
'main.c',
'printf.c',
'ssp.c',
'../../kernel/src/managers/debug/log_lexer.c',
)
)

subdir('arch')
subdir('drivers')
subdir('tests')
15 changes: 15 additions & 0 deletions autotest/src/tests/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# SPDX-FileCopyrightText: 2023 - 2025 Ledger SAS
# SPDX-License-Identifier: Apache-2.0

autotest_sourceset.add(when: 'CONFIG_TEST_CYCLES', if_true: files('test_cycles.c'))
autotest_sourceset.add(when: 'CONFIG_TEST_DMA', if_true: files('test_dma.c'))
autotest_sourceset.add(when: 'CONFIG_TEST_GPIO', if_true: files('test_gpio.c'))
autotest_sourceset.add(when: 'CONFIG_TEST_HANDLE', if_true: files('test_handle.c'))
autotest_sourceset.add(when: 'CONFIG_TEST_IPC', if_true: files('test_ipc.c'))
autotest_sourceset.add(when: 'CONFIG_TEST_IRQ', if_true: files('test_irq.c'))
autotest_sourceset.add(when: 'CONFIG_TEST_MAP', if_true: files('test_map.c'))
autotest_sourceset.add(when: 'CONFIG_TEST_RANDOM', if_true: files('test_random.c'))
autotest_sourceset.add(when: 'CONFIG_TEST_SHM', if_true: files('test_shm.c'))
autotest_sourceset.add(when: 'CONFIG_TEST_SIGNAL', if_true: files('test_signal.c'))
autotest_sourceset.add(when: 'CONFIG_TEST_SLEEP', if_true: files('test_sleep.c'))
autotest_sourceset.add(when: 'CONFIG_TEST_YIELD', if_true: files('test_yield.c'))

0 comments on commit 1d26e31

Please sign in to comment.