-
Notifications
You must be signed in to change notification settings - Fork 201
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests/ctests: Build ctests separately
At present the ctests are not properly linked with the built code, this causes issues when there are interdependencies between the modules. The meson build system does not appear to have support for internal build order or dependncies, so the only way I have found to make this work is to break out the build of the ctests as a separate project. This is required to avoid undefined symbols in the test code for the next patch in this series. Signed-off-by: Frode Nordahl <[email protected]>
- Loading branch information
Showing
6 changed files
with
49 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/sh | ||
|
||
BUILDDIR="$1"; shift | ||
meson setup ${BUILDDIR} $* | ||
meson compile -C ${BUILDDIR} --verbose | ||
|
||
if [ "$(basename $0)" = "run.sh" ]; then | ||
meson test -C ${BUILDDIR} | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,10 @@ | ||
project('ctests', 'c') | ||
|
||
add_project_arguments( | ||
'-DSBINDIR="' + join_paths(get_option('prefix'), get_option('sbindir')) + '"', | ||
'-D_GNU_SOURCE', | ||
language: 'c') | ||
|
||
tests = { | ||
'test_netplan_parser': false, | ||
'test_netplan_state': false, | ||
|
@@ -10,15 +17,25 @@ tests = { | |
'test_netplan_openvswitch': false, | ||
} | ||
|
||
glib = dependency('glib-2.0') | ||
gio = dependency('gio-2.0') | ||
yaml = dependency('yaml-0.1') | ||
uuid = dependency('uuid') | ||
cmocka = dependency('cmocka', required: true) | ||
netplan = meson.get_compiler('c').find_library( | ||
'netplan', | ||
dirs: [join_paths(get_option('parent_current_build_dir'), 'src')]) | ||
|
||
foreach name, should_fail: tests | ||
exe = executable(name, | ||
'@[email protected]'.format(name), | ||
include_directories: [inc, inc_internal], | ||
dependencies: [cmocka, glib, gio, yaml, uuid], | ||
include_directories: [ | ||
join_paths(get_option('parent_current_source_dir'), 'include'), | ||
join_paths(get_option('parent_current_source_dir'), 'src'), | ||
], | ||
dependencies: [cmocka, glib, gio, yaml, uuid, netplan], | ||
c_args: [ | ||
'-DFIXTURESDIR="' + meson.project_source_root() + '/tests/ctests/fixtures"', | ||
'-DFIXTURESDIR="' + meson.project_source_root() + '/fixtures"', | ||
'-Wno-deprecated-declarations', | ||
'-D_GNU_SOURCE', | ||
], | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
option('parent_current_source_dir', type: 'string', value: '') | ||
option('parent_current_build_dir', type: 'string', value: '') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
build.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters