Skip to content

Commit 98688cd

Browse files
author
Martin Belanger
committed
test: add unit tests for static helpers in fabrics.c
Adds libnvme/test/test-fabrics.c, which tests the static helper functions in src/nvme/fabrics.c without modifying any production source. The technique is to define 'static' to nothing and then #include the source file directly. This exposes all translation-unit-local symbols in the test binary. No #ifdef UNIT_TEST guards or visibility changes are needed — the production files are left completely untouched. Functions covered: strchomp, hostid_from_hostnqn, __add_bool_argument, __add_hex_argument, __add_int_argument, __add_int_or_minus_one_argument, __add_argument, inet4_pton, inet_pton_with_scope, traddr_is_hostname, unescape_uri The test is gated on want_fabrics in meson.build, matching the conditional that guards the uriparser test above it. Signed-off-by: Martin Belanger <[email protected]>
1 parent 17a4f8c commit 98688cd

2 files changed

Lines changed: 563 additions & 1 deletion

File tree

libnvme/test/meson.build

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,19 @@ if want_fabrics
126126
],
127127
)
128128

129-
test('libnvme - uriparser', uriparser)
129+
test('libnvme - uriparser', uriparser)
130+
131+
test_fabrics = executable(
132+
'test-fabrics',
133+
['test-fabrics.c'],
134+
dependencies: [
135+
config_dep,
136+
ccan_dep,
137+
libnvme_test_dep,
138+
],
139+
)
140+
141+
test('libnvme - fabrics', test_fabrics)
130142
endif
131143

132144
if conf.get('HAVE_NETDB')

0 commit comments

Comments
 (0)