]> www.infradead.org Git - users/sagi/libnvme.git/commitdiff
test: define separate library for MI unit tests
authorJeremy Kerr <jk@codeconstruct.com.au>
Thu, 23 Jun 2022 11:35:25 +0000 (19:35 +0800)
committerJeremy Kerr <jk@codeconstruct.com.au>
Thu, 23 Jun 2022 11:39:30 +0000 (19:39 +0800)
We previously exposed a couple of internal functions for libnvme-mi.so
in ce4a044720. However, Daniel Wagner has suggest instead using a
separate shared library with all symbols visible, just for the unit
test.

This change reverts the symbol visibility changes for the installed
libnvme-mi.so, and defines a separate, non-installed library for the MI
unit tests. This is the same as libnvme-mi.so, but has no linker script
or versioning information.

This means we're not exposing the init_ep and crc32 functions in the
actual .so, but can still allow unit tests to access non-public symbols.
The coverage reports can handle the separate library just fine, as the
coverage data is correlated on the underlying source files.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
src/libnvme-mi.map
src/meson.build
test/meson.build

index 83c7e5f069a29df9c9473ecb7af354052974a295..cad72afdf0a5effb22a486bbe30db0bd946f56d8 100644 (file)
@@ -19,11 +19,3 @@ LIBNVME_MI_1_1 {
        local:
                *;
 };
-# API exported only for libnvme-mi internal test functions. These should
-# not be used other than through the in-tree tests, and cannot be considered
-# at all stable.
-LIBNVME_MI_TEST {
-       global:
-               nvme_mi_init_ep;
-               nvme_mi_crc32_update;
-};
index f738cda5c72b4f65562cf87c5a30ed0b272ddcab..05d61719974deede13fa5d9de3efc5411010d2c7 100644 (file)
@@ -93,6 +93,25 @@ libnvme_mi_dep = declare_dependency(
     link_with: libnvme_mi,
 )
 
+# test library with all symbols visible, to use for MI unit tests. Should
+# match libnvme_mi above, but with no version script, and install: false.
+libnvme_mi_test = library(
+    'nvme-mi-test', # produces libnvme-mi-test.so
+    mi_sources,
+    dependencies: mi_deps,
+    include_directories: [incdir, internal_incdir],
+    install: false,
+    link_with: libccan,
+)
+
+libnvme_mi_test_dep = declare_dependency(
+    include_directories: ['.'],
+    dependencies: [
+      libuuid_dep.partial_dependency(compile_args: true, includes: true),
+    ],
+    link_with: libnvme_mi_test,
+)
+
 pkg.generate(libnvme_mi,
     filebase: 'libnvme-mi',
     name: 'libnvme-mi',
index 8324ed131adc122948d44ec65a8e57e791b0b9bf..bbd112c80fe5eb91469951adc0161ac8fa47fdcc 100644 (file)
@@ -42,7 +42,7 @@ zns = executable(
 mi = executable(
     'test-mi',
     ['mi.c'],
-    dependencies: libnvme_mi_dep,
+    dependencies: libnvme_mi_test_dep,
     include_directories: [incdir, internal_incdir]
 )