3 # Assume that the current directory is the tests/ directory.
4 # If this fails we're probably running the test from the wrong
8 echo "cannot find disk image $f" >&2
12 # nbdkit is supposed to set $tmpdir. If it doesn't, it's an error.
13 if [ ! -d $tmpdir ]; then
14 echo "\$tmpdir was not set" >&2
18 # Check that SIGPIPE is not ignored unless we want it that way.
19 if (type yes) >/dev
/null
2>&1; then
21 ({ yes; echo $?
>&3; } |
head -c1) 3>&1 >/dev
/null
2>&1)
23 ({ yes; echo $?
>&3; } |
head -c1) 3>&1 >/dev
/null
2>&1)
24 if [ $ignored = $default ]; then
25 echo "SIGPIPE was inherited ignored" >&2
40 stat
-L -c '%s' $f ||
exit 1
44 dd iflag
=skip_bytes
,count_bytes skip
=$4 count
=$3 if=$f || \
51 *) echo "garbage flags: '$5'" >&2
54 dd oflag
=seek_bytes conv
=notrunc seek
=$4 of
=$f ||
exit 1
68 *) echo "garbage flags: '$5'" >&2
71 fallocate
-p -o $4 -l $3 -n $f
74 # We can trim if the fallocate command exists.
75 fallocate
--help >/dev
/null
2>&1 ||
exit 3
80 '' | fua | may_trim | fua
,may_trim
) ;;
81 *) echo "garbage flags: '$5'" >&2
84 fallocate
-z -o $4 -l $3 -n $f
87 # We can zero efficiently if the fallocate command exists.
88 fallocate
--help >/dev
/null
2>&1 ||
exit 3
92 # Unknown methods must exit with code 2.