summaryrefslogtreecommitdiffstats
path: root/tests/meson.build
diff options
context:
space:
mode:
authorAnastasia Klimchuk <aklm@chromium.org>2023-04-01 22:08:52 +1100
committerAnastasia Klimchuk <aklm@chromium.org>2023-04-27 07:40:44 +0000
commit7348eb3320d277aa1d42563009f77189701b47f0 (patch)
tree838ded489510310ebdad816726e167382136331c /tests/meson.build
parent256b04148085e71f499eed33644927320e35431b (diff)
downloadflashrom-7348eb3320d277aa1d42563009f77189701b47f0.tar.gz
flashrom-7348eb3320d277aa1d42563009f77189701b47f0.tar.bz2
flashrom-7348eb3320d277aa1d42563009f77189701b47f0.zip
tests: Emulate multithreading environment for unit tests
The main purpose of this patch is to run unit tests on BSD family of OSes. The root cause is `fileno` syscall which is a macro that can be expanded to either a function call (for multi-threaded environment) or to inline code (for single-threaded environment). Said inline code accesses private field of file descriptor, and this construction is impossible to mock in unit tests. Multi- threaded environment has `fileno` as a function, which can be mocked in unit tests. On other OSes the patch just creates a thread which is doing nothing. We avoid adding pre-processor conditionals since the cost is small. Tested on FreeBSD 13.1-RELEASE-p6 GENERIC amd64 NetBSD 9.2 (GENERIC) amd64 OpenBSD 7.2 GENERIC#7 amd64 DragonFly v6.4.0-RELEASE x86_64 Ubuntu 22.04.1 x86_64 Change-Id: I3d65c125183e60037ad07b9d54b8fffdece5a4e8 Signed-off-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/74157 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Peter Marheine <pmarheine@chromium.org> Reviewed-by: Thomas Heijligen <src@posteo.de>
Diffstat (limited to 'tests/meson.build')
-rw-r--r--tests/meson.build4
1 files changed, 3 insertions, 1 deletions
diff --git a/tests/meson.build b/tests/meson.build
index df866d732..94f60e270 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -113,6 +113,8 @@ mocks = [
'-Wl,--gc-sections',
]
+threads_dep = dependency('threads')
+
flashrom_tests = executable('flashrom_unit_tests',
test_srcs,
c_args : [
@@ -123,7 +125,7 @@ flashrom_tests = executable('flashrom_unit_tests',
],
export_dynamic : true,
link_args : mocks + link_args,
- dependencies : [cmocka_dep, flashrom_test_dep],
+ dependencies : [cmocka_dep, flashrom_test_dep, threads_dep],
)
test('cmocka test flashrom', flashrom_tests)