2 # nbd client library in userspace
5 # This library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2 of the License, or (at your option) any later version.
10 # This library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Lesser General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with this library; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 . ..
/tests
/functions.sh
24 requires nbdkit
--exit-with-parent --version
25 requires
cmp /dev
/null
/dev
/null
26 requires
hexdump -C /dev
/null
28 pidfile1
=copy-nbd-to-nbd.pid1
29 pidfile2
=copy-nbd-to-nbd.pid2
30 file1
=copy-nbd-to-nbd.file1
31 file2
=copy-nbd-to-nbd.file2
32 sock1
=$
(mktemp
-u /tmp
/libnbd-test-copy.XXXXXX
)
33 sock2
=$
(mktemp
-u /tmp
/libnbd-test-copy.XXXXXX
)
34 cleanup_fn
rm -f $pidfile1 $pidfile2 $file1 $file2 $sock1 $sock2
36 nbdkit
--exit-with-parent -f -v -P $pidfile1 -U $sock1 pattern size
=10M
&
37 # Wait for the pidfile to appear.
39 if test -f $pidfile1; then
44 if ! test -f $pidfile1; then
45 echo "$0: nbdkit did not start up"
49 nbdkit
--exit-with-parent -f -v -P $pidfile2 -U $sock2 memory size
=10M
&
50 # Wait for the pidfile to appear.
52 if test -f $pidfile2; then
57 if ! test -f $pidfile2; then
58 echo "$0: nbdkit did not start up"
62 $VG nbdcopy
"nbd+unix:///?socket=$sock1" "nbd+unix:///?socket=$sock2"
64 # Download the file from both servers and check they are the same.
65 $VG nbdcopy
"nbd+unix:///?socket=$sock1" $file1
66 $VG nbdcopy
"nbd+unix:///?socket=$sock2" $file2
71 # Test the data is at least non-zero.
72 test "$(hexdump -C $file1 | head -1)" = "00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 08 |................|"