Add/fix copyright notices and adjust to latest GNU FDL.
[platform/upstream/coreutils.git] / tests / install / basic-1
1 #! /bin/sh
2 # Basic tests for "install".
3
4 # Copyright (C) 1998, 2000, 2001, 2002, 2004, 2005 Free Software
5 # Foundation, Inc.
6
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
11
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
16
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 # 02110-1301, USA.
21
22 if test "$VERBOSE" = yes; then
23   set -x
24   ginstall --version
25 fi
26
27 . $srcdir/../envvar-check
28 PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check
29
30 dir=dir
31 file=file
32
33 pwd=`pwd`
34 t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
35 trap 'status=$?; cd $pwd; chmod -R u+rwx $t0; rm -rf $t0 && exit $status' 0
36 trap '(exit $?); exit $?' 1 2 13 15
37
38 framework_failure=0
39 mkdir -p $tmp || framework_failure=1
40 cd $tmp || framework_failure=1
41
42 rm -rf $dir $file || framework_failure=1
43 mkdir -p $dir || framework_failure=1
44 echo foo > $file || framework_failure=1
45
46 if test $framework_failure = 1; then
47   echo 'failure in testing framework'
48   exit 1
49 fi
50
51 fail=0
52 ginstall $file $dir || fail=1
53 # Make sure the source file still exists.
54 test -f $file || fail=1
55 # Make sure the dest file has been created.
56 test -f $dir/$file || fail=1
57
58 # Make sure strip works.
59 dd=dd$EXEEXT
60 dd2=dd2$EXEEXT
61 cp $pwd/../../src/$dd . || fail=1
62 cp $dd $dd2 || fail=1
63
64 strip $dd2 || \
65   {
66     cat 1>&2 <<EOF
67 $0: WARNING!!!
68 Your strip command doesn't seem to work, so skipping
69 the test of install's --strip option.
70 EOF
71     exit 77
72   }
73
74 # This test would fail with 3.16s when using versions of strip that
75 # don't work on read-only files (the one from binutils works fine).
76 ginstall -s -c -m 555 $dd $dir || fail=1
77 # Make sure the source file is still around.
78 test -f $dd || fail=1
79
80 # Make sure that the destination file has the requested permissions.
81 set X `ls -l $dir/$dd`
82 shift
83 test "$1" = -r-xr-xr-x || fail=1
84
85 # These failed in coreutils CVS from 2004-06-25 to 2004-08-11.
86 ginstall -d . || fail=1
87 ginstall -d newdir || fail=1
88 test -d newdir || fail=1
89 ginstall -d newdir1 newdir2 newdir3 || fail=1
90 test -d newdir1 || fail=1
91 test -d newdir2 || fail=1
92 test -d newdir3 || fail=1
93
94 # This fails because mkdir-p.c's make_dir_parents fails to return to its
95 # initial working directory ($abs) after creating the first argument, and
96 # hence cannot do anything meaningful with the following relative-named dirs.
97 abs=$pwd/$tmp
98 mkdir sub && cd sub
99 chmod 0 .; ginstall -d $abs/xx/yy rel/sub1 rel/sub2 2> /dev/null && fail=1
100 chmod 755 $abs/sub
101
102 # Ensure that the first argument-dir has been created.
103 test -d $abs/xx/yy || fail=1
104
105 # Make sure that the `rel' directory was not created...
106 test -d $abs/sub/rel && fail=1
107 # and make sure it was not created in the wrong place.
108 test -d $abs/xx/rel && fail=1
109
110 (exit $fail); exit $fail