]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
meson: tests: add test binaries build support
authorPavel Hrdina <phrdina@redhat.com>
Thu, 25 Jun 2020 11:05:51 +0000 (13:05 +0200)
committerPavel Hrdina <phrdina@redhat.com>
Mon, 3 Aug 2020 07:27:05 +0000 (09:27 +0200)
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
tests/Makefile.am
tests/meson.build

index 9f5f5d12fb4a127f4332cdd6cf85b0a2f84e4713..1c467f5719333da5f4d2390649d92624aed1e1b3 100644 (file)
 ## License along with this library.  If not, see
 ## <http://www.gnu.org/licenses/>.
 
-PROBES_O =
-if WITH_DTRACE_PROBES
-PROBES_O += ../src/libvirt_probes.lo
-endif WITH_DTRACE_PROBES
-
-LDADDS = \
-       $(NO_INDIRECT_LDFLAGS) \
-       $(PROBES_O) \
-       ../src/libvirt.la \
-       $(GLIB_LIBS) \
-       $(NULL)
-
 test_programs = virshtest sockettest \
        virhostcputest virbuftest \
        commandtest seclabeltest \
index cdcb87453fcb3564faa20723720cc582b302ad59..a0dd204845d90fbdd1786424c6ffe24071899082 100644 (file)
@@ -228,3 +228,52 @@ executable(
     coverage_flags,
   ],
 )
+
+
+# build and define libvirt tests
+
+# tests:
+#   each entry is a dictionary with following items:
+#   * name - name of the test which is also used as default source file name (required)
+#   * sources - override default sources based on name (optional, default [ '$name.c' ])
+#   * c_args - args used by test (optional, default [])
+#   * deps - additional dependencies (optional, default [])
+#   * include - include_directories (optional, default [])
+#   * link_with - compiled libraries to link with (optional, default [])
+#   * link_whole - compiled libraries to link whole (optional, default [])
+
+tests = []
+
+foreach data : tests
+  test_sources = '@0@.c'.format(data['name'])
+  test_bin = executable(
+    data['name'],
+    [
+      data.get('sources', test_sources),
+      dtrace_gen_objects,
+    ],
+    c_args: [
+      data.get('c_args', []),
+    ],
+    dependencies: [
+      tests_dep,
+      data.get('deps', []),
+    ],
+    include_directories: [
+      data.get('include', []),
+    ],
+    link_args: [
+      libvirt_no_indirect,
+    ],
+    link_with: [
+      libvirt_lib,
+      data.get('link_with', []),
+    ],
+    link_whole: [
+      test_utils_lib,
+      data.get('link_whole', []),
+    ],
+    export_dynamic: true,
+  )
+  test(data['name'], test_bin, env: tests_env)
+endforeach