53515629d007246f9fc3b6d41bb73ec74e00d090
[platform/upstream/coreutils.git] / tests / dd / misc
1 #!/bin/sh
2 # Ensure dd treats `--' properly.
3 # Also test some flag values.
4
5 tmp_in=dd-in.$$
6 tmp_in2=dd-in2.$$
7 tmp_sym=dd-sym.$$
8 tmp_out=dd-out.$$
9
10 if test "$VERBOSE" = yes; then
11   set -x
12   dd --version
13 fi
14
15 test_failure=0
16 echo data > $tmp_in || test_failure=1
17 ln $tmp_in $tmp_in2 || test_failure=1
18 ln -s $tmp_in $tmp_sym || test_failure=1
19 if test $test_failure = 1; then
20   echo 'failure in testing framework'
21   exit 1
22 fi
23
24 dd if=$tmp_in of=$tmp_out 2> /dev/null || fail=1
25 cmp $tmp_in $tmp_out || fail=1
26
27 rm $tmp_out
28 dd -- if=$tmp_in of=$tmp_out 2> /dev/null || fail=1
29 cmp $tmp_in $tmp_out || fail=1
30
31 if dd oflag=append if=$tmp_in of=$tmp_out 2> /dev/null; then
32   cmp $tmp_in $tmp_out || fail=1
33 fi
34
35 if dd iflag=nofollow if=$tmp_in count=0 2> /dev/null; then
36   dd iflag=nofollow if=$tmp_sym count=0 2> /dev/null && fail=1
37 fi
38
39 if dd iflag=directory if=. count=0 2> /dev/null; then
40   dd iflag=directory count=0 <. 2> /dev/null || fail=1
41   dd iflag=directory count=0 <$tmp_in 2> /dev/null && fail=1
42 fi
43
44 old_ls=`ls -u --full-time $tmp_in`
45 sleep 1
46 if dd iflag=noatime if=$tmp_in of=$tmp_out 2> /dev/null; then
47   new_ls=`ls -u --full-time $tmp_in`
48   if test "x$old_ls" != "x$new_ls"; then
49     echo "dd iflag=noatime updated atime; O_NOATIME bug in your kernel?" >&2
50     fail=1
51   fi
52 fi
53
54 if dd oflag=nolinks if=$tmp_in of=$tmp_out 2> /dev/null; then
55   dd iflag=nolinks if=$tmp_in > /dev/null 2>&1 && fail=1
56   dd iflag=nolinks < $tmp_in > /dev/null 2>&1 && fail=1
57   dd oflag=nolinks < $tmp_in > $tmp_out 2>&1 || fail=1
58 fi
59
60 rm -f $tmp_in $tmp_in2 $tmp_sym $tmp_out
61
62 exit $fail