From 0509f853897334d547c44b10c36f6e289ef0f408 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Fri, 15 Nov 2019 09:36:36 +0000 Subject: [PATCH] tests: Add a way to write tests using libnbd. --- tests/Makefile.am | 9 +++++++++ tests/README.tests | 21 ++++++++++++++++----- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index bf27d6d8..bbc3ffab 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -176,6 +176,9 @@ endif HAVE_VDDK # # TESTS: Tests that don't have any special requirements. # +# LIBNBD_TESTS: Tests that link to the libnbd C library should be +# added to this variable. +# # LIBGUESTFS_TESTS: Tests that link to libguestfs C library should be # added to this variable. # @@ -183,6 +186,7 @@ endif HAVE_VDDK # Consult the automake manual for the meaning of these. TESTS = +LIBNBD_TESTS = LIBGUESTFS_TESTS = check_PROGRAMS = @@ -1112,6 +1116,11 @@ endif HAVE_PLUGINS #---------------------------------------------------------------------- +if HAVE_LIBNBD +check_PROGRAMS += $(LIBNBD_TESTS) +TESTS += $(LIBNBD_TESTS) +endif HAVE_LIBNBD + if HAVE_LIBGUESTFS check_PROGRAMS += $(LIBGUESTFS_TESTS) TESTS += $(LIBGUESTFS_TESTS) diff --git a/tests/README.tests b/tests/README.tests index 745ea0b3..568f6fb3 100644 --- a/tests/README.tests +++ b/tests/README.tests @@ -1,7 +1,5 @@ -The real tests use libguestfs as a convenient way to control the qemu -NBD client. - -To test a plugin using libguestfs: +To test a plugin using libguestfs +================================= - #include @@ -28,4 +26,17 @@ To test a plugin using libguestfs: - Close the handle and exit. An 'atexit' handler installed by 'test_start_nbdkit' cleans up the server automatically. -For an example, see 'test-file.c'. +For an example, see 'test-data.c'. + +To test a plugin using libnbd +============================= + + - Open a libnbd handle, and configure it using: + + char *args[] = { "nbdkit", "-s", "--exit-with-parent", + "plugin", , NULL }; + nbd_connect_command (nbd, args); + + - Perform tests via libnbd. + +For an example, see 'test-delay.c'. -- 2.11.4.GIT