]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
[ng] deptrack: increase testsuite coverage
authorStefano Lattarini <stefano.lattarini@gmail.com>
Wed, 25 Jan 2012 21:18:04 +0000 (22:18 +0100)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Tue, 31 Jan 2012 09:36:16 +0000 (10:36 +0100)
This will be useful in the soon-to-appear refactoring to the code
supporting automatic dependency tracking.

* tests/depcomp-recover.test: New test, still xfailing.
* tests/Makefile.am (XFAIL_TESTS): Add it.
* tests/depcomp-shuffle.sh: New helper script, sourced by ...
* tests/depcomp-shuffle-so.test, tests/depcomp-shuffle-vpath.test,
* tests/depcomp-shuffle.test, tests/depcomp-shuffle-so-vpath.test:
... these new tests.
* tests/list-of-tests.mk: Add all the new tests.
* tests/gen-testsuite-part ($deps_extractor[depcomp_shuffle]): Also
compute dependencies for the new tests.

tests/Makefile.am
tests/depcomp-recover.test [new file with mode: 0755]
tests/depcomp-shuffle-sub-vpath.test [new file with mode: 0755]
tests/depcomp-shuffle-sub.test [new file with mode: 0755]
tests/depcomp-shuffle-vpath.test [new file with mode: 0755]
tests/depcomp-shuffle.sh [new file with mode: 0755]
tests/depcomp-shuffle.test [new file with mode: 0755]
tests/gen-testsuite-part
tests/list-of-tests.mk

index 9381f26a9c9b7db944b9ab34a0d2b45bb10506de..1f4d4023aa410614a4514b68f6337850b6f1cd89 100644 (file)
@@ -37,6 +37,7 @@ TESTS = ## Will be updated later.
 XFAIL_TESTS = \
 all.test \
 cond17.test \
+depcomp-recover.test \
 gcj6.test \
 interp3.test \
 override-conditional-2.test \
