automake-ng
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Automake-ng] [PATCH 1/4] [ng] deptrack: increase testsuite coverage


From: Stefano Lattarini
Subject: [Automake-ng] [PATCH 1/4] [ng] deptrack: increase testsuite coverage
Date: Thu, 26 Jan 2012 14:44:20 +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                    |    1 +
 tests/depcomp-recover.test           |  112 +++++++++++++++++++++
 tests/depcomp-shuffle-sub-vpath.test |   23 +++++
 tests/depcomp-shuffle-sub.test       |   23 +++++
 tests/depcomp-shuffle-vpath.test     |   23 +++++
 tests/depcomp-shuffle.sh             |  177 ++++++++++++++++++++++++++++++++++
 tests/depcomp-shuffle.test           |   23 +++++
 tests/gen-testsuite-part             |    5 +
 tests/list-of-tests.mk               |    5 +
 9 files changed, 392 insertions(+), 0 deletions(-)
 create mode 100755 tests/depcomp-recover.test
 create mode 100755 tests/depcomp-shuffle-sub-vpath.test
 create mode 100755 tests/depcomp-shuffle-sub.test
 create mode 100755 tests/depcomp-shuffle-vpath.test
 create mode 100755 tests/depcomp-shuffle.sh
 create mode 100755 tests/depcomp-shuffle.test

diff --git a/tests/Makefile.am b/tests/Makefile.am
index dc16ad5..d1accee 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -37,6 +37,7 @@ TESTS = ## Will be updated later.
 XFAIL_TESTS = \
 all.test \
 cond17.test \
+depcomp-recover.test \
 gcj6.test \
 override-conditional-2.test \
 java-nobase.test \
diff --git a/tests/depcomp-recover.test b/tests/depcomp-recover.test
new file mode 100755
index 0000000..1529726
--- /dev/null
+++ b/tests/depcomp-recover.test
@@ -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
index 0000000..06cdd3d
--- /dev/null
+++ b/tests/depcomp-shuffle-sub-vpath.test
@@ -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
index 0000000..c04eb12
--- /dev/null
+++ b/tests/depcomp-shuffle-sub.test
@@ -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
index 0000000..78ccc19
--- /dev/null
+++ b/tests/depcomp-shuffle-vpath.test
@@ -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
index 0000000..23c0832
--- /dev/null
+++ b/tests/depcomp-shuffle.sh
@@ -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
index 0000000..79c063c
--- /dev/null
+++ b/tests/depcomp-shuffle.test
@@ -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
diff --git a/tests/gen-testsuite-part b/tests/gen-testsuite-part
index 51b634f..b53b9f9 100755
--- a/tests/gen-testsuite-part
+++ b/tests/gen-testsuite-part
@@ -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/,
diff --git a/tests/list-of-tests.mk b/tests/list-of-tests.mk
index 4ee2b36..c46d1ca 100644
--- a/tests/list-of-tests.mk
+++ b/tests/list-of-tests.mk
@@ -331,6 +331,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 \
-- 
1.7.7.3




reply via email to

[Prev in Thread] Current Thread [Next in Thread]