* 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 no source files. Add a proper 'FIXME' 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 | 12 ++- tests/cscope4.test | 83 ++++++++++++++++++++ tests/cscope5.test | 55 +++++++++++++ tests/cscope6.test | 149 ++++++++++++++++++++++++++++++++++++ tests/cscope7.test | 152 +++++++++++++++++++++++++++++++++++++ tests/cscope8.test | 206 ++++++++++++++++++++++++++++++++++++++++++++++++++ tests/cscopec.test | 154 +++++++++++++++++++++++++++++++++++++ tests/cscopecxx.test | 155 +++++++++++++++++++++++++++++++++++++ 13 files changed, 1067 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
From 44ab545aa80300c19f3c3ac3d26b0d1590497df6 Mon Sep 17 00:00:00 2001 From: Stefano Lattarini <stefano.lattar...@gmail.com> 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 no source files. Add a proper 'FIXME' 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 | 12 ++- tests/cscope4.test | 83 ++++++++++++++++++++ tests/cscope5.test | 55 +++++++++++++ tests/cscope6.test | 156 ++++++++++++++++++++++++++++++++++++++ tests/cscope7.test | 159 ++++++++++++++++++++++++++++++++++++++ tests/cscope8.test | 206 ++++++++++++++++++++++++++++++++++++++++++++++++++ tests/cscopec.test | 154 +++++++++++++++++++++++++++++++++++++ tests/cscopecxx.test | 155 +++++++++++++++++++++++++++++++++++++ 13 files changed, 1081 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..1e8d358 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,29 @@ +2010-06-19 Stefano Lattarini <stefano.lattar...@gmail.com> + + 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 no source files. Add a proper 'FIXME' 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 <stefano.lattar...@gmail.com> 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..8f2b84d 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,10 @@ $AUTOMAKE ./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'. Fow nor, we are +# content with ensuring that it's 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..3a40a8e --- /dev/null +++ b/tests/cscope6.test @@ -0,0 +1,156 @@ +#! /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 + +cscope=false # used below, when postprocessing Makefile.in + +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 +$AUTOMAKE --add-missing + +## We go to great lengths to avoid running configure. This is not +## for a mistaken desire of "optimization". Rather, we want to be +## able to run this test even if some (or all!) of configure-time +## requirements (various compilers, an emacs installation, etc.) +## are not present on the system. We think that this possibility +## is well worth the additional complications below. + +# Required to prevent make to try to rerun autotools and configure. +touch configure config.status +chmod a+x configure config.status + +for d in . sub; do + LC_ALL=C sed \ + -e '/^ *...@set_make@ *$/d' \ + -e '/^...@[a-za-z0-9_]*true@/d' \ + -e '/^...@[a-za-z0-9_]*false@/d' \ + -e "s|^CSCOPE *=.*|CSCOPE = $cscope|" \ + -e 's|^srcdir *=.*|srcdir = .|' \ + -e 's|^builddir *=.*|builddir = .|' \ + -e 's|^VPATH *=.*|VPATH = .|' \ + -e 's|^SHELL *=.*|SHELL = /bin/sh|' \ + -e 's|@PATH_SEPARATOR@|:|g' \ + <$d/Makefile.in >$d/Makefile.tmp + # FIXME above: we should use the $PATH_SEPARATOR found + # at configure time... +done +sed -e 's|^top_srcdir *=.*$|top_srcdir = .|' \ + -e 's|^top_builddir *=.*$|top_builddir = .|' \ + <Makefile.tmp >Makefile +sed -e 's|^top_srcdir *=.*$|top_srcdir = ..|' \ + -e 's|^top_builddir *=.*$|top_builddir = ..|' \ + <sub/Makefile.tmp >sub/Makefile +rm -f Makefile.tmp sub/Makefile.tmp + +## Go with the tests. + +$MAKE -n cscope +$MAKE 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..6f40244 --- /dev/null +++ b/tests/cscope7.test @@ -0,0 +1,159 @@ +#! /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 + +cscope=cscope # used below, when postprocessing Makefile.in + +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 +$AUTOMAKE --add-missing + +## We go to great lengths to avoid running configure. This is not +## for a mistaken desire of "optimization". Rather, we want to be +## able to run this test even if some (or all!) of configure-time +## requirements (various compilers, an emacs installation, etc.) +## are not present on the system. We think that this possibility +## is well worth the additional complications below. + +# Required to prevent make to try to rerun autotools and configure. +touch configure config.status +chmod a+x configure config.status + +for d in . sub; do + LC_ALL=C sed \ + -e '/^ *...@set_make@ *$/d' \ + -e '/^...@[a-za-z0-9_]*true@/d' \ + -e '/^...@[a-za-z0-9_]*false@/d' \ + -e "s|^CSCOPE *=.*|CSCOPE = $cscope|" \ + -e 's|^srcdir *=.*|srcdir = .|' \ + -e 's|^builddir *=.*|builddir = .|' \ + -e 's|^VPATH *=.*|VPATH = .|' \ + -e 's|^SHELL *=.*|SHELL = /bin/sh|' \ + -e 's|@PATH_SEPARATOR@|:|g' \ + <$d/Makefile.in >$d/Makefile.tmp + # FIXME above: we should use the $PATH_SEPARATOR found + # at configure time... +done +sed -e 's|^top_srcdir *=.*$|top_srcdir = .|' \ + -e 's|^top_builddir *=.*$|top_builddir = .|' \ + <Makefile.tmp >Makefile +sed -e 's|^top_srcdir *=.*$|top_srcdir = ..|' \ + -e 's|^top_builddir *=.*$|top_builddir = ..|' \ + <sub/Makefile.tmp >sub/Makefile +rm -f Makefile.tmp sub/Makefile.tmp + +## Go with the tests. + +$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..2651217 --- /dev/null +++ b/tests/cscopec.test @@ -0,0 +1,154 @@ +#! /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 +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 + + # 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..5f31a29 --- /dev/null +++ b/tests/cscopecxx.test @@ -0,0 +1,155 @@ +#! /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++ +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) + cat <<'END' +./foo.c++ +./main-alias.h++ +sub/dist.cpp +sub/subsub/gen.cxx +END + ;; + parent) + cat <<'END' +./../foo.c++ +./../main-alias.h++ +sub/../../sub/dist.cpp +sub/subsub/gen.cxx +END + ;; + abs_parent) + cat <<END +$ocwd/foo.c++ +$ocwd/main-alias.h++ +$ocwd/sub/dist.cpp +sub/subsub/gen.cxx +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 + + # 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