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

Last change on this file since 2544 was 2544, checked in by Peter, 10 years ago

remove all libtool files to allow libtoolize to install its files

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 4.3 KB
Line 
1# @configure_input@
2# $Id: common_defs.sh.in 2544 2011-08-04 03:34:51Z peter $
3
4# Copyright (C) 2009, 2010, 2011 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# bootstrap a test project
23#
24bootstrap ()
25{
26    @MKDIR_P@ m4
27    cp @abs_top_builddir@/m4/*.m4 m4/.
28    rm -f m4/lt*.m4 m4/libtool.m4
29    autoreconf -siv && true
30    res=$?
31    case $res in
32        0)
33            :;;
34        63)
35            exit_skip;;
36        *)
37            exit $res;;
38    esac
39}
40
41# Usage: run PROG EXPECTED_EXITCODE [OPTION]...
42run ()
43{
44    test $# -ge 2 || exit_fatal
45    foo_prog=$1
46    shift
47    expected_exitcode=$1
48    shift
49    exitcode=0
50    $foo_prog ${1+"$@"} > stdout 2>stderr || exitcode=$?
51    cat stderr >&2
52    cat stdout
53    test $exitcode = $expected_exitcode || Exit 1
54}
55
56Exit () { set +x; exit $1; }
57warn_ () { echo $@ >&2; }
58exit_fail () { warn_ "$me: failed test: $@"; Exit 1; }
59exit_fatal () { warn_ "$me: hard error: $@"; Exit 99; }
60exit_skip () { warn_ "$me: skipped test: $@"; Exit 77; }
61exit_success () { echo "$me: successsful test: $@"; Exit 0; }
62
63me=$0
64
65echo "=== Running $me ==="
66
67# if required tool is not available, exit_skip
68if test -n "$required"; then
69  for tool in $required; do
70    case $tool in
71      automake)
72      echo "$me: running $tool --version"
73      ($tool --version) || exit_skip;
74      # skip test if automake older than v1.10
75      version_am=`$tool --version | head -n 1 | cut -f 2 -d ')'`
76      ver_major=`echo ${version_am} | cut -f 1 -d '.'`
77      test ${ver_major} -ge 1 || exit_skip
78      ver_minor=`echo ${version_am} | cut -f 2 -d '.'`
79      test ${ver_major} -gt 1 || test ${ver_minor} -ge 10 || exit_skip
80      ;;
81      doxygen)
82      test @have_doxygen@ = "yes" || exit_skip no doxygen
83      ;;
84      libtool)
85      # GNU libtool comes as glibtool on Mac OS
86      (echo "$me: running libtool --version" && libtool --version) || \
87      (echo "$me: running glibtool --version" && glibtool --version) || \
88       exit_skip
89      ;;
90      static)
91      if (test "x@enable_static@" = "xno"); then
92        echo static libyat disabled;
93        exit_skip;
94      fi
95      ;;
96      *)
97      echo "$me: running $tool --version"
98      ($tool --version) || exit_skip
99    esac
100  done
101fi
102 
103# some defs we need in tests
104test_dir=`echo $me.dir | sed -e 's,.*[\\/],,'`
105test_dir="testSubDir/$test_dir"
106abs_top_builddir=@abs_top_builddir@
107abs_top_srcdir=@abs_top_srcdir@
108move_if_change=@abs_top_srcdir@/build_support/move-if-change
109have_doxygen="@have_doxygen@"
110
111# user is always right
112test -z "$DOXYGEN" && DOXYGEN="@DOXYGEN@"
113
114rm -rf $test_dir
115@MKDIR_P@ --verbose $test_dir
116
117cd $test_dir
118
119if (echo "$required" | grep autoconf > /dev/null); then
120echo "creating configure.ac"
121cat > configure.ac <<EOF
122AC_INIT([hello],[1.0])
123AC_CONFIG_SRCDIR([hello.cc])
124AC_CONFIG_MACRO_DIR([m4])
125EOF
126if (echo "$required" | grep automake > /dev/null); then
127echo "AM_INIT_AUTOMAKE([foreign])" >> configure.ac
128fi
129if (echo "$required" | grep libtool > /dev/null); then
130echo AC_PROG_LIBTOOL >> configure.ac
131fi
132
133
134echo "creating Makefile.am"
135cat > Makefile.am <<EOF
136ACLOCAL_AMFLAGS = -I m4
137AM_CPPFLAGS = \$(YAT_CPPFLAGS)
138AM_CXXFLAGS = \$(YAT_CXXFLAGS)
139LDADD = \$(YAT_LDADD)
140bin_PROGRAMS = hello
141TESTS = hello
142hello_SOURCES = hello.cc
143EOF
144
145echo "creating hello.cc"
146cat > hello.cc <<EOF
147#include <yat/utility/Vector.h>
148#include <yat/utility/version.h>
149#include <algorithm>
150#include <iostream>
151#include <string>
152int main(void)
153{
154  using namespace theplu::yat;
155  if (utility::version()!="@VERSION@") {
156    std::cerr << "Incorrect version of linked libyat\n";
157    return 1;
158  }
159  // testing something with gsl
160  utility::Vector v(10);
161  v.resize(120); 
162  // testing something with boost
163  std::copy(v.begin(), v.begin()+10, v.begin()+10);
164  return 0;
165}
166EOF
167fi #end of creation of autotool files
168
169# turn on shell traces
170set -x
Note: See TracBrowser for help on using the repository browser.