tests: expose automake bug#13940
[platform/upstream/automake.git] / t / tar-ustar-id-too-high.sh
1 #! /bin/sh
2 # Copyright (C) 2013 Free Software Foundation, Inc.
3 #
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2, or (at your option)
7 # any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
17 # Check that UID or GID too high for the ustar format are correctly
18 # rwcognized and diagnosed by configure.  See bug#8343 and bug#13588.
19
20 . test-init.sh
21
22 cat > configure.ac <<END
23 AC_INIT([$me], [1.0])
24 AM_INIT_AUTOMAKE([tar-ustar])
25 AC_CONFIG_FILES([Makefile])
26 AC_OUTPUT
27 END
28
29 : > Makefile.am
30
31 run_configure()
32 {
33   st=0; ./configure ${1+"$@"}  >stdout || st=$?
34   cat stdout || exit 1
35   test $st -eq 0 || exit 1
36 }
37
38 checked ()
39 {
40   grep "^checking $1\.\.\. $2$" stdout
41 }
42
43 $ACLOCAL
44 $AUTOCONF
45 $AUTOMAKE
46
47 mkdir bin
48 cat > bin/id <<'END'
49 #!/bin/sh -e
50 case "$*" in
51   -u) echo "${am_uid-1000}";;
52   -g) echo "${am_gid-1000}";;
53    *) echo "id: bad/unexpected usage" >&2; exit 1;;
54 esac
55 END
56 chmod a+x bin/id
57
58 PATH=$(pwd)/bin$PATH_SEPARATOR$PATH
59
60 # Problematic ID reported in
61 # <https://bugzilla.redhat.com/show_bug.cgi?id=843376>.
62 am_uid=16777216; export am_uid
63 am_gid=1000;     export am_gid
64 run_configure
65 checked "whether UID '$am_uid' is supported by ustar format" "no"
66 checked "whether GID '1000' is supported by ustar format" "yes"
67 checked "how to create a ustar tar archive" "none"
68
69 # Another problematic ID reported in
70 # <https://bugzilla.redhat.com/show_bug.cgi?id=843376>.
71 am_uid=1000;     export am_uid
72 am_gid=17000000; export am_gid
73 run_configure
74 checked "whether UID '1000' is supported by ustar format" "yes"
75 checked "whether GID '$am_gid' is supported by ustar format" "no"
76 checked "how to create a ustar tar archive" "none"
77
78 # The minimal ID that is too big.
79 two_to_twentyone=$((32 * 32 * 32 * 32 * 2))
80 # <https://bugzilla.redhat.com/show_bug.cgi?id=843376>.
81 am_uid=$two_to_twentyone; export am_uid
82 am_gid=$two_to_twentyone; export am_gid
83 run_configure
84 checked "whether UID '$two_to_twentyone' is supported by ustar format" "no"
85 checked "whether GID '$two_to_twentyone' is supported by ustar format" "no"
86 checked "how to create a ustar tar archive" "none"
87
88 :