source: trunk/test/common_defs.sh.in @ 2228

Last change on this file since 2228 was 2228, checked in by Peter, 12 years ago

Using the parallel-tests driver. All tests are now by default verbose,
but 'make check' is still silent and the output is collected in log
files. Please refer to test/README or the Automake manual for more
details.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.4 KB
Line 
1# @configure_input@
2# $Id: common_defs.sh.in 2228 2010-03-25 12:28:14Z peter $
3
4# Copyright (C) 2009 Peter Johansson
5#
6# This file is part of the yat library, http://dev.thep.lu.se/yat
7#
8# The yat library is free software; you can redistribute it
9# and/or modify it under the terms of the GNU General Public License as
10# published by the Free Software Foundation; either version 3 of the
11# License, or (at your option) any later version.
12#
13# The yat library is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16# General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with yat. If not, see <http://www.gnu.org/licenses/>.
20
21
22# function copied from GNU Automake 1.10.2
23#
24# is_newest FILE FILES
25# --------------------
26# Return false if any file in FILES is newer than FILE.
27# Resolve ties in favor of FILE.
28is_newest ()
29{
30  test x`find "$@" -newer "$1"` = x
31}
32
33#
34#
35bootstrap ()
36{
37    autoreconf -siv && true
38    res=$?
39    case $res in
40  0)
41      :;;
42  63)
43      exit 77;;
44  *)
45      exit $res;;
46    esac
47}
48
49
50me=$0
51
52echo "=== Running $me ==="
53
54# if required tool is not available, exit 77 to skip test
55if test -n "$required"; then
56  for tool in $required; do
57    case $tool in
58      libtool)
59      # GNU libtool comes as glibtool on Mac OS
60      (echo "$me: running libtool --version" && libtool --version) || \
61      (echo "$me: running glibtool --version" && glibtool --version) || exit 77
62      ;;
63      *.m4)
64      : # do nothing see below
65      ;;
66      *)
67      echo "$me: running $tool --version"
68      ($tool --version) || exit 77
69    esac
70  done
71fi
72 
73# some defs we need in tests
74test_dir=`echo $me.dir | sed -e 's,.*[\\/],,'`
75test_dir="testSubDir/$test_dir"
76abs_top_builddir=@abs_top_builddir@
77abs_top_srcdir=@abs_top_srcdir@
78move_if_change=@abs_top_srcdir@/build_support/move-if-change
79
80rm -rf $test_dir
81@MKDIR_P@ --verbose $test_dir
82
83cd $test_dir
84
85if (echo "$required" | grep autoconf > /dev/null); then
86echo "creating configure.ac"
87cat > configure.ac <<EOF
88AC_INIT([hello],[1.0])
89AC_CONFIG_SRCDIR([hello.cc])
90AM_INIT_AUTOMAKE([foreign])
91AC_CONFIG_MACRO_DIR([m4])
92AC_LANG(C++)
93AC_PROG_CXXCPP
94AC_PROG_CXX
95EOF
96if (echo "$required" | grep libtool > /dev/null); then
97echo AC_PROG_LIBTOOL >> configure.ac
98fi
99
100
101echo "creating Makefile.am"
102cat > Makefile.am <<EOF
103ACLOCAL_AMFLAGS = -I m4
104# dependency to rerun configure
105CONFIG_STATUS_DEPENDENCIES = $abs_top_builddir/build_support/yat-config
106AM_CPPFLAGS = \$(YAT_CPPFLAGS)
107AM_CXXFLAGS = \$(YAT_CXXFLAGS)
108LDADD = \$(YAT_LDADD)
109bin_PROGRAMS = hello
110TESTS = hello
111hello_SOURCES = hello.cc
112EOF
113
114echo "creating hello.cc"
115cat > hello.cc <<EOF
116#include <yat/utility/Vector.h>
117#include <yat/utility/version.h>
118#include <algorithm>
119#include <iostream>
120#include <string>
121int main(void)
122{
123  using namespace theplu::yat;
124  if (utility::version()!="@VERSION@") {
125    std::cerr << "Incorrect version of linked libyat\n";
126    return 1;
127  }
128  // testing something with gsl
129  utility::Vector v(10);
130  v.resize(120); 
131  // testing something with boost
132  std::copy(v.begin(), v.begin()+10, v.begin()+10);
133  return 0;
134}
135EOF
136fi #end of creation of autotool files
137
138if test -n "$required"; then
139  for tool in $required; do
140    case $tool in
141      *.m4)
142      @MKDIR_P@ --verbose m4
143      echo "copying $tool"
144      cp @abs_top_srcdir@/m4/$tool m4/$tool
145      ;;
146      *)
147      :
148    esac
149  done
150fi
151 
152# turn on shell traces when in verbose mode
153set -x
Note: See TracBrowser for help on using the repository browser.