diff --git a/tests/depcomp-recover.test b/tests/depcomp-recover.test
new file mode 100755 (executable)
index 0000000..1529726
--- /dev/null
@@ -0,0 +1,112 @@
+#! /bin/sh
+# Copyright (C) 2012 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/>.
+
+# Dependency tracking:
+#  - we can recover if any .Po file in $(DEPDIR) gets removed;
+#  - in fact, we can recover if the whole $(DEPDIR) directory gets
+#    removed.
+
+required=cc
+. ./defs || Exit 1
+
+cat >> configure.in <<'END'
+AC_PROG_CC
+AM_PROG_CC_C_O
+AC_CONFIG_FILES([sub/Makefile])
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+SUBDIRS = . sub
+noinst_PROGRAMS = foo
+foo_SOURCES = main.c foo.c foo.h
+get-depdir:
+       @echo '$(DEPDIR)'
+END
+
+cat > main.c <<'END'
+#include "foo.h"
+int main (void)
+{
+  return foo ();
+}
+END
+cat > foo.c <<'END'
+#include "foo.h"
+int foo (void)
+{
+  return 0;
+}
+END
+echo 'int foo (void);' > foo.h
+
+mkdir sub sub/src
+cat > sub/Makefile.am <<'END'
+AUTOMAKE_OPTIONS = subdir-objects
+noinst_PROGRAMS = foo
+foo_SOURCES = src/main.c src/foo.c src/foo.h
+END
+cp main.c foo.c foo.h sub/src
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+for vpath in : false; do
+
+  if $vpath; then
+    srcdir=..
+    mkdir build
+    cd build
+  else
+    srcdir=.
+  fi
+
+  $srcdir/configure --enable-dependency-tracking
+  $MAKE
+  depdir=`$MAKE -s --no-print-directory get-depdir` \
+    && test -n "$depdir" \
+    && test -d $depdir \
+    && test -d sub/src/$depdir \
+    || fatal_ "cannot find the depdir"
+
+  for remove_stuff in \
+    "rm -f $depdir/main.Po" \
+    "rm -f sub/src/$depdir/foo.Po" \
+    "rm -rf $depdir" \
+    "rm -rf $depdir sub/src/$depdir" \
+  ; do
+    $remove_stuff
+    # We can still use make and order a build, even if we have probably
+    # lost the dependency information registered in removed the .Po files.
+    # TODO: maybe we should detect such a situation and force a clean
+    # TODO: rebuild?
+    $MAKE
+    # But if we force a rebuild by hand by cleaning out the existing
+    # objects, everything works out as expected.
+    $MAKE clean
+    $MAKE
+    test -f $depdir/main.Po
+    test -f $depdir/foo.Po
+    test -f sub/src/$depdir/main.Po
+    test -f sub/src/$depdir/foo.Po
+  done
+
+  cd $srcdir
+
+done
+
+:
diff --git a/tests/depcomp-shuffle-sub-vpath.test b/tests/depcomp-shuffle-sub-vpath.test
new file mode 100755 (executable)
index 0000000..06cdd3d
--- /dev/null
@@ -0,0 +1,23 @@
+#! /bin/sh
+# Copyright (C) 2012 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/>.
+
+# Dependency tracking in the face of added/removed/renamed files.
+#  - VPATH build
+#  - use of subdir-objects
+
+. ./defs-static || exit '99'
+xdir='sub' vpath='yes'
+. $testsrcdir/depcomp-shuffle.sh
diff --git a/tests/depcomp-shuffle-sub.test b/tests/depcomp-shuffle-sub.test
new file mode 100755 (executable)
index 0000000..c04eb12
--- /dev/null
@@ -0,0 +1,23 @@
+#! /bin/sh
+# Copyright (C) 2012 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/>.
+
+# Dependency tracking in the face of added/removed/renamed files.
+#  - in-tree build
+#  - use of subdir-objects
+
+. ./defs-static || exit '99'
+xdir='sub' vpath='no'
+. $testsrcdir/depcomp-shuffle.sh
diff --git a/tests/depcomp-shuffle-vpath.test b/tests/depcomp-shuffle-vpath.test
new file mode 100755 (executable)
index 0000000..78ccc19
--- /dev/null
@@ -0,0 +1,23 @@
+#! /bin/sh
+# Copyright (C) 2012 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/>.
+
+# Dependency tracking in the face of added/removed/renamed files.
+#  - VPATH build
+#  - no use of subdir-objects
+
+. ./defs-static || exit '99'
+xdir='' vpath='yes'
+. $testsrcdir/depcomp-shuffle.sh
diff --git a/tests/depcomp-shuffle.sh b/tests/depcomp-shuffle.sh
new file mode 100755 (executable)
index 0000000..23c0832
--- /dev/null
@@ -0,0 +1,177 @@
+#! /bin/sh
+# Copyright (C) 2012 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/>.
+
+# Dependency tracking in the face of added/removed/renamed files.
+# This is meant to be sourced by other the tests, after they've
+# set the variables '$xdir' and '$vpath' appropriately.
+
+required=cc
+. ./defs || Exit 1
+
+test x${xdir+"set"} = x"set" || fatal_ "\$xdir is unset"
+test x${vpath+"set"} = x"set" || fatal_ "\$vpath is unset"
+
+if test $vpath = no; then
+  srcdir=.
+elif test $vpath = yes; then
+  srcdir=..
+else
+  fatal_ "invalid value for \$vpath: '$vpath'"
+fi
+
+if test -z "$xdir"; then
+  thedir=$srcdir
+else
+  thedir=$srcdir/$xdir
+  xdir=$xdir/
+fi
+
+
+finalize_edit ()
+{
+  diff "$1" t && Exit 1
+  mv -f t "$2"
+}
+
+func_subst ()
+{
+  subst=$1; shift
+  for file
+  do
+    sed "$subst" "$file" > t
+    finalize_edit "$subst" "$file"
+  done
+}
+
+prepend ()
+{
+  cat "$1" "$2" > t
+  finalize_edit "$@"
+}
+
+if cross_compiling; then
+  grep_prog_out () { :; }
+else
+  grep_prog_out () { ./prg && ./prg | grep "$1" || Exit 1; }
+fi
+
+echo AC_PROG_CC                         >> configure.in
+echo AM_PROG_AR                         >> configure.in
+echo AC_PROG_RANLIB                     >> configure.in
+test -z "$xdir" || echo AM_PROG_CC_C_O  >> configure.in
+echo AC_OUTPUT                          >> configure.in
+
+if test -n "$xdir"; then
+  echo AUTOMAKE_OPTIONS = subdir-objects > Makefile.am
+fi
+cat >> Makefile.am <<END
+noinst_PROGRAMS = prg
+noinst_LIBRARIES = liber.a
+prg_SOURCES = ${xdir}main.c
+liber_a_SOURCES = ${xdir}niam.c
+get-exeext:
+       @echo \$(EXEEXT)
+END
+
+cat configure.in # For debugging.
+cat Makefile.am  # Likewise.
+
+test -z "$xdir" || mkdir "$xdir"
+
+echo '#define THE_STRING "foofoofoo"' > ${xdir}foo.h
+
+cat > ${xdir}main.c << 'END'
+#include "foo.h"
+#include <stdio.h>
+int main (void)
+{
+   printf ("%s\n", THE_STRING);
+   return 0;
+}
+END
+
+sed 's/main/niam/' ${xdir}main.c > ${xdir}niam.c
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+test $vpath = no || { mkdir build && cd build; } || Exit 99
+
+$srcdir/configure --enable-dependency-tracking
+$MAKE
+grep_prog_out foofoofoo # Sanity check.
+
+EXEEXT=`$MAKE -s --no-print-directory get-exeext` \
+  || fatal_ "cannot get \$EXEEXT"
+
+# Modify an header file.
+$sleep
+echo '#define THE_STRING "oofoofoof"' > $thedir/foo.h
+$MAKE
+is_newest prg$EXEEXT $thedir/foo.h
+is_newest liber.a $thedir/foo.h
+grep_prog_out oofoofoof
+
+# Rename an header file.
+$sleep
+mv $thedir/foo.h $thedir/foo2.h
+func_subst 's|foo\.h|foo2.h|' $thedir/main.c $thedir/niam.c
+$MAKE
+is_newest prg$EXEEXT $thedir/main.c
+is_newest liber.a $thedir/niam.c
+grep_prog_out oofoofoof
+
+# Add an header file, modify another one.
+$sleep
+mv $thedir/foo2.h $thedir/bar.h
+echo '#include "bar.h"' > $thedir/foo2.h
+$MAKE
+grep_prog_out oofoofoof
+is_newest prg$EXEEXT $thedir/foo2.h
+is_newest liber.a $thedir/foo2.h
+
+# Remove an header file, modify another one.
+$sleep
+echo '#define THE_STRING "bazbazbaz"' > $thedir/foo2.h
+rm -f $thedir/bar.h
+$MAKE
+is_newest prg$EXEEXT $thedir/foo2.h
+is_newest liber.a $thedir/foo2.h
+grep_prog_out bazbazbaz
+
+# Add two header files, rename another file.
+$sleep
+echo '#define S_ONE "zar"' > $thedir/1.h
+echo '#define S_TWO "doz"' > $thedir/2.h
+cat > $thedir/baz.h <<'END'
+#include "1.h"
+#include "2.h"
+#define THE_STRING S_ONE S_TWO
+END
+func_subst 's|foo2\.h|baz.h|' $thedir/main.c $thedir/niam.c
+rm -f $thedir/foo2.h
+$MAKE
+is_newest prg$EXEEXT $thedir/*.[ch]
+is_newest liber.a $thedir/*.[ch]
+grep_prog_out zardoz
+
+# Check the distribution.
+$sleep
+echo prg_SOURCES += ${xdir}baz.h ${xdir}1.h ${xdir}2.h >> $srcdir/Makefile.am
+$MAKE distcheck
+
+:
diff --git a/tests/depcomp-shuffle.test b/tests/depcomp-shuffle.test
new file mode 100755 (executable)
index 0000000..79c063c
--- /dev/null
@@ -0,0 +1,23 @@
+#! /bin/sh
+# Copyright (C) 2012 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/>.
+
+# Dependency tracking in the face of added/removed/renamed files.
+#  - in-tree build
+#  - no use of subdir-objects
+
+. ./defs-static || exit '99'
+xdir='' vpath='no'
+. $testsrcdir/depcomp-shuffle.sh
index 51b634fe9d7fc9fa3cdd95e86981fe51280f57fd..b53b9f97aebacbc10aab08569259239d2e6dd430 100755 (executable)
@@ -152,6 +152,11 @@ my %deps_extractor =
         line_matcher => qr/\btrivial-test-driver\b/,
         dist_prereqs => "trivial-test-driver",
       },
+    depcomp_shuffle =>
+      {
+        line_matcher => qr/\bdepcomp-shuffle\.sh\b/,
+        dist_prereqs => "depcomp-shuffle.sh",
+      },
     check_testsuite_summary =>
       {
         line_matcher => qr/\btestsuite-summary-checks\.sh\b/,
index ea04a102111a15f67d36cf322a4ad946217ff588..aa372138d9e8bd23983ac665aa046d54a93dff43 100644 (file)
@@ -329,6 +329,11 @@ depcomp6.test \
 depcomp7.test \
 depcomp8a.test \
 depcomp8b.test \
+depcomp-recover.test \
+depcomp-shuffle.test \
+depcomp-shuffle-vpath.test \
+depcomp-shuffle-sub.test \
+depcomp-shuffle-sub-vpath.test \
 depdist.test \
 depend.test \
 depend2.test \