maint: Update HACKING
[automake.git] / t / dist-readonly.sh
blob2b41248511467d6cb19fba443a911a4f042bc4b4
1 #! /bin/sh
2 # Copyright (C) 2011-2017 Free Software Foundation, Inc.
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.
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.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <https://www.gnu.org/licenses/>.
17 # Test that a readonly files are distributed as such, and not make
18 # writable while being copied in the $(distdir).
20 # This test expect the user to be unable to write on files lacking
21 # write permissions -- so it won't work if the user is 'root'.
22 required='non-root cc'
23 . test-init.sh
25 cat >> configure.ac << 'END'
26 AC_PROG_CC
27 AC_OUTPUT
28 END
30 cat > Makefile.am << 'END'
31 bin_PROGRAMS = foo
32 foo_SOURCES = foo.c
33 EXTRA_DIST = bar.txt
34 check-local: test
35 .PHONY: test
36 test:
37 test -f $(srcdir)/foo.c && test ! -w $(srcdir)/foo.c
38 if (echo x > $(srcdir)/foo.c); then exit 1; else :; fi
39 grep 'main (void)' $(srcdir)/foo.c
40 test -f $(srcdir)/bar.txt && test ! -w $(srcdir)/bar.txt
41 if (echo x > $(srcdir)/bar.txt); then exit 1; else :; fi
42 grep 'To be, or not to be' $(srcdir)/bar.txt
43 END
45 echo 'int main (void) { return 0; }' > foo.c
46 echo To be, or not to be ... > bar.txt
47 chmod a-w foo.c bar.txt
49 $ACLOCAL
50 $AUTOCONF
51 $AUTOMAKE
53 ./configure
54 $MAKE distdir
55 ls -l $distdir # For debugging.
56 test -f foo.c && test ! -w foo.c || exit 1
57 (echo x > foo.c) && exit 1
58 test -f bar.txt && test ! -w bar.txt || exit 1
59 (echo x > bar.txt) && exit 1
60 $MAKE distcheck