|
|
fe7475 |
From 80b83f39a8b365455880d8dabbcb86249c1ecd6b Mon Sep 17 00:00:00 2001
|
|
|
fe7475 |
From: "Richard W.M. Jones" <rjones@redhat.com>
|
|
|
fe7475 |
Date: Wed, 25 Jul 2018 14:09:58 +0100
|
|
|
fe7475 |
Subject: [PATCH] vddk: Add a very simple test.
|
|
|
fe7475 |
|
|
|
fe7475 |
We cannot do anything like a real test without the proprietary
|
|
|
fe7475 |
library. However by making a dummy library which contains some stub
|
|
|
fe7475 |
functions we can test --dump-plugin output.
|
|
|
fe7475 |
|
|
|
fe7475 |
(cherry picked from commit 70f7227ecc9b7c8d628987cb12ca7541bf485d66)
|
|
|
fe7475 |
---
|
|
|
fe7475 |
tests/Makefile.am | 21 ++++++++++++++++++
|
|
|
fe7475 |
tests/dummy-vddk.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
fe7475 |
tests/test-vddk.sh | 45 +++++++++++++++++++++++++++++++++++++++
|
|
|
fe7475 |
3 files changed, 128 insertions(+)
|
|
|
fe7475 |
create mode 100644 tests/dummy-vddk.c
|
|
|
fe7475 |
create mode 100755 tests/test-vddk.sh
|
|
|
fe7475 |
|
|
|
fe7475 |
diff --git a/tests/Makefile.am b/tests/Makefile.am
|
|
|
fe7475 |
index c0c2155..2973268 100644
|
|
|
fe7475 |
--- a/tests/Makefile.am
|
|
|
fe7475 |
+++ b/tests/Makefile.am
|
|
|
fe7475 |
@@ -75,6 +75,7 @@ EXTRA_DIST = \
|
|
|
fe7475 |
test-random-sock.sh \
|
|
|
fe7475 |
test-tls.sh \
|
|
|
fe7475 |
test-tls-psk.sh \
|
|
|
fe7475 |
+ test-vddk.sh \
|
|
|
fe7475 |
test-version.sh \
|
|
|
fe7475 |
test-version-filter.sh \
|
|
|
fe7475 |
test-version-plugin.sh \
|
|
|
fe7475 |
@@ -365,6 +366,26 @@ test_streaming_SOURCES = test-streaming.c test.h
|
|
|
fe7475 |
test_streaming_CFLAGS = $(WARNINGS_CFLAGS) $(LIBGUESTFS_CFLAGS)
|
|
|
fe7475 |
test_streaming_LDADD = libtest.la $(LIBGUESTFS_LIBS)
|
|
|
fe7475 |
|
|
|
fe7475 |
+# VDDK plugin test.
|
|
|
fe7475 |
+# This only tests that the plugin can be loaded against a
|
|
|
fe7475 |
+# dummy VDDK library, it is not a detailed test.
|
|
|
fe7475 |
+
|
|
|
fe7475 |
+# check_LTLIBRARIES won't build a shared library (see automake manual).
|
|
|
fe7475 |
+# So we have to do this and add a dependency.
|
|
|
fe7475 |
+noinst_LTLIBRARIES += libvixDiskLib.la
|
|
|
fe7475 |
+TESTS += test-vddk.sh
|
|
|
fe7475 |
+
|
|
|
fe7475 |
+libvixDiskLib_la_SOURCES = \
|
|
|
fe7475 |
+ dummy-vddk.c
|
|
|
fe7475 |
+libvixDiskLib_la_CPPFLAGS = \
|
|
|
fe7475 |
+ -I$(top_srcdir)/plugins/vddk
|
|
|
fe7475 |
+libvixDiskLib_la_CXXFLAGS = \
|
|
|
fe7475 |
+ $(WARNINGS_CFLAGS)
|
|
|
fe7475 |
+# For use of the -rpath option, see:
|
|
|
fe7475 |
+# https://lists.gnu.org/archive/html/libtool/2007-07/msg00067.html
|
|
|
fe7475 |
+libvixDiskLib_la_LDFLAGS = \
|
|
|
fe7475 |
+ -shared -version-number 6:0:0 -rpath /nowhere
|
|
|
fe7475 |
+
|
|
|
fe7475 |
# xz plugin test.
|
|
|
fe7475 |
if HAVE_LIBLZMA
|
|
|
fe7475 |
if HAVE_GUESTFISH
|
|
|
fe7475 |
diff --git a/tests/dummy-vddk.c b/tests/dummy-vddk.c
|
|
|
fe7475 |
new file mode 100644
|
|
|
fe7475 |
index 0000000..e9069c9
|
|
|
fe7475 |
--- /dev/null
|
|
|
fe7475 |
+++ b/tests/dummy-vddk.c
|
|
|
fe7475 |
@@ -0,0 +1,62 @@
|
|
|
fe7475 |
+/* nbdkit
|
|
|
fe7475 |
+ * Copyright (C) 2018 Red Hat Inc.
|
|
|
fe7475 |
+ * All rights reserved.
|
|
|
fe7475 |
+ *
|
|
|
fe7475 |
+ * Redistribution and use in source and binary forms, with or without
|
|
|
fe7475 |
+ * modification, are permitted provided that the following conditions are
|
|
|
fe7475 |
+ * met:
|
|
|
fe7475 |
+ *
|
|
|
fe7475 |
+ * * Redistributions of source code must retain the above copyright
|
|
|
fe7475 |
+ * notice, this list of conditions and the following disclaimer.
|
|
|
fe7475 |
+ *
|
|
|
fe7475 |
+ * * Redistributions in binary form must reproduce the above copyright
|
|
|
fe7475 |
+ * notice, this list of conditions and the following disclaimer in the
|
|
|
fe7475 |
+ * documentation and/or other materials provided with the distribution.
|
|
|
fe7475 |
+ *
|
|
|
fe7475 |
+ * * Neither the name of Red Hat nor the names of its contributors may be
|
|
|
fe7475 |
+ * used to endorse or promote products derived from this software without
|
|
|
fe7475 |
+ * specific prior written permission.
|
|
|
fe7475 |
+ *
|
|
|
fe7475 |
+ * THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND
|
|
|
fe7475 |
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
|
fe7475 |
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
|
|
fe7475 |
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR
|
|
|
fe7475 |
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
fe7475 |
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
fe7475 |
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
|
|
fe7475 |
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
|
fe7475 |
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
|
fe7475 |
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
|
|
fe7475 |
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
fe7475 |
+ * SUCH DAMAGE.
|
|
|
fe7475 |
+ */
|
|
|
fe7475 |
+
|
|
|
fe7475 |
+/* This file pretends to be libvixDiskLib.so.6.
|
|
|
fe7475 |
+ *
|
|
|
fe7475 |
+ * In fact because we don't check the result from dlsym and because we
|
|
|
fe7475 |
+ * only call a few APIs in the --dump-plugin path there are only a few
|
|
|
fe7475 |
+ * stub functions needed.
|
|
|
fe7475 |
+ */
|
|
|
fe7475 |
+
|
|
|
fe7475 |
+#include <stdio.h>
|
|
|
fe7475 |
+#include <stdlib.h>
|
|
|
fe7475 |
+#include <stdint.h>
|
|
|
fe7475 |
+
|
|
|
fe7475 |
+#include "vddk-structs.h"
|
|
|
fe7475 |
+
|
|
|
fe7475 |
+VixError
|
|
|
fe7475 |
+VixDiskLib_InitEx (uint32_t major, uint32_t minor,
|
|
|
fe7475 |
+ VixDiskLibGenericLogFunc *log_function,
|
|
|
fe7475 |
+ VixDiskLibGenericLogFunc *warn_function,
|
|
|
fe7475 |
+ VixDiskLibGenericLogFunc *panic_function,
|
|
|
fe7475 |
+ const char *lib_dir, const char *config_file)
|
|
|
fe7475 |
+{
|
|
|
fe7475 |
+ /* Do nothing, only exit with no error. */
|
|
|
fe7475 |
+ return VIX_OK;
|
|
|
fe7475 |
+}
|
|
|
fe7475 |
+
|
|
|
fe7475 |
+void
|
|
|
fe7475 |
+VixDiskLib_Exit (void)
|
|
|
fe7475 |
+{
|
|
|
fe7475 |
+ /* Do nothing. */
|
|
|
fe7475 |
+}
|
|
|
fe7475 |
diff --git a/tests/test-vddk.sh b/tests/test-vddk.sh
|
|
|
fe7475 |
new file mode 100755
|
|
|
fe7475 |
index 0000000..5ccfff1
|
|
|
fe7475 |
--- /dev/null
|
|
|
fe7475 |
+++ b/tests/test-vddk.sh
|
|
|
fe7475 |
@@ -0,0 +1,45 @@
|
|
|
fe7475 |
+#!/bin/bash -
|
|
|
fe7475 |
+# nbdkit
|
|
|
fe7475 |
+# Copyright (C) 2018 Red Hat Inc.
|
|
|
fe7475 |
+# All rights reserved.
|
|
|
fe7475 |
+#
|
|
|
fe7475 |
+# Redistribution and use in source and binary forms, with or without
|
|
|
fe7475 |
+# modification, are permitted provided that the following conditions are
|
|
|
fe7475 |
+# met:
|
|
|
fe7475 |
+#
|
|
|
fe7475 |
+# * Redistributions of source code must retain the above copyright
|
|
|
fe7475 |
+# notice, this list of conditions and the following disclaimer.
|
|
|
fe7475 |
+#
|
|
|
fe7475 |
+# * Redistributions in binary form must reproduce the above copyright
|
|
|
fe7475 |
+# notice, this list of conditions and the following disclaimer in the
|
|
|
fe7475 |
+# documentation and/or other materials provided with the distribution.
|
|
|
fe7475 |
+#
|
|
|
fe7475 |
+# * Neither the name of Red Hat nor the names of its contributors may be
|
|
|
fe7475 |
+# used to endorse or promote products derived from this software without
|
|
|
fe7475 |
+# specific prior written permission.
|
|
|
fe7475 |
+#
|
|
|
fe7475 |
+# THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND
|
|
|
fe7475 |
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
|
fe7475 |
+# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
|
|
fe7475 |
+# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR
|
|
|
fe7475 |
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
fe7475 |
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
fe7475 |
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
|
|
fe7475 |
+# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
|
fe7475 |
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
|
fe7475 |
+# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
|
|
fe7475 |
+# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
fe7475 |
+# SUCH DAMAGE.
|
|
|
fe7475 |
+
|
|
|
fe7475 |
+set -x
|
|
|
fe7475 |
+set -e
|
|
|
fe7475 |
+
|
|
|
fe7475 |
+rm -f test-vddk.out
|
|
|
fe7475 |
+
|
|
|
fe7475 |
+LD_LIBRARY_PATH=.libs:$LD_LIBRARY_PATH \
|
|
|
fe7475 |
+nbdkit vddk --dump-plugin > test-vddk.out
|
|
|
fe7475 |
+cat test-vddk.out
|
|
|
fe7475 |
+
|
|
|
fe7475 |
+grep ^vddk_default_libdir= test-vddk.out
|
|
|
fe7475 |
+
|
|
|
fe7475 |
+rm test-vddk.out
|
|
|
fe7475 |
--
|
|
|
fe7475 |
1.8.3.1
|
|
|
fe7475 |
|