From: Tomas Krizek Date: Thu, 31 Jan 2019 11:46:48 +0000 (+0100) Subject: meson: tests - unit tests without coverage X-Git-Tag: v4.0.0~24^2~209 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e5c065680cfa8c8170ebe90bc9bfb54f6637c6d6;p=thirdparty%2Fknot-resolver.git meson: tests - unit tests without coverage --- diff --git a/meson.build b/meson.build index 2d50ecd32..9552c2a3e 100644 --- a/meson.build +++ b/meson.build @@ -22,7 +22,6 @@ luajit = dependency('luajit') # Optional dependencies ## tests -cmocka = dependency('cmocka', required: false) socket_wrapper = dependency('socket_wrapper', required: false) ## coverage @@ -75,6 +74,10 @@ subdir('daemon') subdir('modules') +# tests +subdir('tests') + + # documentation, install, tests # TODO install man subdir('doc') diff --git a/tests/meson.build b/tests/meson.build new file mode 100644 index 000000000..c7b66a87a --- /dev/null +++ b/tests/meson.build @@ -0,0 +1,56 @@ +# Unit tests +unit_tests = [ + 'test_array', + #'test_cache', # TODO: re-consider how best to test cache + 'test_lru', + 'test_map', + 'test_module', + 'test_pack', + 'test_queue', + 'test_rplan', + 'test_set', + 'test_trie', + 'test_utils', + 'test_zonecut', +] + +# dependency +cmocka = dependency('cmocka', required: false) + +if cmocka.found() + + # mock module for test_module + mock_cmodule_src = [ + 'mock_cmodule.c', + ] + + mock_cmodule_lib = library( + 'mock_cmodule', + mock_cmodule_src, + name_prefix: '', + dependencies: libkres_dep, + ) + + mock_cmodule_dep = declare_dependency( + link_with: mock_cmodule_lib, + ) + + # executables with tests + foreach unit_test : unit_tests + exec_test = executable( + unit_test, + unit_test + '.c', + dependencies: [ + contrib_dep, + libkres_dep, + cmocka, + lmdb, + ], + ) + test( + unit_test, + exec_test, + suite: 'unit', + ) + endforeach +endif