[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 1/3] Refactor and extend tests on cscope functionality.
From: |
Stefano Lattarini |
Subject: |
Re: [PATCH 1/3] Refactor and extend tests on cscope functionality. |
Date: |
Tue, 22 Jun 2010 13:09:10 +0200 |
User-agent: |
KMail/1.12.1 (Linux/2.6.30-2-686; KDE/4.3.4; i686; ; ) |
At Monday 21 June 2010, Ralf Wildenhues wrote:
> >
> > --- a/tests/cscope3.test
> > +++ b/tests/cscope3.test
> > [CUT]
> > ./configure
> > $MAKE cscope
> > +# FIXME (in automake.in): We'd like cscope.files not to be
> > +#created, as there are no source files in `.' nor in `sub'.
> > +test ! -s cscope.files
> > +test ! -f cscope.out
>
> Why is that? Why would we not want the file cscope.files to be
> created?
Because, if there are no sources, there's no point in creating it.
And this is exactly what happens when no "recursive subdir" is
present (see cscope2.test). But this is just a minor minor nit
(and in fact the comment says that "we'd like", not that "it
should"). And now, I think that a more "neuter" comment would
be better:
#
# NOTE: Ideally, we'd like cscope.files not to be created, as there are
# no source files in `.' nor in `sub'. But implementing this could
# complicate the associated Makefile rules, and it's probably not worth
# the hassle. Thus we content ourself with ensuring that, if cscope.list
# is created, it is at least empty.
#
I amended the patch to use this comment.
> >
> > --- /dev/null
> > +++ b/tests/cscope6.test
> >
> > [CUT]
> >
> > +
> > +for d in . sub; do
> > + LC_ALL=C sed \
> > + -e '/^ address@hidden@ *$/d' \
>
> Removing SET_MAKE is not going to work with a package using
> recursive makefiles and some ancient makes. I don't know whether
> any of them are relevant any more though.
We could play on the safe side and use
-e "s/^ address@hidden@ *$/MAKE = $MAKE/" \
instead (but see below my acceptance of your later suggestion).
And BTW, this fix should be applied to all the tests that use a similar
sed transformation on Makefile.in, but this should be the object of
another thread.
> > + -e '/address@hidden@/d' \
> > + -e '/address@hidden@/d' \
> > + -e "s|^CSCOPE *=.*|CSCOPE = $cscope|" \
> > + -e 's|^srcdir *=.*|srcdir = .|' \
> > + -e 's|^builddir *=.*|builddir = .|' \
> > + -e 's|^VPATH *=.*|VPATH = .|' \
> > + -e 's|^SHELL *=.*|SHELL = /bin/sh|' \
>
> This might not work everywhere, /bin/sh might not exist (nevermind
> the #!/bin/sh lines, for them to work it needs system support, not
> necessarily the presence of a /bin/sh file).
Right. We could use:
-e "s|^SHELL *=.*|SHELL = $SHELL|"
instead (but see below my acceptance of your later suggestion).
> > + -e 's|@PATH_SEPARATOR@|:|g' \
>
> This is not going to work portably.
>
> > + <$d/Makefile.in >$d/Makefile.tmp
> > + # FIXME above: we should use the $PATH_SEPARATOR found
> > + # at configure time...
>
> How about, instead, running configure with all the required tools
> pre-set? That way, all you need is a C compiler.
Definitely a good idea, much much better that my hackish sed munging
of Makefile.in. And after all, a lot of tests in the automake testsuite
require a working C Compiler. The amended version of the patch follows
your insight.
> > --- /dev/null
> > +++ b/tests/cscope7.test
>
> This test has similar issues as cscope6.test
>
Which can be fixed in the same way :-)
> > --- /dev/null
> > +++ b/tests/cscopec.test
> >
> > +# Test for cscope functionality with C files.
> > +# Please keep this in sync with the sister test 'cscopecxx.test'.
> > +
> > +required='gcc cscope'
> > +. ./defs || Exit 1
> > +
> > +set -e
> > +
> > +cat >> configure.in <<'END'
> > +AC_CONFIG_FILES([sub/Makefile])
> > +AC_PROG_CC
> > +AC_OUTPUT
> > +END
> > +
> > +mkdir sub sub/subsub
> > +
> > +cat > Makefile.am <<'END'
> > +SUBDIRS = sub
> > +bin_PROGRAMS = foo
> > +foo_SOURCES = foo.c main-alias.h
> > +END
> > +
> > +cat > sub/Makefile.am <<'END'
> > +bin_PROGRAMS = bar
> > +bar_SOURCES = subsub/dist.c
> > +nodist_bar_SOURCES = gen.c
> > +gen.c:
> > + echo 'int generated_func () { return 0; }' > $@
> > +CLEANFILES = gen.c
> > +END
> > +
> > +cat > main-alias.h <<'END'
> > +#define RUN int main (void)
> > +END
> > +
> > +cat > foo.c <<'END'
> > +#include "main-alias.h"
> > +RUN
> > +{
> > + return 0;
> > +}
> > +END
> > +
> > +cat > sub/subsub/dist.c <<'END'
> > +int generated_func();
> > +int main ()
> > +{
> > + return generated_func();
> > +}
> > +END
> > +
> > +$ACLOCAL
> > +$AUTOCONF
> > +$AUTOMAKE --add-missing
> > +
> > +ocwd=`pwd`
> > +
> > +for d in parent abs_parent current; do
> > +
> > + case $d in
> > + current)
> > + ./configure
> > + ;;
> > + parent)
> > + mkdir build
> > + cd build
> > + ../configure
> > + ;;
> > + abs_parent)
> > + mkdir build2
> > + cd build2
> > + "$ocwd/configure"
> > + ;;
> > + *)
> > + Exit 99 # sanity check
> > + ;;
> > + esac
> > +
> > + $MAKE cscope 2>stderr || { cat stderr >&2; Exit 1; }
> > + cat stderr >&2
> > + grep 'cannot find file' stderr && Exit 1
> > + ls -l . sub
> > + cat cscope.files # must exist
> > + test -f cscope.out
> > + test ! -f sub/cscope.files
> > + test ! -f sub/subsub/cscope.files
> > +
> > + case $d in
> > + current)
> > + cat <<'END'
> > +./foo.c
> > +./main-alias.h
> > +sub/gen.c
> > +sub/subsub/dist.c
> > +END
> > + ;;
> > + parent)
> > + cat <<'END'
> > +./../foo.c
> > +./../main-alias.h
> > +sub/../../sub/subsub/dist.c
> > +sub/gen.c
> > +END
> > + ;;
> > + abs_parent)
> > + cat <<END
> > +$ocwd/foo.c
> > +$ocwd/main-alias.h
> > +$ocwd/sub/subsub/dist.c
> > +sub/gen.c
> > +END
> > + ;;
> > + esac | LC_ALL=C sort > fileslist-exp
> > +
> > + LC_ALL=C sort cscope.files > fileslist-got
> > + cat fileslist-exp
> > + cat fileslist-got
> > + diff fileslist-exp fileslist-got
>
> How come this doesn't fail with Solaris make expanding VPATH file
> names in the makefile?
Well, in fact, *it fails*, but the patch 2/3 in this series fixes such
failure (and this test can serve to expose the bug fixed by that patch).
> I think in general, we might expect a bit too much here. make
> might even simplify noncanonical paths such as sub/../../sub/...
Ouch. What a silly behaviour.
> (see the section on make issues in the Autoconf manual) e.g. on
> Tru64/OSF. (I haven't tested that though.)
>
> Similar with cscopecxx.test.
Hmm... What about leaving the dirty work of generating fileslist-exp to
make? This way, make itself can simplify for us any noncanonical
path to be put in fileslist-exp.
My try is in the amended patch. WDYT?
> The rest of the large patch looks fairly good to me, and 2/3 is
> pretty obvious too.
Good!
Regards,
Stefano
From 35555becd068bbd84bbfe28ef956b6538d623d1b Mon Sep 17 00:00:00 2001
From: Stefano Lattarini <address@hidden>
Date: Sat, 19 Jun 2010 11:56:02 +0200
Subject: [PATCH 1/3] Refactor and extend tests on cscope functionality.
* tests/cscope.test: Improve and normalize generation and names
of source files.
Do not use hackish, belated SKIPs anymore.
Slighty extend existing tests.
(configure.in): Do not call macro `AM_PROG_GCJ' anymore.
($required): Set properly.
($EMACS): Intialize and export, for use by configure.
* tests/cscope2.test: Add 'cscope' to $required. Check that
the 'cscope' target do not generate any file if there are no
source files.
* tests/cscope3.test: Add 'cscope' to $required. Check that
the recursive 'cscope' target do not create a 'cscope.out' file
if there is no source files. Add an explanatory comment.
* tests/cscope4.test: New test.
* tests/cscope5.test: Likewise.
* tests/cscope6.test: Likewise.
* tests/cscope7.test: Likewise.
* tests/cscopec.test: Likewise.
* tests/cscopecxx.test: Likewise.
* tests/cscope8.test: New test, similar to cscope.test, but adds
java, lex, yacc and fortran77 sources to the mix.
* tests/Makefile.am (TESTS): Updated.
---
ChangeLog | 26 ++++++
tests/Makefile.am | 7 ++
tests/Makefile.in | 7 ++
tests/cscope.test | 82 ++++++++++++++------
tests/cscope2.test | 10 ++-
tests/cscope3.test | 14 +++-
tests/cscope4.test | 83 ++++++++++++++++++++
tests/cscope5.test | 55 +++++++++++++
tests/cscope6.test | 134 ++++++++++++++++++++++++++++++++
tests/cscope7.test | 137 +++++++++++++++++++++++++++++++++
tests/cscope8.test | 206 ++++++++++++++++++++++++++++++++++++++++++++++++++
tests/cscopec.test | 158 ++++++++++++++++++++++++++++++++++++++
tests/cscopecxx.test | 158 ++++++++++++++++++++++++++++++++++++++
13 files changed, 1046 insertions(+), 31 deletions(-)
create mode 100755 tests/cscope4.test
create mode 100755 tests/cscope5.test
create mode 100755 tests/cscope6.test
create mode 100755 tests/cscope7.test
create mode 100755 tests/cscope8.test
create mode 100755 tests/cscopec.test
create mode 100755 tests/cscopecxx.test
diff --git a/ChangeLog b/ChangeLog
index 31d354e..45c5da8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,29 @@
+2010-06-21 Stefano Lattarini <address@hidden>
+
+ Refactor and extend tests on cscope functionality.
+ * tests/cscope.test: Improve and normalize generation and names
+ of source files.
+ Do not use hackish, belated SKIPs anymore.
+ Slighty extend existing tests.
+ (configure.in): Do not call macro `AM_PROG_GCJ' anymore.
+ ($required): Set properly.
+ ($EMACS): Intialize and export, for use by configure.
+ * tests/cscope2.test: Add 'cscope' to $required. Check that
+ the 'cscope' target do not generate any file if there are no
+ source files.
+ * tests/cscope3.test: Add 'cscope' to $required. Check that
+ the recursive 'cscope' target do not create a 'cscope.out' file
+ if there is no source files. Add an explanatory comment.
+ * tests/cscope4.test: New test.
+ * tests/cscope5.test: Likewise.
+ * tests/cscope6.test: Likewise.
+ * tests/cscope7.test: Likewise.
+ * tests/cscopec.test: Likewise.
+ * tests/cscopecxx.test: Likewise.
+ * tests/cscope8.test: New test, similar to cscope.test, but adds
+ java, lex, yacc and fortran77 sources to the mix.
+ * tests/Makefile.am (TESTS: Updated.
+
2010-06-12 Stefano Lattarini <address@hidden>
cscope.test: ensure verbose printing of captured stderr.
diff --git a/tests/Makefile.am b/tests/Makefile.am
index e974689..de237bb 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -211,6 +211,13 @@ copy.test \
cscope.test \
cscope2.test \
cscope3.test \
+cscope4.test \
+cscope5.test \
+cscope6.test \
+cscope7.test \
+cscope8.test \
+cscopec.test \
+cscopecxx.test \
ctarget1.test \
cxx.test \
cxx2.test \
diff --git a/tests/Makefile.in b/tests/Makefile.in
index 9e9fb97..cf90537 100644
--- a/tests/Makefile.in
+++ b/tests/Makefile.in
@@ -445,6 +445,13 @@ copy.test \
cscope.test \
cscope2.test \
cscope3.test \
+cscope4.test \
+cscope5.test \
+cscope6.test \
+cscope7.test \
+cscope8.test \
+cscopec.test \
+cscopecxx.test \
ctarget1.test \
cxx.test \
cxx2.test \
diff --git a/tests/cscope.test b/tests/cscope.test
index 497335d..2f145f8 100755
--- a/tests/cscope.test
+++ b/tests/cscope.test
@@ -14,19 +14,20 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-# Test cscope functionality.
+# Stress test for cscope functionality.
-required=
+required='gcc g++ gfortran emacs cscope'
. ./defs || Exit 1
set -e
+EMACS=emacs; export EMACS # so that it will be picked up by configure
+
cat >> configure.in << 'END'
AC_CONFIG_FILES([sub/Makefile])
AC_PROG_CC
AC_PROG_CXX
AC_PROG_FC
-AM_PROG_GCJ
AM_PATH_LISPDIR
AC_OUTPUT
END
@@ -35,10 +36,9 @@ mkdir sub sub/subsub
cat >Makefile.am <<'END'
SUBDIRS = sub
-bin_PROGRAMS = foo
-foo_SOURCES = foo.c bar.cpp baz.f90
-lisp_LISP = foo.el
-EXTRA_DIST = foo.el
+bin_PROGRAMS = prog
+prog_SOURCES = foo.c bar.cpp baz.f90
+dist_lisp_LISP = zardoz.el
END
cat >sub/Makefile.am <<'END'
@@ -51,14 +51,35 @@ subsub/gen.c:
CLEANFILES = subsub/gen.c
END
-echo 'int foo_func () { return 0; }' > foo.c
-echo 'int main () { return 0; }' > bar.cpp
+cat > foo.c <<'END'
+int foo_func (void)
+{
+ return 0;
+}
+END
+
+cat > bar.cpp <<'END'
+extern "C" int foo_func(void);
+int main (void)
+{
+ return foo_func();
+}
+END
+
cat > baz.f90 <<'END'
subroutine baz
end
END
-: >foo.el
-echo 'int main () { return 0; }' > sub/subsub/dist.c
+
+: > zardoz.el
+
+cat > sub/subsub/dist.c <<'END'
+int generated_subsub();
+int main()
+{
+ return generated_subsub();
+}
+END
$ACLOCAL
$AUTOCONF
@@ -66,42 +87,53 @@ $AUTOMAKE --add-missing
mkdir build
cd build
-../configure || Exit 77
-
-$MAKE -n cscope
-
-: ${CSCOPE=cscope}
-( $CSCOPE --version ) >/dev/null 2>&1 || Exit 77
+../configure
$MAKE cscope 2>stderr || { cat stderr >&2; Exit 1; }
cat stderr >&2
grep 'cannot find file' stderr && Exit 1
test -f cscope.files
-$FGREP foo.c cscope.files
-$FGREP bar.cpp cscope.files
-$FGREP sub/subsub/dist.c cscope.files
-$FGREP sub/subsub/gen.c cscope.files
-
-cp cscope.files cscope.files1
+test ! -f sub/cscope.files
+test -s cscope.out # must be non-empty
+test ! -f sub/cscope.out
+$EGREP '(^|/)foo\.c$' cscope.files
+$EGREP '(^|/)bar\.cpp$' cscope.files
+$EGREP '(^|/)sub/subsub/dist\.c$' cscope.files
+$EGREP '(^|/)sub/subsub/gen\.c$' cscope.files
+
+# Check that making 'cscope' twice do not inappropriately append extra
+# text to 'cscope.files'.
+cp -f cscope.files cscope.files1
$MAKE cscope
diff cscope.files cscope.files1
+# Try to ensure our test distribution can be built and cleaned.
+$MAKE
$MAKE distclean
test ! -f cscope.files
test ! -f cscope.out
test ! -f cscope.in.out
test ! -f cscope.po.out
-
-`pwd`/../configure || Exit 77
+# Now try with $top_srcdir being an absolute path.
+cwd=`pwd`
+"$cwd/../configure"
$MAKE cscope 2>stderr || { cat stderr >&2; Exit 1; }
cat stderr >&2
grep 'cannot find file' stderr && Exit 1
+
+# Try to ensure our test distribution can be built and cleaned.
+$MAKE
$MAKE distclean
+test ! -f cscope.files
+test ! -f cscope.out
+test ! -f cscope.in.out
+test ! -f cscope.po.out
cd ..
+# Try to ensure our test distribution is self-contained.
./configure
$MAKE distcheck
diff --git a/tests/cscope2.test b/tests/cscope2.test
index 106b801..1ab405c 100755
--- a/tests/cscope2.test
+++ b/tests/cscope2.test
@@ -1,5 +1,5 @@
#! /bin/sh
-# Copyright (C) 2009 Free Software Foundation, Inc.
+# Copyright (C) 2009, 2010 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -16,7 +16,7 @@
# The `cscope' target should not fail if there are no sources.
-required=
+required=cscope
. ./defs || Exit 1
set -e
@@ -24,7 +24,8 @@ set -e
cat >> configure.in << 'END'
AC_OUTPUT
END
-: >Makefile.am
+
+: > Makefile.am
$ACLOCAL
$AUTOCONF
@@ -32,5 +33,8 @@ $AUTOMAKE
./configure
$MAKE cscope
+ls . > lst
+cat lst
+$FGREP cscope lst && Exit 1
:
diff --git a/tests/cscope3.test b/tests/cscope3.test
index 03e1d47..ee4a0e0 100755
--- a/tests/cscope3.test
+++ b/tests/cscope3.test
@@ -1,5 +1,5 @@
#! /bin/sh
-# Copyright (C) 2009 Free Software Foundation, Inc.
+# Copyright (C) 2009, 2010 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -27,9 +27,10 @@ cat >> configure.in << 'END'
AC_CONFIG_FILES([sub/Makefile])
AC_OUTPUT
END
+
+echo 'SUBDIRS = sub' > Makefile.am
mkdir sub
-echo 'SUBDIRS = sub' >Makefile.am
-: >sub/Makefile.am
+: > sub/Makefile.am
$ACLOCAL
$AUTOCONF
@@ -37,5 +38,12 @@ $AUTOMAKE
./configure
$MAKE cscope
+# NOTE: Ideally, we'd like cscope.files not to be created, as there are
+# no source files in `.' nor in `sub'. But implementing this could
+# complicate the associated Makefile rules, and it's probably not worth
+# the hassle. Thus we content ourself with ensuring that, if cscope.list
+# is created, it is at least empty.
+test ! -s cscope.files
+test ! -f cscope.out
:
diff --git a/tests/cscope4.test b/tests/cscope4.test
new file mode 100755
index 0000000..6bb8fc9
--- /dev/null
+++ b/tests/cscope4.test
@@ -0,0 +1,83 @@
+#! /bin/sh
+# Copyright (C) 2010 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Static checks on cscope functionality, done grepping the Makefile.in
+# files.
+
+. ./defs || Exit 1
+
+set -e
+
+cat >> configure.in << 'END'
+AC_CONFIG_FILES([sub/Makefile sub/subsub1/Makefile sub/subsub2/Makefile])
+AC_PROG_CC
+AC_OUTPUT
+END
+
+mkdir sub sub/subsub1 sub/subsub2
+
+cat > Makefile.am <<'END'
+SUBDIRS = sub
+bin_PROGRAMS = foo
+foo_SOURCES = foo.c
+END
+
+cat > sub/Makefile.am <<'END'
+SUBDIRS = subsub1 subsub2
+bin_PROGRAMS = bar
+bar_SOURCES = bar.c
+END
+
+cat > sub/subsub1/Makefile.am <<'END'
+bin_PROGRAMS = qux
+qux_SOURCES = baz.c
+END
+
+cat > sub/subsub2/Makefile.am <<'END'
+zardozdir = $(prefix)/zardoz
+dist_zardoz_DATA = data.txt
+END
+
+$ACLOCAL
+$AUTOMAKE --add-missing
+
+m=Makefile.in # I'm a lazy typist
+
+grep '^CSCOPE =' $m
+grep '^cscope:.* cscope\.files' $m
+grep '^cscope\.files:' $m
+grep '^cscopelist:.* cscopelist-recursive' $m
+grep '^cscopelist-recursive:' $m
+grep '^clean-cscope:' $m
+grep '\$(CSCOPE).*\$(AM_CSCOPEFLAGS).*\$(CSCOPEFLAGS).*\$(CSCOPE_ARGS)' $m
+
+for d in sub sub/subsub1 sub/subsub2; do
+ grep 'cscope\.files:' $d/$m && Exit 1
+ grep 'CSCOPE' $d/$m && Exit 1
+ grep '^cscope:' $d/$m && Exit 1
+ grep 'clean-cscope' $d/$m && Exit 1
+ grep 'rm -f cscope\.' $d/$m && Exit 1
+done
+
+grep '^cscopelist:.* cscopelist-recursive' sub/$m
+for d in sub/subsub1 sub/subsub2; do
+ # The following hairy regexp is required, because the 'cscopelist'
+ # target might be dummy, and lumped in with other related dummy
+ # targets.
+ $EGREP '(^| )cscopelist(:| .*:)' $d/$m
+done
+
+:
diff --git a/tests/cscope5.test b/tests/cscope5.test
new file mode 100755
index 0000000..196d4e2
--- /dev/null
+++ b/tests/cscope5.test
@@ -0,0 +1,55 @@
+#! /bin/sh
+# Copyright (C) 2010 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Check that $(CSCOPE) is overridable in Makefile.am, and that the cscope
+# target honours $(AM_CSCOPEFLAGS) and $(CSCOPEFLAGS) in the correct order.
+
+required=gcc
+. ./defs || Exit 1
+
+set -e
+
+cat >> configure.in << 'END'
+AC_PROG_CC
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+bin_PROGRAMS = foo
+foo_SOURCES = foo.c
+
+CSCOPE = echo >out X
+AM_CSCOPEFLAGS = __am_cscope_flags__
+CSCOPEFLAGS = __usr_cscope_flags__
+END
+
+: > foo.c
+
+$ACLOCAL
+$AUTOCONF
+
+# Opportunistically test error message about $(CSCOPE) redefinition.
+AUTOMAKE_fails
+grep 'user variable.*CSCOPE' stderr
+grep 'override.*[Aa]utomake variable.*CSCOPE' stderr
+
+$AUTOMAKE -Wno-override
+
+./configure
+$MAKE cscope
+grep 'X.*__am_cscope_flags__.*__usr_cscope_flags__' out
+
+:
diff --git a/tests/cscope6.test b/tests/cscope6.test
new file mode 100755
index 0000000..dcf790b
--- /dev/null
+++ b/tests/cscope6.test
@@ -0,0 +1,134 @@
+#! /bin/sh
+# Copyright (C) 2010 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Basic checks on cscope functionality.
+# This test does *not* require the cscope program, nor any compiler.
+# Please keep this test in sync with the sister test `cscope7.test'.
+
+. ./defs || Exit 1
+
+set -e
+
+cat >> configure.in << 'END'
+AC_CONFIG_FILES([sub/Makefile])
+AC_PROG_CC
+AC_PROG_CXX
+AC_PROG_LEX
+AC_PROG_YACC
+AC_PROG_F77
+AC_PROG_FC
+AM_PROG_GCJ
+AM_PATH_LISPDIR
+AC_OUTPUT
+END
+
+mkdir sub sub/subsub
+
+cat > Makefile.am <<'END'
+SUBDIRS = sub
+dist_lisp_LISP = zardoz.el
+bin_PROGRAMS = foo
+foo_SOURCES = ## will be extended later
+END
+
+cat > sub/Makefile.am <<'END'
+bin_PROGRAMS = bar
+bar_SOURCES = subsub/dist.c
+nodist_bar_SOURCES = subsub/gen.c
+subsub/gen.c:; echo '/*GeNeRaTeD*/' >$@
+END
+
+: > fileslist-exp
+
+for f in \
+ foo01.c \
+ foo02.cc \
+ foo03.cpp \
+ foo04.cxx \
+ foo05.c++ \
+ foo06.y \
+ foo07.ypp \
+ foo08.yy \
+ foo09.l \
+ foo10.l++ \
+ foo11.lxx \
+ foo12.f \
+ foo13.f90 \
+ quux.java \
+; do
+ touch $f # cannot use ': >', as Solaris Sh "optimize" it away
+ echo ./$f >> fileslist-exp
+ echo foo_SOURCES += $f >> Makefile.am
+done
+
+cat >> fileslist-exp <<'END'
+./zardoz.el
+sub/subsub/dist.c
+sub/subsub/gen.c
+END
+
+: > zardoz.el
+: > sub/subsub/dist.c
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+#
+# We want to be able to run this test even if some of configure-time
+# requirements (various compilers, an emacs installation, etc.) are
+# not present on the system.
+# Since the various compilers/tools shoudn't be run anyway by make,
+# we can pre-set them to dummy values for configure.
+#
+: > x.c
+./configure \
+ --disable-dependency-tracking \
+ --with-lispdir='/nonesuch' EMACS=false \
+ YACC=false LEX=false ac_cv_prog_lex_root=x LEXLIB='' \
+ CXX=false GCJ=false F77=false FC=false
+rm -f x.c
+
+$MAKE -n cscope
+CSCOPE=false $MAKE -e cscopelist
+ls -l . sub sub/subsub # useful for debugging
+cat cscope.files # must exist
+test ! -f cscope.out
+test ! -f sub/cscope.files
+test ! -f sub/cscope.out
+test -f sub/subsub/gen.c
+$FGREP '/*GeNeRaTeD*/' sub/subsub/gen.c
+
+LC_ALL=C sort cscope.files >fileslist-got
+
+cat fileslist-exp
+cat fileslist-got
+diff fileslist-exp fileslist-got
+
+# Check that making 'cscope' twice do not inappropriately
+# append extra text to 'cscope.files'.
+cp -f cscope.files prevlist
+CSCOPE=: $MAKE -e cscope
+diff prevlist cscope.files
+
+$MAKE clean
+test -f cscope.files
+
+$MAKE distclean
+ls > lst
+$FGREP 'cscope' lst && Exit 1
+
+:
diff --git a/tests/cscope7.test b/tests/cscope7.test
new file mode 100755
index 0000000..4bc70b7
--- /dev/null
+++ b/tests/cscope7.test
@@ -0,0 +1,137 @@
+#! /bin/sh
+# Copyright (C) 2010 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Basic checks on cscope functionality.
+# This test does *not* require any compiler.
+# Please keep this test in sync with the sister test `cscope6.test'.
+
+required=cscope
+. ./defs || Exit 1
+
+set -e
+
+cat >> configure.in << 'END'
+AC_CONFIG_FILES([sub/Makefile])
+AC_PROG_CC
+AC_PROG_CXX
+AC_PROG_LEX
+AC_PROG_YACC
+AC_PROG_F77
+AC_PROG_FC
+AM_PROG_GCJ
+AM_PATH_LISPDIR
+AC_OUTPUT
+END
+
+mkdir sub sub/subsub
+
+cat > Makefile.am <<'END'
+SUBDIRS = sub
+dist_lisp_LISP = zardoz.el
+bin_PROGRAMS = foo
+foo_SOURCES = ## will be extended later
+END
+
+cat > sub/Makefile.am <<'END'
+bin_PROGRAMS = bar
+bar_SOURCES = subsub/dist.c
+nodist_bar_SOURCES = subsub/gen.c
+subsub/gen.c:; echo '/*GeNeRaTeD*/' >$@
+END
+
+: > fileslist-exp
+
+for f in \
+ foo01.c \
+ foo02.cc \
+ foo03.cpp \
+ foo04.cxx \
+ foo05.c++ \
+ foo06.y \
+ foo07.ypp \
+ foo08.yy \
+ foo09.l \
+ foo10.l++ \
+ foo11.lxx \
+ foo12.f \
+ foo13.f90 \
+ quux.java \
+; do
+ touch $f # cannot use ': >', as Solaris Sh "optimize" it away
+ echo ./$f >> fileslist-exp
+ echo foo_SOURCES += $f >> Makefile.am
+done
+
+cat >> fileslist-exp <<'END'
+./zardoz.el
+sub/subsub/dist.c
+sub/subsub/gen.c
+END
+
+: > zardoz.el
+: > sub/subsub/dist.c
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+#
+# We want to be able to run this test even if some of configure-time
+# requirements (various compilers, an emacs installation, etc.) are
+# not present on the system.
+# Since the various compilers/tools shoudn't be run anyway by make,
+# we can pre-set them to dummy values for configure.
+#
+: > x.c
+./configure \
+ --disable-dependency-tracking \
+ --with-lispdir='/nonesuch' EMACS=false \
+ YACC=false LEX=false ac_cv_prog_lex_root=x LEXLIB='' \
+ CXX=false GCJ=false F77=false FC=false
+rm -f x.c
+
+$MAKE cscope 2>stderr || { cat stderr >&2; Exit 1; }
+cat stderr >&2
+grep 'cannot find file' stderr && Exit 1
+ls -l . sub sub/subsub # useful for debugging
+cat cscope.files # must exist
+test -f cscope.out
+test -s cscope.out # must be non-empty
+test ! -f sub/cscope.files
+test ! -f sub/cscope.out
+test -f sub/subsub/gen.c
+$FGREP '/*GeNeRaTeD*/' sub/subsub/gen.c
+
+LC_ALL=C sort cscope.files >fileslist-got
+
+cat fileslist-exp
+cat fileslist-got
+diff fileslist-exp fileslist-got
+
+# Check that making 'cscope' twice do not inappropriately
+# append extra text to 'cscope.files'.
+cp -f cscope.files prevlist
+$MAKE cscope
+diff prevlist cscope.files
+
+$MAKE clean
+test -f cscope.files
+
+$MAKE distclean
+ls > lst
+$FGREP 'cscope' lst && Exit 1
+
+:
diff --git a/tests/cscope8.test b/tests/cscope8.test
new file mode 100755
index 0000000..2e79893
--- /dev/null
+++ b/tests/cscope8.test
@@ -0,0 +1,206 @@
+#! /bin/sh
+# Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Bigger stress test for cscope functionality.
+
+required='gcc g++ gcj gfortran flex bison emacs cscope'
+. ./defs || Exit 1
+
+set -e
+
+EMACS=emacs; export EMACS # so that it will be picked up by configure
+
+check_cscope()
+{
+ $MAKE cscope 2>stderr || { cat stderr >&2; Exit 1; }
+ cat stderr >&2
+ grep 'cannot find file' stderr && Exit 1
+
+ cat cscope.files # must exist
+ test ! -f sub/cscope.files
+ test -s cscope.out # must be non-empty
+ test ! -f sub/cscope.out
+
+ #FIXME: make stricter!
+ $EGREP '(^|/)foo1\.c$' cscope.files
+ $EGREP '(^|/)foo2\.cc$' cscope.files
+ $EGREP '(^|/)foo3\.cpp$' cscope.files
+ $EGREP '(^|/)foo4\.cxx$' cscope.files
+ $EGREP '(^|/)foo5\.c\+\+$' cscope.files
+ $EGREP '(^|/)foo6\.f$' cscope.files
+ $EGREP '(^|/)foo7\.f90$' cscope.files
+ $EGREP '(^|/)foo8\.l$' cscope.files
+ $EGREP '(^|/)foo9\.y$' cscope.files
+ $EGREP '(^|/)sub/subsub/dist\.c$' cscope.files
+ $EGREP '(^|/)sub/subsub/gen\.c$' cscope.files
+
+ # Check that making 'cscope' twice do not inappropriately
+ # append extra text to 'cscope.files'.
+ cp -f cscope.files prevlist
+ $MAKE cscope
+ diff prevlist cscope.files
+}
+
+cat >> configure.in << 'END'
+AC_CONFIG_FILES([sub/Makefile])
+AC_PROG_CC
+AC_PROG_CXX
+AC_PROG_F77
+AC_PROG_FC
+AC_PROG_YACC
+AC_PROG_LEX
+AM_PROG_GCJ
+AM_PATH_LISPDIR
+AC_OUTPUT
+END
+
+mkdir sub sub/subsub
+
+cat >Makefile.am <<'END'
+SUBDIRS = sub
+bin_PROGRAMS = foo
+foo_SOURCES = \
+ foo1.c \
+ foo2.cc \
+ foo3.cpp \
+ foo4.cxx \
+ foo5.c++ \
+ foo6.f \
+ foo7.f90 \
+ foo8.l \
+ foo9.y
+foo_LDADD = $(LEXLIB)
+javadir = $(datadir)/java
+dist_java_JAVA = quux.java
+dist_lisp_LISP = zardoz.el
+END
+
+cat >sub/Makefile.am <<'END'
+bin_PROGRAMS = bar
+bar_SOURCES = subsub/dist.c
+nodist_bar_SOURCES = subsub/gen.c
+subsub/gen.c:
+ $(MKDIR_P) subsub
+ echo 'int generated_subsub () { return 0; }' > $@
+CLEANFILES = subsub/gen.c
+END
+
+cat > foo1.c <<'END'
+int main (void)
+{
+ return 0;
+}
+END
+
+cat > foo2.cc <<'END'
+int foo2_func (void)
+{
+ return 0;
+}
+END
+
+cat > foo3.cpp <<'END'
+int foo3_func (void)
+{
+ return 0;
+}
+END
+
+cat > foo4.cxx <<'END'
+int foo4_func (void)
+{
+ return 0;
+}
+END
+
+cat > foo5.c++ <<'END'
+int foo5_func (void)
+{
+ return 0;
+}
+END
+
+cat > foo6.f <<'END'
+ subroutine foo6
+ end
+END
+
+cat > foo7.f90 <<'END'
+ integer function foo7()
+ foo7 = 1
+ return
+ end
+END
+
+cat > foo8.l <<'END'
+%%
+"END" return EOF;
+.
+%%
+END
+
+cat > foo9.y <<'END'
+%{
+void yyerror (char *s) {}
+%}
+%token EOF
+%%
+fubar : 'f' 'o' 'o' 'b' 'a' 'r' EOF {};
+END
+
+cat > quux.java <<'END'
+class quux {}
+END
+
+: > zardoz.el
+
+cat > sub/subsub/dist.c <<'END'
+int generated_subsub();
+int main()
+{
+ return generated_subsub();
+}
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+mkdir build
+cd build
+../configure
+
+check_cscope
+
+# Try to ensure our test distribution can be built and cleaned.
+$MAKE
+$MAKE distclean
+ls > lst
+$FGREP 'cscope' lst && Exit 1
+
+# Now try with $top_srcdir being an absolute path.
+cwd=`pwd`
+"$cwd/../configure"
+
+check_cscope
+
+# Try to ensure our test distribution can be built and cleaned.
+$MAKE
+$MAKE distclean
+ls > lst
+$FGREP 'cscope' lst && Exit 1
+
+:
diff --git a/tests/cscopec.test b/tests/cscopec.test
new file mode 100755
index 0000000..eaa6ae5
--- /dev/null
+++ b/tests/cscopec.test
@@ -0,0 +1,158 @@
+#! /bin/sh
+# Copyright (C) 2010 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Test for cscope functionality with C files.
+# Please keep this in sync with the sister test 'cscopecxx.test'.
+
+required='gcc cscope'
+. ./defs || Exit 1
+
+set -e
+
+cat >> configure.in <<'END'
+AC_CONFIG_FILES([sub/Makefile])
+AC_PROG_CC
+AC_OUTPUT
+END
+
+mkdir sub sub/subsub
+
+cat > Makefile.am <<'END'
+SUBDIRS = sub
+bin_PROGRAMS = foo
+foo_SOURCES = foo.c main-alias.h
+
+## Yes, we really need to generate 'fileslist-exp' here, because some make
+## implementations (e.g. on Tru64/OSF) might even simplify noncanonical
+## paths (such as sub/../../sub/foo) that really occurs in cscope.files.
+## For more info, see the section on make issues in the Autoconf manual.
+.PHONY: sanity list1 list2 cmp
+sanity:
+ test -n '$(x_src_top)'
+ test -n '$(x_src_sub)'
+ test -n '$(x_bld_sub)'
+ test -f cscope.files
+list1: sanity
+ echo '$(x_src_top)/foo.c' > t
+ echo '$(x_src_top)/main-alias.h' >> t
+ echo '$(x_src_sub)/subsub/dist.c' >> t
+ echo '$(x_bld_sub)/gen.c' >> t
+ LC_ALL=C sort t > fileslist-exp
+ rm -f t
+list2: sanity
+ LC_ALL=C sort cscope.files > fileslist-got
+cmp: list1 list2
+ cat fileslist-exp
+ cat fileslist-got
+ diff fileslist-exp fileslist-got
+END
+
+cat > sub/Makefile.am <<'END'
+bin_PROGRAMS = bar
+bar_SOURCES = subsub/dist.c
+nodist_bar_SOURCES = gen.c
+gen.c:
+ echo 'int generated_func () { return 0; }' > $@
+CLEANFILES = gen.c
+END
+
+cat > main-alias.h <<'END'
+#define RUN int main (void)
+END
+
+cat > foo.c <<'END'
+#include "main-alias.h"
+RUN
+{
+ return 0;
+}
+END
+
+cat > sub/subsub/dist.c <<'END'
+int generated_func();
+int main ()
+{
+ return generated_func();
+}
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+ocwd=`pwd`
+
+for d in parent abs_parent current; do
+
+ case $d in
+ current)
+ ./configure
+ ;;
+ parent)
+ mkdir build
+ cd build
+ ../configure
+ ;;
+ abs_parent)
+ mkdir build2
+ cd build2
+ "$ocwd/configure"
+ ;;
+ *)
+ Exit 99 # sanity check
+ ;;
+ esac
+
+ $MAKE cscope 2>stderr || { cat stderr >&2; Exit 1; }
+ cat stderr >&2
+ grep 'cannot find file' stderr && Exit 1
+ ls -l . sub
+ cat cscope.files # must exist
+ test -f cscope.out
+ test ! -f sub/cscope.files
+ test ! -f sub/subsub/cscope.files
+
+ case $d in
+ current) x_src_top=. x_src_sub=sub x_bld_sub=sub ;;
+ parent) x_src_top=./.. x_src_sub=sub/../../sub x_bld_sub=sub ;;
+ abs_parent) x_src_top=$ocwd x_src_sub=$ocwd/sub x_bld_sub=sub ;;
+ esac
+
+ # Check that cscope.files has the expected content.
+ # Check that cscope.files has the expected content.
+ $MAKE cmp x_src_top="$x_src_top" \
+ x_src_sub="$x_src_sub" \
+ x_bld_sub="$x_bld_sub"
+
+ # Check that making 'cscope' twice do not inappropriately
+ # append extra text to 'cscope.files'.
+ cp -f cscope.files prevlist
+ $MAKE cscope
+ diff prevlist cscope.files
+
+ $MAKE clean
+ test -f cscope.files
+ test -f cscope.out
+
+ $MAKE distclean
+ ls > lst
+ $FGREP 'cscope' lst && Exit 1
+
+ cd "$ocwd"
+
+done
+
+:
diff --git a/tests/cscopecxx.test b/tests/cscopecxx.test
new file mode 100755
index 0000000..461e7c6
--- /dev/null
+++ b/tests/cscopecxx.test
@@ -0,0 +1,158 @@
+#! /bin/sh
+# Copyright (C) 2010 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Test for cscope functionality with C++ files.
+# Please keep this in sync with the sister test 'cscopec.test'.
+
+required='g++ cscope'
+. ./defs || Exit 1
+
+set -e
+
+cat >> configure.in <<'END'
+AC_CONFIG_FILES([sub/Makefile])
+AC_PROG_CXX
+AC_OUTPUT
+END
+
+mkdir sub sub/subsub
+
+cat > Makefile.am <<'END'
+SUBDIRS = sub
+bin_PROGRAMS = foo
+foo_SOURCES = foo.c++ main-alias.h++
+
+## Yes, we really need to generate 'fileslist-exp' here, because some make
+## implementations (e.g. on Tru64/OSF) might even simplify noncanonical
+## paths (such as sub/../../sub/foo) that really occurs in cscope.files.
+## For more info, see the section on make issues in the Autoconf manual.
+.PHONY: sanity list1 list2 cmp
+sanity:
+ test -n '$(x_src_top)'
+ test -n '$(x_src_sub)'
+ test -n '$(x_bld_sub)'
+ test -f cscope.files
+list1: sanity
+ echo '$(x_src_top)/foo.c++' > t
+ echo '$(x_src_top)/main-alias.h++' >> t
+ echo '$(x_src_sub)/dist.cpp' >> t
+ echo '$(x_bld_sub)/subsub/gen.cxx' >> t
+ LC_ALL=C sort t > fileslist-exp
+ rm -f t
+list2: sanity
+ LC_ALL=C sort cscope.files > fileslist-got
+cmp: list1 list2
+ cat fileslist-exp
+ cat fileslist-got
+ diff fileslist-exp fileslist-got
+END
+
+cat > sub/Makefile.am <<'END'
+bin_PROGRAMS = bar
+bar_SOURCES = dist.cpp
+nodist_bar_SOURCES = subsub/gen.cxx
+subsub/gen.cxx:
+ $(MKDIR_P) subsub
+ echo 'int generated_func () { return 0; }' > $@
+CLEANFILES = subsub/gen.c
+END
+
+cat > main-alias.h++ <<'END'
+#define RUN int main (void)
+END
+
+cat > foo.c++ <<'END'
+#include "main-alias"
+RUN
+{
+ return 0;
+}
+END
+
+cat > sub/dist.cpp <<'END'
+int generated_func(void);
+int main (void)
+{
+ return generated_func();
+}
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+ocwd=`pwd`
+
+for d in parent abs_parent current; do
+
+ case $d in
+ current)
+ ./configure
+ ;;
+ parent)
+ mkdir build
+ cd build
+ ../configure
+ ;;
+ abs_parent)
+ mkdir build2
+ cd build2
+ "$ocwd/configure"
+ ;;
+ *)
+ Exit 99 # sanity check
+ ;;
+ esac
+
+ $MAKE cscope 2>stderr || { cat stderr >&2; Exit 1; }
+ cat stderr >&2
+ grep 'cannot find file' stderr && Exit 1
+ ls -l . sub
+ cat cscope.files # must exist
+ test -f cscope.out
+ test ! -f sub/cscope.files
+ test ! -f sub/subsub/cscope.files
+
+ case $d in
+ current) x_src_top=. x_src_sub=sub x_bld_sub=sub ;;
+ parent) x_src_top=./.. x_src_sub=sub/../../sub x_bld_sub=sub ;;
+ abs_parent) x_src_top=$ocwd x_src_sub=$ocwd/sub x_bld_sub=sub ;;
+ esac
+
+ # Check that cscope.files has the expected content.
+ $MAKE cmp x_src_top="$x_src_top" \
+ x_src_sub="$x_src_sub" \
+ x_bld_sub="$x_bld_sub"
+
+ # Check that making 'cscope' twice do not inappropriately
+ # append extra text to 'cscope.files'.
+ cp -f cscope.files prevlist
+ $MAKE cscope
+ diff prevlist cscope.files
+
+ $MAKE clean
+ test -f cscope.files
+ test -f cscope.out
+
+ $MAKE distclean
+ ls > lst
+ $FGREP 'cscope' lst && Exit 1
+
+ cd "$ocwd"
+
+done
+
+:
--
1.6.5