ff0d0692a9a02e965137c36137a73e5fd6467ae8
[platform/upstream/coreutils.git] / tests / cp / no-deref-link2
1 #!/bin/sh
2 # FIXME: This test requires ln -s.
3 # cp from 3.16 fails this test
4
5 if test "$VERBOSE" = yes; then
6   set -x
7   cp --version
8 fi
9
10 pwd=`pwd`
11 t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
12 trap 'status=$?; cd $pwd; rm -rf $t0 && exit $status' 0
13 trap '(exit $?); exit' 1 2 13 15
14
15 framework_failure=0
16 mkdir -p $tmp || framework_failure=1
17 cd $tmp || framework_failure=1
18
19 if test $framework_failure = 1; then
20   echo "$0: failure in testing framework" 1>&2
21   (exit 1); exit 1
22 fi
23
24 mkdir b
25 msg=bar
26 echo $msg > a
27 cd b
28 ln -s ../a .
29 cd ..
30
31 fail=0
32
33 # It should fail with a message something like this:
34 #   cp: `a' and `b/foo' are the same file
35 cp -d a b 2>/dev/null
36
37 # Fail this test if the exit status is not 1
38 test $? = 1 || fail=1
39
40 test "`cat a`" = $msg || fail=1
41
42 (exit $fail); exit $fail