5050db6753d55cbfd917b584ac7fc4ec110da723
[platform/upstream/coreutils.git] / tests / dd / unblock-sync
1 #!/bin/sh
2 # Ensure that dd conv=unblock,sync works.
3
4 if test "$VERBOSE" = yes; then
5   set -x
6   dd --version
7 fi
8
9 # . $srcdir/../envvar-check
10
11 pwd=`pwd`
12 t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
13 trap 'status=$?; cd $pwd; chmod -R u+rwx $t0; rm -rf $t0 && exit $status' 0
14 trap '(exit $?); exit $?' 1 2 13 15
15
16 framework_failure=0
17 mkdir -p $tmp || framework_failure=1
18 cd $tmp || framework_failure=1
19 printf 000100020003xx > in || framework_failure=1
20
21 if test $framework_failure = 1; then
22   echo "$0: failure in testing framework" 1>&2
23   (exit 1); exit 1
24 fi
25
26 fail=0
27
28 dd cbs=4 ibs=4 conv=unblock,sync < in > out 2> /dev/null || fail=1
29 cat <<\EOF > exp || fail=1
30 0001
31 0002
32 0003
33 xx
34 EOF
35
36 cmp out exp || fail=1
37 test $fail = 1 && diff out exp 2> /dev/null
38
39 (exit $fail); exit $fail