meson: Build and run unit tests

This commit is contained in:
Dima Krasner 2019-08-22 10:19:25 +03:00 committed by Andreas Schneider
parent aed0d9dd55
commit 33d48bfaa7
3 changed files with 35 additions and 0 deletions

View File

@ -41,3 +41,7 @@ pkgconfig.generate(libraries : [libcmocka],
name : 'cmocka',
filebase : 'cmocka',
description : 'The cmocka unit testing library')
if get_option('unit_testing')
subdir('tests')
endif

1
meson_options.txt Normal file
View File

@ -0,0 +1 @@
option('unit_testing', type: 'boolean', value: false)

30
tests/meson.build Normal file
View File

@ -0,0 +1,30 @@
tests = {
'alloc': false,
'group_setup_assert': true,
'group_setup_fail': true,
'fixtures': false,
'group_fixtures': false,
'groups': false,
'float_macros': false,
'assert_macros': false,
'assert_macros_fail': true,
'basics': false,
'skip': false,
'strmatch': false,
'setup_fail': true,
'ordering': false,
'ordering_fail': true,
'returns': false,
'returns_fail': true,
'wildcard': false,
'skip_filter': false,
'cmockery': false
}
foreach name, should_fail: tests
exe = executable(name,
'test_@0@.c'.format(name),
include_directories: [cmocka_includes],
link_with: [libcmocka])
test(name, exe, should_fail: should_fail)
endforeach