0fdb43953d2e55d6e952aec921bae9041149ad70
[platform/upstream/coreutils.git] / tests / install / basic-1
1 #! /bin/sh
2
3 if test "$VERBOSE" = yes; then
4   set -x
5   ginstall --version
6 fi
7
8 . $srcdir/../envvar-check
9 PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check
10
11 dir=dir
12 file=file
13
14 pwd=`pwd`
15 t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
16 trap 'status=$?; cd $pwd; chmod -R u+rwx $t0; rm -rf $t0 && exit $status' 0
17 trap '(exit $?); exit $?' 1 2 13 15
18
19 framework_failure=0
20 mkdir -p $tmp || framework_failure=1
21 cd $tmp || framework_failure=1
22
23 rm -rf $dir $file || framework_failure=1
24 mkdir -p $dir || framework_failure=1
25 echo foo > $file || framework_failure=1
26
27 if test $framework_failure = 1; then
28   echo 'failure in testing framework'
29   exit 1
30 fi
31
32 fail=0
33 ginstall $file $dir || fail=1
34 # Make sure the source file still exists.
35 test -f $file || fail=1
36 # Make sure the dest file has been created.
37 test -f $dir/$file || fail=1
38
39 # Make sure strip works.
40 dd=dd$EXEEXT
41 dd2=dd2$EXEEXT
42 cp $pwd/../../src/$dd . || fail=1
43 cp $dd $dd2 || fail=1
44
45 strip $dd2 || \
46   {
47     cat 1>&2 <<EOF
48 $0: WARNING!!!
49 Your strip command doesn't seem to work, so skipping
50 the test of install's --strip option.
51 EOF
52     exit 77
53   }
54
55 # This test would fail with 3.16s when using versions of strip that
56 # don't work on read-only files (the one from binutils works fine).
57 ginstall -s -c -m 555 $dd $dir || fail=1
58 # Make sure the source file is still around.
59 test -f $dd || fail=1
60
61 # Make sure that the destination file has the requested permissions.
62 set X `ls -l $dir/$dd`
63 shift
64 test "$1" = -r-xr-xr-x || fail=1
65
66 # These failed in coreutils CVS from 2004-06-25 to 2004-08-11.
67 ginstall -d . || fail=1
68 ginstall -d newdir || fail=1
69 test -d newdir || fail=1
70 ginstall -d newdir1 newdir2 newdir3 || fail=1
71 test -d newdir1 || fail=1
72 test -d newdir2 || fail=1
73 test -d newdir3 || fail=1
74
75 # This fails because mkdir-p.c's make_dir_parents fails to return to its
76 # initial working directory ($abs) after creating the first argument, and
77 # hence cannot do anything meaningful with the following relative-named dirs.
78 abs=$pwd/$tmp
79 mkdir sub && cd sub
80 chmod 0 .; ginstall -d $abs/xx/yy rel/sub1 rel/sub2 2> /dev/null && fail=1
81 chmod 755 $abs/sub
82
83 # Ensure that the first argument-dir has been created.
84 test -d $abs/xx/yy || fail=1
85
86 # Make sure that the `rel' directory was not created...
87 test -d $abs/sub/rel && fail=1
88 # and make sure it was not created in the wrong place.
89 test -d $abs/xx/rel && fail=1
90
91 (exit $fail); exit $fail