c2b0cf7b434c02c10b0230c2e2c05e622cd85186
[platform/upstream/coreutils.git] / tests / cp / cp-HL
1 #!/bin/sh
2 # test cp's new, -H and -L options
3
4 if test "$VERBOSE" = yes; then
5   set -x
6   cp --version
7 fi
8
9 . $srcdir/../envvar-check
10
11 pwd=`pwd`
12 tmp=cp-HL.$$
13 trap 'status=$?; cd $pwd; rm -rf $tmp && exit $status' 0
14 trap 'exit $?' 1 2 13 15
15
16 framework_failure=0
17 mkdir $tmp || framework_failure=1
18 cd $tmp || framework_failure=1
19
20 mkdir src-dir dest-dir || framework_failure=1
21 echo f > f || framework_failure=1
22 ln -s f slink || framework_failure=1
23 ln -s no-such-file src-dir/slink || framework_failure=1
24
25 if test $framework_failure = 1; then
26   echo 'failure in testing framework'
27   exit 1
28 fi
29
30 fail=0
31
32 cp -H -R slink src-dir dest-dir || fail=1
33 test -d src-dir || fail=1
34 test -d dest-dir/src-dir || fail=1
35
36 # Expect this to succeed since this slink is not a symlink
37 cat dest-dir/slink > /dev/null 2>&1 || fail=1
38
39 # Expect this to fail since *this* slink is a dangling symlink.
40 cat dest-dir/src-dir/slink > /dev/null 2>&1 && fail=1
41
42 # FIXME: test -L, too.
43
44 (exit $fail); exit