rust: prevent dead_code warning
[nbdkit.git] / tests / test-vddk-real.sh
blob480040b2ceac3c0bdfc81a60051e2097f82c5460
1 #!/usr/bin/env bash
2 # nbdkit
3 # Copyright (C) 2018-2020 Red Hat Inc.
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions are
7 # met:
9 # * Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
12 # * Redistributions in binary form must reproduce the above copyright
13 # notice, this list of conditions and the following disclaimer in the
14 # documentation and/or other materials provided with the distribution.
16 # * Neither the name of Red Hat nor the names of its contributors may be
17 # used to endorse or promote products derived from this software without
18 # specific prior written permission.
20 # THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND
21 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22 # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
23 # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR
24 # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
27 # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
28 # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
30 # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 # SUCH DAMAGE.
33 source ./functions.sh
34 set -e
35 set -x
37 requires test "x$vddkdir" != "x"
38 requires test -d "$vddkdir"
39 requires test -f "$vddkdir/lib64/libvixDiskLib.so"
40 requires test -r /dev/urandom
41 requires cmp --version
42 requires dd --version
43 requires qemu-img --version
44 requires nbdcopy --version
45 requires nbdinfo --version
47 # Testing $LD_LIBRARY_PATH stuff breaks valgrind, so skip the rest of
48 # this test if valgrinding.
49 if [ "x$NBDKIT_VALGRIND" = "x1" ]; then
50 echo "$0: skipped LD_LIBRARY_PATH test when doing valgrind"
51 exit 77
54 # VDDK > 5.1.1 only supports x86_64.
55 if [ `uname -m` != "x86_64" ]; then
56 echo "$0: unsupported architecture"
57 exit 77
60 # Since we are comparing error messages below, let's make sure we're
61 # not translating errors.
62 export LANG=C
64 pid=test-vddk-real.pid
65 sock=$(mktemp -u /tmp/nbdkit-test-sock.XXXXXX)
66 vmdk=$PWD/test-vddk-real.vmdk ;# note must be an absolute path
67 raw=test-vddk-real.raw
68 raw2=test-vddk-real.raw2
69 log=test-vddk-real.log
70 files="$pid $sock $vmdk $raw $raw2 $log"
71 rm -f $files
72 cleanup_fn rm -f $files
74 qemu-img create -f vmdk $vmdk 10M
76 # Check first that the VDDK library can be fully loaded. We have to
77 # check the log file for missing modules since they may not show up as
78 # errors.
79 nbdkit -fv -U - vddk libdir="$vddkdir" $vmdk --run 'nbdinfo "$uri"' 2>&1 |
80 tee $log
82 # Check the log for missing modules
83 if grep 'cannot open shared object file' $log; then
84 exit 1
87 # Now run nbdkit for the test.
88 start_nbdkit -P $pid -U $sock -D vddk.stats=1 -D vddk.diskinfo=1 \
89 vddk libdir="$vddkdir" $vmdk
90 uri="nbd+unix:///?socket=$sock"
92 # VDDK < 6.0 did not support flush, so disable flush test there. Also
93 # if nbdinfo doesn't support the --can flush syntax (added in libnbd
94 # 1.10) then this is disabled.
95 if nbdinfo --can flush "$uri"; then flush="--flush"; else flush=""; fi
97 # Copy in and out some data. This should exercise read, write,
98 # extents and flushing.
99 dd if=/dev/urandom of=$raw count=5 bs=$((1024*1024))
100 $TRUNCATE -s 10M $raw
102 nbdcopy $flush $raw "$uri"
103 nbdcopy "$uri" $raw2
105 cmp $raw $raw2