Revert "ci: skip "lib/test-fork-safe-execvpe.sh" on Alpine Linux"
[libnbd.git] / copy / copy-nbd-to-file.sh
blobdc4ed441d765547cd894919bdafd1f2a10c252da
1 #!/usr/bin/env bash
2 # nbd client library in userspace
3 # Copyright Red Hat
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
21 set -e
22 set -x
24 requires nbdkit --exit-with-parent --version
25 requires hexdump -C /dev/null
26 requires stat --version
28 file=copy-nbd-to-file.file
29 cleanup_fn rm -f $file
31 $VG nbdcopy -- [ nbdkit --exit-with-parent -v data data='0x55 0xAA @268435454 0xAA 0x55' ] $file
32 if [ "$(stat -c %s $file)" -ne $(( 256 * 1024 * 1024 )) ]; then
33 echo "$0: incorrect amount of data copied"
34 exit 1
37 # Test the data is as expected.
38 test "$(hexdump -C $file)" = \
39 '00000000 55 aa 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |U...............|
40 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
42 0ffffff0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 aa 55 |...............U|
43 10000000'