Attention is currently required from: Thomas Heijligen, Anastasia Klimchuk.
Evan Benn has uploaded this change for review.
meson: Move meson tests config to top level build file
meson has a bug with code coverage, moving the test to the top level
build file works around this bug.
https://github.com/mesonbuild/meson/issues/6747
BUG=b:187647884
BRANCH=None
TEST=meson test
Change-Id: Ibba93037831fc0ed526f701cbe360b5a493895d1
Signed-off-by: Evan Benn <evanbenn@chromium.org>
---
M meson.build
D tests/meson.build
2 files changed, 131 insertions(+), 126 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/65/69265/1
diff --git a/meson.build b/meson.build
index 3a6cc41..72ba6d7 100644
--- a/meson.build
+++ b/meson.build
@@ -621,7 +621,7 @@
)
flashrom_test_dep = declare_dependency(
- include_directories : include_dir,
+ include_directories : include_directories('include', 'tests', 'tests/include'),
sources : [
srcs,
'cli_common.c',
@@ -637,9 +637,118 @@
],
)
- if cmocka_dep.found()
- subdir('tests')
+ test_srcs = files(
+ 'tests/io_mock.c',
+ 'tests/tests.c',
+ 'tests/libusb_wraps.c',
+ 'tests/helpers.c',
+ 'tests/flashrom.c',
+ 'tests/spi25.c',
+ 'tests/lifecycle.c',
+ 'tests/dummyflasher.c',
+ 'tests/nicrealtek.c',
+ 'tests/raiden_debug_spi.c',
+ 'tests/dediprog.c',
+ 'tests/linux_mtd.c',
+ 'tests/linux_spi.c',
+ 'tests/parade_lspcon.c',
+ 'tests/mediatek_i2c_spi.c',
+ 'tests/realtek_mst_i2c_spi.c',
+ 'tests/layout.c',
+ 'tests/chip.c',
+ 'tests/chip_wp.c',
+ )
+
+ if not programmer.get('dummy').get('active')
+ test_srcs += programmer.get('dummy').get('srcs')
endif
+
+ mocks = [
+ '-Wl,--wrap=strdup',
+ '-Wl,--wrap=physunmap',
+ '-Wl,--wrap=physmap',
+ '-Wl,--wrap=pcidev_init',
+ '-Wl,--wrap=pcidev_readbar',
+ '-Wl,--wrap=spi_send_command',
+ '-Wl,--wrap=sio_write',
+ '-Wl,--wrap=sio_read',
+ '-Wl,--wrap=open',
+ '-Wl,--wrap=open64',
+ '-Wl,--wrap=__open64_2',
+ '-Wl,--wrap=ioctl',
+ '-Wl,--wrap=read',
+ '-Wl,--wrap=write',
+ '-Wl,--wrap=fopen',
+ '-Wl,--wrap=fopen64',
+ '-Wl,--wrap=fdopen',
+ '-Wl,--wrap=fwrite',
+ '-Wl,--wrap=fflush',
+ '-Wl,--wrap=stat',
+ '-Wl,--wrap=stat64',
+ '-Wl,--wrap=__xstat',
+ '-Wl,--wrap=__xstat64',
+ '-Wl,--wrap=fstat',
+ '-Wl,--wrap=fstat64',
+ '-Wl,--wrap=__fxstat',
+ '-Wl,--wrap=__fxstat64',
+ '-Wl,--wrap=fileno',
+ '-Wl,--wrap=fsync',
+ '-Wl,--wrap=fread',
+ '-Wl,--wrap=fgets',
+ '-Wl,--wrap=__fgets_chk',
+ '-Wl,--wrap=fprintf',
+ '-Wl,--wrap=__vfprintf_chk',
+ '-Wl,--wrap=fclose',
+ '-Wl,--wrap=feof',
+ '-Wl,--wrap=ferror',
+ '-Wl,--wrap=clearerr',
+ '-Wl,--wrap=setvbuf',
+ '-Wl,--wrap=rget_io_perms',
+ '-Wl,--wrap=OUTB',
+ '-Wl,--wrap=INB',
+ '-Wl,--wrap=OUTW',
+ '-Wl,--wrap=INW',
+ '-Wl,--wrap=OUTL',
+ '-Wl,--wrap=INL',
+ '-Wl,--wrap=usb_dev_get_by_vid_pid_number',
+ '-Wl,--wrap=libusb_init',
+ '-Wl,--wrap=libusb_open',
+ '-Wl,--wrap=libusb_set_auto_detach_kernel_driver',
+ '-Wl,--wrap=libusb_detach_kernel_driver',
+ '-Wl,--wrap=libusb_attach_kernel_driver',
+ '-Wl,--wrap=libusb_get_device_list',
+ '-Wl,--wrap=libusb_free_device_list',
+ '-Wl,--wrap=libusb_get_bus_number',
+ '-Wl,--wrap=libusb_get_device_address',
+ '-Wl,--wrap=libusb_get_device_descriptor',
+ '-Wl,--wrap=libusb_get_config_descriptor',
+ '-Wl,--wrap=libusb_free_config_descriptor',
+ '-Wl,--wrap=libusb_get_configuration',
+ '-Wl,--wrap=libusb_set_configuration',
+ '-Wl,--wrap=libusb_claim_interface',
+ '-Wl,--wrap=libusb_control_transfer',
+ '-Wl,--wrap=libusb_release_interface',
+ '-Wl,--wrap=libusb_ref_device',
+ '-Wl,--wrap=libusb_unref_device',
+ '-Wl,--wrap=libusb_close',
+ '-Wl,--wrap=libusb_exit',
+ '-Wl,--gc-sections',
+ ]
+
+ # The test is declared here to work around a meson code coverage bug:
+ # https://github.com/mesonbuild/meson/issues/6747
+ flashrom_tests = executable('flashrom_unit_tests',
+ test_srcs,
+ c_args : [
+ cargs,
+ '-ffunction-sections',
+ '-fdata-sections',
+ ],
+ export_dynamic : true,
+ link_args : mocks,
+ dependencies : [cmocka_dep, flashrom_test_dep],
+ )
+ test('cmocka test flashrom', flashrom_tests, timeout: 60)
endif
programmer_names_active = []
diff --git a/tests/meson.build b/tests/meson.build
deleted file mode 100644
index c62cc1b..0000000
--- a/tests/meson.build
+++ /dev/null
@@ -1,123 +0,0 @@
-# This file is part of the flashrom project.
-#
-# Copyright 2020 Google LLC
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; version 2 of the License.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-srcs = files(
- 'io_mock.c',
- 'tests.c',
- 'libusb_wraps.c',
- 'helpers.c',
- 'flashrom.c',
- 'spi25.c',
- 'lifecycle.c',
- 'dummyflasher.c',
- 'nicrealtek.c',
- 'raiden_debug_spi.c',
- 'dediprog.c',
- 'linux_mtd.c',
- 'linux_spi.c',
- 'parade_lspcon.c',
- 'mediatek_i2c_spi.c',
- 'realtek_mst_i2c_spi.c',
- 'layout.c',
- 'chip.c',
- 'chip_wp.c',
-)
-
-if not programmer.get('dummy').get('active')
- srcs += programmer.get('dummy').get('srcs')
-endif
-
-mocks = [
- '-Wl,--wrap=strdup',
- '-Wl,--wrap=physunmap',
- '-Wl,--wrap=physmap',
- '-Wl,--wrap=pcidev_init',
- '-Wl,--wrap=pcidev_readbar',
- '-Wl,--wrap=spi_send_command',
- '-Wl,--wrap=sio_write',
- '-Wl,--wrap=sio_read',
- '-Wl,--wrap=open',
- '-Wl,--wrap=open64',
- '-Wl,--wrap=__open64_2',
- '-Wl,--wrap=ioctl',
- '-Wl,--wrap=read',
- '-Wl,--wrap=write',
- '-Wl,--wrap=fopen',
- '-Wl,--wrap=fopen64',
- '-Wl,--wrap=fdopen',
- '-Wl,--wrap=fwrite',
- '-Wl,--wrap=fflush',
- '-Wl,--wrap=stat',
- '-Wl,--wrap=stat64',
- '-Wl,--wrap=__xstat',
- '-Wl,--wrap=__xstat64',
- '-Wl,--wrap=fstat',
- '-Wl,--wrap=fstat64',
- '-Wl,--wrap=__fxstat',
- '-Wl,--wrap=__fxstat64',
- '-Wl,--wrap=fileno',
- '-Wl,--wrap=fsync',
- '-Wl,--wrap=fread',
- '-Wl,--wrap=fgets',
- '-Wl,--wrap=__fgets_chk',
- '-Wl,--wrap=fprintf',
- '-Wl,--wrap=__vfprintf_chk',
- '-Wl,--wrap=fclose',
- '-Wl,--wrap=feof',
- '-Wl,--wrap=ferror',
- '-Wl,--wrap=clearerr',
- '-Wl,--wrap=setvbuf',
- '-Wl,--wrap=rget_io_perms',
- '-Wl,--wrap=OUTB',
- '-Wl,--wrap=INB',
- '-Wl,--wrap=OUTW',
- '-Wl,--wrap=INW',
- '-Wl,--wrap=OUTL',
- '-Wl,--wrap=INL',
- '-Wl,--wrap=usb_dev_get_by_vid_pid_number',
- '-Wl,--wrap=libusb_init',
- '-Wl,--wrap=libusb_open',
- '-Wl,--wrap=libusb_set_auto_detach_kernel_driver',
- '-Wl,--wrap=libusb_detach_kernel_driver',
- '-Wl,--wrap=libusb_attach_kernel_driver',
- '-Wl,--wrap=libusb_get_device_list',
- '-Wl,--wrap=libusb_free_device_list',
- '-Wl,--wrap=libusb_get_bus_number',
- '-Wl,--wrap=libusb_get_device_address',
- '-Wl,--wrap=libusb_get_device_descriptor',
- '-Wl,--wrap=libusb_get_config_descriptor',
- '-Wl,--wrap=libusb_free_config_descriptor',
- '-Wl,--wrap=libusb_get_configuration',
- '-Wl,--wrap=libusb_set_configuration',
- '-Wl,--wrap=libusb_claim_interface',
- '-Wl,--wrap=libusb_control_transfer',
- '-Wl,--wrap=libusb_release_interface',
- '-Wl,--wrap=libusb_ref_device',
- '-Wl,--wrap=libusb_unref_device',
- '-Wl,--wrap=libusb_close',
- '-Wl,--wrap=libusb_exit',
- '-Wl,--gc-sections',
-]
-
-flashrom_tests = executable('flashrom_unit_tests',
- srcs,
- c_args : [
- cargs,
- '-ffunction-sections',
- '-fdata-sections',
- ],
- export_dynamic : true,
- link_args : mocks,
- dependencies : [cmocka_dep, flashrom_test_dep],
-)
-test('cmocka test flashrom', flashrom_tests)
To view, visit change 69265. To unsubscribe, or for help writing mail filters, visit settings.