Thomas Heijligen submitted this change.

View Change

Approvals: build bot (Jenkins): Verified Felix Singer: Looks good to me, but someone else must approve Angel Pons: Looks good to me, approved Anastasia Klimchuk: Looks good to me, approved
meson: add option to disable tests

During development it can be useful to disable unit testing. By default
tests are built if cmocka is found. To force enable tests run `meson
build -Dtests=enable`. To disable tests run `meson build
-Dtests=disabled`.

Change-Id: I384c904c577b265dfe36bf46bf07c641bc29de9b
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/63832
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Reviewed-by: Felix Singer <felixsinger@posteo.net>
---
M meson.build
M meson_options.txt
2 files changed, 29 insertions(+), 23 deletions(-)

diff --git a/meson.build b/meson.build
index f9a0455..a783bdd 100644
--- a/meson.build
+++ b/meson.build
@@ -506,30 +506,35 @@

subdir('util')

+# Use `.auto() or .enabled()` instead of `.allowed()` to keep the minimum meson version as low as possible.
+# `.allowed()` gets introduced in 0.59.0
+if get_option('tests').auto() or get_option('tests').enabled()
# unit-test framework
cmocka_dep = dependency(
- 'cmocka',
- fallback: ['cmocka', 'cmocka_dep'],
- required: false
-)
-flashrom_test_dep = declare_dependency(
- include_directories : include_dir,
- sources : [
- srcs,
- 'cli_common.c',
- 'cli_output.c',
- 'flashrom.c',
- ],
- compile_args : [
- '-includestdlib.h',
- '-includeunittest_env.h',
- '-includehwaccess_x86_io_unittest.h'
- ],
- dependencies : [
- deps,
- ],
-)
+ 'cmocka',
+ fallback: ['cmocka', 'cmocka_dep'],
+ required : get_option('tests')
+ )

-if cmocka_dep.found()
- subdir('tests')
+ flashrom_test_dep = declare_dependency(
+ include_directories : include_dir,
+ sources : [
+ srcs,
+ 'cli_common.c',
+ 'cli_output.c',
+ 'flashrom.c',
+ ],
+ compile_args : [
+ '-includestdlib.h',
+ '-includeunittest_env.h',
+ '-includehwaccess_x86_io_unittest.h'
+ ],
+ dependencies : [
+ deps,
+ ],
+ )
+
+ if cmocka_dep.found()
+ subdir('tests')
+ endif
endif
diff --git a/meson_options.txt b/meson_options.txt
index 8022c74..46ac763 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -42,3 +42,4 @@
option('config_lspcon_i2c_spi', type : 'boolean', value : false, description : 'Parade lspcon USB-C to HDMI protocol translator')
option('config_mediatek_i2c_spi', type : 'boolean', value : false, description : 'MediaTek LCD controller')
option('config_realtek_mst_i2c_spi', type : 'boolean', value : true, description : 'Realtek MultiStream Transport MST')
+option('tests', type : 'feature', value : 'auto', description : 'Build unit tests')

8 is the latest approved patch-set. No files were changed between the latest approved patch-set and the submitted one.

To view, visit change 63832. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I384c904c577b265dfe36bf46bf07c641bc29de9b
Gerrit-Change-Number: 63832
Gerrit-PatchSet: 10
Gerrit-Owner: Thomas Heijligen <src@posteo.de>
Gerrit-Reviewer: Anastasia Klimchuk <aklm@chromium.org>
Gerrit-Reviewer: Angel Pons <th3fanbus@gmail.com>
Gerrit-Reviewer: Edward O'Callaghan <quasisec@chromium.org>
Gerrit-Reviewer: Felix Singer <felixsinger@posteo.net>
Gerrit-Reviewer: Peter Marheine <pmarheine@chromium.org>
Gerrit-Reviewer: Thomas Heijligen <src@posteo.de>
Gerrit-Reviewer: build bot (Jenkins) <no-reply@coreboot.org>
Gerrit-CC: Paul Menzel <paulepanter@mailbox.org>
Gerrit-MessageType: merged