]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
meson: tests - unit tests without coverage
authorTomas Krizek <tomas.krizek@nic.cz>
Thu, 31 Jan 2019 11:46:48 +0000 (12:46 +0100)
committerTomas Krizek <tomas.krizek@nic.cz>
Tue, 12 Mar 2019 09:41:53 +0000 (10:41 +0100)
meson.build
tests/meson.build [new file with mode: 0644]

index 2d50ecd32a5621ee6b025ad38acdd16ca375fc6d..9552c2a3e660d2b08e9afa15dee35bde9d9660f3 100644 (file)
@@ -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 (file)
index 0000000..c7b66a8
--- /dev/null
@@ -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