Update Red Hat Copyright Notices
[nbdkit.git] / tests / test-vddk-real.sh
blob0b189665b4b3745c15902164beb13766f2d2fb64
1 #!/usr/bin/env bash
2 # nbdkit
3 # Copyright Red Hat
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
45 requires_nbdinfo
46 skip_if_valgrind "because setting LD_LIBRARY_PATH breaks valgrind"
48 # VDDK > 5.1.1 only supports x86_64.
49 if [ `uname -m` != "x86_64" ]; then
50 echo "$0: unsupported architecture"
51 exit 77
54 # Since we are comparing error messages below, let's make sure we're
55 # not translating errors.
56 export LANG=C
58 pid=test-vddk-real.pid
59 sock=$(mktemp -u /tmp/nbdkit-test-sock.XXXXXX)
60 vmdk=$PWD/test-vddk-real.vmdk ;# note must be an absolute path
61 raw=test-vddk-real.raw
62 raw2=test-vddk-real.raw2
63 log=test-vddk-real.log
64 files="$pid $sock $vmdk $raw $raw2 $log"
65 rm -f $files
66 cleanup_fn rm -f $files
68 qemu-img create -f vmdk $vmdk 10M
70 # Check first that the VDDK library can be fully loaded. We have to
71 # check the log file for missing modules since they may not show up as
72 # errors.
73 nbdkit -fv -U - vddk libdir="$vddkdir" $vmdk --run 'nbdinfo "$uri"' 2>&1 |
74 tee $log
76 # Check the log for missing modules
77 if grep 'cannot open shared object file' $log; then
78 exit 1
81 # Now run nbdkit for the test.
82 start_nbdkit -P $pid -U $sock -D vddk.stats=1 -D vddk.diskinfo=1 \
83 vddk libdir="$vddkdir" $vmdk
84 uri="nbd+unix:///?socket=$sock"
86 # VDDK < 6.0 did not support flush, so disable flush test there. Also
87 # if nbdinfo doesn't support the --can flush syntax (added in libnbd
88 # 1.10) then this is disabled.
89 if nbdinfo --can flush "$uri"; then flush="--flush"; else flush=""; fi
91 # Copy in and out some data. This should exercise read, write,
92 # extents and flushing.
93 dd if=/dev/urandom of=$raw count=5 bs=$((1024*1024))
94 $TRUNCATE -s 10M $raw
96 nbdcopy $flush $raw "$uri"
97 nbdcopy "$uri" $raw2
99 cmp $raw $raw2