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

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

Required .m4 files no longer need to be set in variable
'required'. The files are not copied manually anymore but we let
aclocal do the job. Modified tests to reflect this change.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.1 KB
Line 
1# @configure_input@
2# $Id: common_defs.sh.in 2240 2010-04-11 15:06:16Z 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    @MKDIR_P@ m4
38    autoreconf -siv && true
39    res=$?
40    case $res in
41        0)
42            :;;
43        63)
44            exit 77;;
45        *)
46            exit $res;;
47    esac
48}
49
50
51me=$0
52
53echo "=== Running $me ==="
54
55# if required tool is not available, exit 77 to skip test
56if test -n "$required"; then
57  for tool in $required; do
58    case $tool in
59      libtool)
60      # GNU libtool comes as glibtool on Mac OS
61      (echo "$me: running libtool --version" && libtool --version) || \
62      (echo "$me: running glibtool --version" && glibtool --version) || exit 77
63      ;;
64      *)
65      echo "$me: running $tool --version"
66      ($tool --version) || exit 77
67    esac
68  done
69fi
70 
71# some defs we need in tests
72test_dir=`echo $me.dir | sed -e 's,.*[\\/],,'`
73test_dir="testSubDir/$test_dir"
74abs_top_builddir=@abs_top_builddir@
75abs_top_srcdir=@abs_top_srcdir@
76move_if_change=@abs_top_srcdir@/build_support/move-if-change
77
78rm -rf $test_dir
79@MKDIR_P@ --verbose $test_dir
80
81cd $test_dir
82
83if (echo "$required" | grep autoconf > /dev/null); then
84echo "creating configure.ac"
85cat > configure.ac <<EOF
86AC_INIT([hello],[1.0])
87AC_CONFIG_SRCDIR([hello.cc])
88AM_INIT_AUTOMAKE([foreign])
89AC_CONFIG_MACRO_DIR([m4])
90AC_LANG(C++)
91AC_PROG_CXXCPP
92AC_PROG_CXX
93EOF
94if (echo "$required" | grep libtool > /dev/null); then
95echo AC_PROG_LIBTOOL >> configure.ac
96fi
97
98
99echo "creating Makefile.am"
100cat > Makefile.am <<EOF
101ACLOCAL_AMFLAGS = -I m4 -I ${abs_top_srcdir}/m4 --install
102AM_CPPFLAGS = \$(YAT_CPPFLAGS)
103AM_CXXFLAGS = \$(YAT_CXXFLAGS)
104LDADD = \$(YAT_LDADD)
105bin_PROGRAMS = hello
106TESTS = hello
107hello_SOURCES = hello.cc
108EOF
109
110echo "creating hello.cc"
111cat > hello.cc <<EOF
112#include <yat/utility/Vector.h>
113#include <yat/utility/version.h>
114#include <algorithm>
115#include <iostream>
116#include <string>
117int main(void)
118{
119  using namespace theplu::yat;
120  if (utility::version()!="@VERSION@") {
121    std::cerr << "Incorrect version of linked libyat\n";
122    return 1;
123  }
124  // testing something with gsl
125  utility::Vector v(10);
126  v.resize(120); 
127  // testing something with boost
128  std::copy(v.begin(), v.begin()+10, v.begin()+10);
129  return 0;
130}
131EOF
132fi #end of creation of autotool files
133
134# turn on shell traces when in verbose mode
135set -x
Note: See TracBrowser for help on using the repository browser.