8233ecfd32
This requires some upstream fixes for srcdir != builddir.
285 lines
11 KiB
Diff
285 lines
11 KiB
Diff
From ac60163ceba1b951e1d2f0625552e6a45d85f666 Mon Sep 17 00:00:00 2001
|
|
From: "Richard W.M. Jones" <rjones@redhat.com>
|
|
Date: Tue, 23 Jan 2024 13:35:02 +0000
|
|
Subject: [PATCH 2/2] tests: Fix tests to work with srcdir != builddir
|
|
|
|
---
|
|
tests/test-cc-cpp.sh | 2 +-
|
|
tests/test-cc-ocaml.sh | 2 +-
|
|
tests/test-cc.sh | 2 +-
|
|
tests/test-curl-header-script-fail.sh | 2 +-
|
|
tests/test-linuxdisk-copy-out.sh | 4 ++--
|
|
tests/test-multi-conn-name.sh | 6 ++++--
|
|
tests/test-multi-conn.sh | 20 +++++++++++---------
|
|
tests/test-plugin-docs.sh | 2 +-
|
|
tests/test-shebang-cc.sh | 3 +++
|
|
tests/test-tar.sh | 2 +-
|
|
tests/cc-shebang.c | 4 +++-
|
|
tests/test-read-password-plugin.c | 4 +++-
|
|
12 files changed, 32 insertions(+), 21 deletions(-)
|
|
|
|
diff --git a/tests/test-cc-cpp.sh b/tests/test-cc-cpp.sh
|
|
index ebbdab31d..dd9bf58d8 100755
|
|
--- a/tests/test-cc-cpp.sh
|
|
+++ b/tests/test-cc-cpp.sh
|
|
@@ -55,6 +55,6 @@ rm -f $out
|
|
|
|
nbdkit cc $script \
|
|
CC="$CXX" \
|
|
- EXTRA_CFLAGS="-I$abs_top_srcdir/include" \
|
|
+ EXTRA_CFLAGS="-I$abs_top_srcdir/include -I../include" \
|
|
--run 'nbdinfo --size $uri' > $out
|
|
test "$(cat $out)" -eq $((100 * 1024 * 1024))
|
|
diff --git a/tests/test-cc-ocaml.sh b/tests/test-cc-ocaml.sh
|
|
index 68972fce0..79eb678df 100755
|
|
--- a/tests/test-cc-ocaml.sh
|
|
+++ b/tests/test-cc-ocaml.sh
|
|
@@ -57,6 +57,6 @@ cleanup_fn rm -f $out
|
|
rm -f $out
|
|
|
|
nbdkit -v cc $script a=1 b=2 c=3 d=4 \
|
|
- CC="$OCAMLOPT" CFLAGS="-output-obj -runtime-variant _pic -I $abs_top_srcdir/plugins/ocaml $OCAML_PLUGIN_LIBRARIES NBDKit.cmx -cclib -L../plugins/ocaml/.libs -cclib -lnbdkitocaml" \
|
|
+ CC="$OCAMLOPT" CFLAGS="-output-obj -runtime-variant _pic -I $abs_top_srcdir/plugins/ocaml -I ../plugins/ocaml $OCAML_PLUGIN_LIBRARIES NBDKit.cmx -cclib -L../plugins/ocaml/.libs -cclib -lnbdkitocaml" \
|
|
--run 'nbdinfo --size $uri' > $out
|
|
test "$(cat $out)" -eq $((512 * 2048))
|
|
diff --git a/tests/test-cc.sh b/tests/test-cc.sh
|
|
index 2646704be..5c1db8b96 100755
|
|
--- a/tests/test-cc.sh
|
|
+++ b/tests/test-cc.sh
|
|
@@ -53,6 +53,6 @@ cleanup_fn rm -f $out
|
|
rm -f $out
|
|
|
|
nbdkit cc $script \
|
|
- EXTRA_CFLAGS="-I$abs_top_srcdir/include" \
|
|
+ EXTRA_CFLAGS="-I$abs_top_srcdir/include -I../include" \
|
|
--run 'nbdinfo --size $uri' > $out
|
|
test "$(cat $out)" -eq $((100 * 1024 * 1024))
|
|
diff --git a/tests/test-curl-header-script-fail.sh b/tests/test-curl-header-script-fail.sh
|
|
index cf9614f96..282e0ddf0 100755
|
|
--- a/tests/test-curl-header-script-fail.sh
|
|
+++ b/tests/test-curl-header-script-fail.sh
|
|
@@ -50,7 +50,7 @@ cleanup_fn rm -f $errors
|
|
# This command is expected to fail.
|
|
nbdkit -rfv \
|
|
curl file:$PWD/disk protocols=file \
|
|
- header-script=$PWD/test-curl-header-script-fail.script \
|
|
+ header-script=$abs_top_srcdir/tests/test-curl-header-script-fail.script \
|
|
--run 'nbdinfo --no-content $uri' >$errors 2>&1 ||:
|
|
|
|
cat $errors
|
|
diff --git a/tests/test-linuxdisk-copy-out.sh b/tests/test-linuxdisk-copy-out.sh
|
|
index 8c2f44bad..81b5b7439 100755
|
|
--- a/tests/test-linuxdisk-copy-out.sh
|
|
+++ b/tests/test-linuxdisk-copy-out.sh
|
|
@@ -65,14 +65,14 @@ guestfish --ro -a linuxdisk-copy-out.img -m /dev/sda <<EOF
|
|
tar-out / - | cat >/dev/null
|
|
|
|
# Download some files and compare to local copies.
|
|
- download /Makefile linuxdisk-copy-out.test1
|
|
+ download /virtual-disk.c linuxdisk-copy-out.test1
|
|
download /Makefile.am linuxdisk-copy-out.test2
|
|
download /nbdkit-linuxdisk-plugin.pod linuxdisk-copy-out.test3
|
|
download /filesystem.c linuxdisk-copy-out.test4
|
|
EOF
|
|
|
|
# Compare downloaded files to local versions.
|
|
-cmp linuxdisk-copy-out.test1 $srcdir/../plugins/linuxdisk/Makefile
|
|
+cmp linuxdisk-copy-out.test1 $srcdir/../plugins/linuxdisk/virtual-disk.c
|
|
cmp linuxdisk-copy-out.test2 $srcdir/../plugins/linuxdisk/Makefile.am
|
|
cmp linuxdisk-copy-out.test3 $srcdir/../plugins/linuxdisk/nbdkit-linuxdisk-plugin.pod
|
|
cmp linuxdisk-copy-out.test4 $srcdir/../plugins/linuxdisk/filesystem.c
|
|
diff --git a/tests/test-multi-conn-name.sh b/tests/test-multi-conn-name.sh
|
|
index 6a180db72..2d2072925 100755
|
|
--- a/tests/test-multi-conn-name.sh
|
|
+++ b/tests/test-multi-conn-name.sh
|
|
@@ -42,6 +42,8 @@ requires_nbdsh_uri
|
|
requires nbdsh -c 'print(h.set_opt_mode)'
|
|
requires dd iflag=count_bytes </dev/null
|
|
|
|
+plugin=$srcdir/../tests/test-multi-conn-plugin.sh
|
|
+
|
|
files="test-multi-conn-name.out"
|
|
rm -f $files
|
|
cleanup_fn rm -f $files
|
|
@@ -69,7 +71,7 @@ print(bytes(h["b1"].pread(1, 0)))
|
|
'
|
|
|
|
# Without the knob we flush all exports
|
|
-nbdkit -vf sh test-multi-conn-plugin.sh --filter=multi-conn \
|
|
+nbdkit -vf sh $plugin --filter=multi-conn \
|
|
--run 'export uri; nbdsh -c "$script"' > test-multi-conn-name.out || fail=1
|
|
diff -u <(cat <<\EOF
|
|
b'A'
|
|
@@ -77,7 +79,7 @@ b'B'
|
|
EOF
|
|
) test-multi-conn-name.out || fail=1
|
|
# But with the knob, our flush is specific to the correct export
|
|
-nbdkit -vf sh test-multi-conn-plugin.sh --filter=multi-conn \
|
|
+nbdkit -vf sh $plugin --filter=multi-conn \
|
|
multi-conn-exportname=true \
|
|
--run 'export uri; nbdsh -c "$script"' > test-multi-conn-name.out || fail=1
|
|
diff -u <(cat <<\EOF
|
|
diff --git a/tests/test-multi-conn.sh b/tests/test-multi-conn.sh
|
|
index 3383cd246..eec225c2a 100755
|
|
--- a/tests/test-multi-conn.sh
|
|
+++ b/tests/test-multi-conn.sh
|
|
@@ -41,6 +41,8 @@ requires_plugin sh
|
|
requires_nbdsh_uri
|
|
requires dd iflag=count_bytes </dev/null
|
|
|
|
+plugin=$srcdir/../tests/test-multi-conn-plugin.sh
|
|
+
|
|
files="test-multi-conn.out test-multi-conn.stat"
|
|
rm -f $files
|
|
cleanup_fn rm -f $files
|
|
@@ -63,7 +65,7 @@ print(h[0].can_multi_conn())
|
|
|
|
# Demonstrate the caching present without use of filter
|
|
for filter in '' '--filter=multi-conn multi-conn-mode=plugin'; do
|
|
- nbdkit -vf sh test-multi-conn-plugin.sh $filter \
|
|
+ nbdkit -vf sh $plugin $filter \
|
|
--run 'handles=4 nbdsh -c "$preamble" -c "
|
|
# Without flush, reads cache, and writes do not affect persistent data
|
|
print(bytes(h[0].pread(4, 0)))
|
|
@@ -109,7 +111,7 @@ done
|
|
|
|
# Demonstrate specifics of FUA flag
|
|
for filter in '' '--filter=multi-conn multi-conn-mode=plugin'; do
|
|
- nbdkit -vf sh test-multi-conn-plugin.sh $filter \
|
|
+ nbdkit -vf sh $plugin $filter \
|
|
--run 'nbdsh -c "$preamble" -c "
|
|
# Some servers let FUA flush all outstanding requests
|
|
h[0].pwrite(b'\''hello '\'', 0)
|
|
@@ -123,7 +125,7 @@ EOF
|
|
) test-multi-conn.out || fail=1
|
|
done
|
|
for filter in '' '--filter=multi-conn multi-conn-mode=plugin'; do
|
|
- nbdkit -vf sh test-multi-conn-plugin.sh strictfua=1 $filter \
|
|
+ nbdkit -vf sh $plugin strictfua=1 $filter \
|
|
--run 'nbdsh -c "$preamble" -c "
|
|
# But it is also compliant for a server that only flushes the exact request
|
|
h[0].pwrite(b'\''hello '\'', 0)
|
|
@@ -155,7 +157,7 @@ done
|
|
# mode is also able to supply multi-conn by a different technique.
|
|
for filter in '--filter=multi-conn' 'strictfua=1 --filter=multi-conn' \
|
|
'--filter=multi-conn multi-conn-mode=plugin --filter=cache' ; do
|
|
- nbdkit -vf sh test-multi-conn-plugin.sh $filter \
|
|
+ nbdkit -vf sh $plugin $filter \
|
|
--run 'nbdsh -c "$preamble" -c "
|
|
# FUA writes are immediately visible on all connections
|
|
h[0].cache(12, 0)
|
|
@@ -175,7 +177,7 @@ EOF
|
|
done
|
|
|
|
# unsafe mode intentionally lacks consistency, use at your own risk
|
|
-nbdkit -vf sh test-multi-conn-plugin.sh \
|
|
+nbdkit -vf sh $plugin \
|
|
--filter=multi-conn multi-conn-mode=unsafe \
|
|
--run 'nbdsh -c "$preamble" -c "
|
|
h[0].cache(12, 0)
|
|
@@ -193,7 +195,7 @@ EOF
|
|
) test-multi-conn.out || fail=1
|
|
|
|
# auto mode devolves to multi-conn disable when connections are serialized
|
|
-nbdkit -vf sh test-multi-conn-plugin.sh --filter=noparallel \
|
|
+nbdkit -vf sh $plugin --filter=noparallel \
|
|
serialize=connections --filter=multi-conn --filter=cache \
|
|
--run 'handles=1 nbdsh -c "$preamble"
|
|
' > test-multi-conn.out || fail=1
|
|
@@ -208,7 +210,7 @@ for level in off connection fast; do
|
|
plugin 'plugin --filter=cache'; do
|
|
echo "setup: $level $mode" >> test-multi-conn.stat
|
|
# Flush with no activity
|
|
- nbdkit -vf sh test-multi-conn-plugin.sh --filter=multi-conn \
|
|
+ nbdkit -vf sh $plugin --filter=multi-conn \
|
|
--filter=stats statsfile=test-multi-conn.stat statsappend=true \
|
|
multi-conn-track-dirty=$level multi-conn-mode=$mode \
|
|
--run 'nbdsh -c "$preamble" -c "
|
|
@@ -217,7 +219,7 @@ h[0].pread(1, 0)
|
|
h[0].flush()
|
|
"' > test-multi-conn.out || fail=1
|
|
# Client that flushes assuming multi-conn semantics
|
|
- nbdkit -vf sh test-multi-conn-plugin.sh --filter=multi-conn \
|
|
+ nbdkit -vf sh $plugin --filter=multi-conn \
|
|
--filter=stats statsfile=test-multi-conn.stat statsappend=true \
|
|
multi-conn-track-dirty=$level multi-conn-mode=$mode \
|
|
--run 'handles=4 nbdsh -c "$preamble" -c "
|
|
@@ -230,7 +232,7 @@ h[3].flush()
|
|
h[3].flush()
|
|
"' > test-multi-conn.out || fail=1
|
|
# Client that flushes assuming inconsistent semantics
|
|
- nbdkit -vf sh test-multi-conn-plugin.sh --filter=multi-conn \
|
|
+ nbdkit -vf sh $plugin --filter=multi-conn \
|
|
--filter=stats statsfile=test-multi-conn.stat statsappend=true \
|
|
multi-conn-track-dirty=$level multi-conn-mode=$mode \
|
|
--run 'nbdsh -c "$preamble" -c "
|
|
diff --git a/tests/test-plugin-docs.sh b/tests/test-plugin-docs.sh
|
|
index 772cfff07..e329035da 100755
|
|
--- a/tests/test-plugin-docs.sh
|
|
+++ b/tests/test-plugin-docs.sh
|
|
@@ -59,7 +59,7 @@ run_test ()
|
|
{
|
|
plugin="$1"
|
|
|
|
- pod=../plugins/$plugin/nbdkit-$plugin-plugin.pod
|
|
+ pod=$srcdir/../plugins/$plugin/nbdkit-$plugin-plugin.pod
|
|
test -f "$pod"
|
|
|
|
# Get the key=value lines from the help output.
|
|
diff --git a/tests/test-shebang-cc.sh b/tests/test-shebang-cc.sh
|
|
index b25b789f7..674d0fcef 100755
|
|
--- a/tests/test-shebang-cc.sh
|
|
+++ b/tests/test-shebang-cc.sh
|
|
@@ -45,6 +45,9 @@ requires_run
|
|
requires_plugin cc
|
|
requires guestfish --version
|
|
|
|
+# This variable is used by $script.
|
|
+export abs_top_srcdir
|
|
+
|
|
$script -fv \
|
|
EXTRA_CFLAGS="-I$abs_top_srcdir/include" \
|
|
--run '
|
|
diff --git a/tests/test-tar.sh b/tests/test-tar.sh
|
|
index 9c9b3974f..d1a602b99 100755
|
|
--- a/tests/test-tar.sh
|
|
+++ b/tests/test-tar.sh
|
|
@@ -45,7 +45,7 @@ cleanup_fn rm -f $files
|
|
|
|
# Create a tar file containing the disk image plus some other random
|
|
# files that hopefully will be ignored.
|
|
-tar cf tar.tar test-tar.sh Makefile disk Makefile.am
|
|
+tar cf tar.tar Makefile disk functions.sh
|
|
tar tvvf tar.tar
|
|
|
|
# Run nbdkit.
|
|
diff --git a/tests/cc-shebang.c b/tests/cc-shebang.c
|
|
index de2730f67..882fa2c1c 100755
|
|
--- a/tests/cc-shebang.c
|
|
+++ b/tests/cc-shebang.c
|
|
@@ -1,5 +1,7 @@
|
|
#if 0
|
|
-exec nbdkit cc "$0" "$@"
|
|
+exec nbdkit cc "$0" "$@" \
|
|
+ EXTRA_CFLAGS="-I.. -I../include \
|
|
+ -I$abs_top_srcdir/include"
|
|
#endif
|
|
#include <stdint.h>
|
|
#include <string.h>
|
|
diff --git a/tests/test-read-password-plugin.c b/tests/test-read-password-plugin.c
|
|
index 3f0a95153..703fc724d 100755
|
|
--- a/tests/test-read-password-plugin.c
|
|
+++ b/tests/test-read-password-plugin.c
|
|
@@ -1,5 +1,7 @@
|
|
#if 0
|
|
-exec nbdkit cc "$0" "$@" EXTRA_CFLAGS="-I.. -I$abs_top_srcdir/include"
|
|
+exec nbdkit cc "$0" "$@" \
|
|
+ EXTRA_CFLAGS="-I.. -I../include \
|
|
+ -I$abs_top_srcdir/include"
|
|
#endif
|
|
/* nbdkit
|
|
* Copyright Red Hat
|
|
--
|
|
2.43.0
|
|
|