diff --git a/.gitignore b/.gitignore index cf7ebb45d..c89dffc5e 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,7 @@ scripts/* configure config.log aclocal.m4 +autom4te.cache semantic.cache wiki/backups/* doc/devel/draw/*.png diff --git a/SConstruct b/SConstruct index de7a7edc2..9b4ce1dcb 100644 --- a/SConstruct +++ b/SConstruct @@ -215,7 +215,7 @@ def configurePlatform(env): if not conf.CheckLibWithHeader('dl', 'dlfcn.h', 'C'): problems.append('Functions for runtime dynamic loading not available.') - if not conf.CheckPkgConfig('nobugmt', 0.3): + if not conf.CheckPkgConfig('nobugmt', 200909.1): problems.append('Did not find NoBug [http://www.pipapo.org/pipawiki/NoBug].') else: conf.env.mergeConf('nobugmt') @@ -227,10 +227,12 @@ def configurePlatform(env): conf.env.Append(CCFLAGS = ' -pthread') if conf.CheckCHeader('execinfo.h'): - conf.env.Append(CPPFLAGS = ' -DHAS_EXECINFO_H') + conf.env.Append(CPPFLAGS = ' -DHAVE_EXECINFO_H') if conf.CheckCHeader('valgrind/valgrind.h'): - conf.env.Append(CPPFLAGS = ' -DHAS_VALGRIND_VALGIND_H') + conf.env.Append(CPPFLAGS = ' -DHAVE_VALGRIND_H') + else: + print 'Valgrind not found. The use of Valgrind is optional; building without.' if not conf.CheckCXXHeader('tr1/memory'): problems.append('We rely on the std::tr1 proposed standard extension for shared_ptr.') diff --git a/src/gui/gtk-lumiera.hpp b/src/gui/gtk-lumiera.hpp index 951b861ef..99b0a5efc 100644 --- a/src/gui/gtk-lumiera.hpp +++ b/src/gui/gtk-lumiera.hpp @@ -17,6 +17,8 @@ #include #include +#include "lib/lumitime.hpp" + #include extern "C" { diff --git a/src/include/symbol.hpp b/src/include/symbol.hpp deleted file mode 100644 index 5de94a2cd..000000000 --- a/src/include/symbol.hpp +++ /dev/null @@ -1,57 +0,0 @@ -/* - SYMBOL.hpp - symbolic constant datatype - - Copyright (C) Lumiera.org - 2008, Hermann Vosseler - - 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 of the - License, 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, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -*/ - -/** @file symbol.hpp - ** WIP placeholder definition for a planned Symbol datatype. - ** - ** @todo for the (currently just planned as of 11/08) rules based configuration - ** in the Proc-Layer a explicit Symbol datatype will probably very helpful. - ** For now we just a typedef is sufficient. A real Symbol datatype should - ** - be definable by string constant - ** - integrate smoothly with std::string - ** - provide a unique numeric index for each distinct Symbol - ** - automatically maintain a symbol table at runtime to support this - ** - provide some magic (macros) allowing to build distinct types based on symbols. - ** - ** @see configrules.hpp - ** @see query.hpp - */ - - -#ifndef LUMIERA_SYMBOL_H -#define LUMIERA_SYMBOL_H - - -#include - - -namespace lumiera { - - typedef const char * const Symbol; ///< Token or Atom with distinct identity @todo define a real Symbol class, i.e. same literal string==same pointer, - - typedef const std::string Literal; ///< inline string literal @todo improve interaction with Symbol - - - -} // namespace lumiera - -#endif diff --git a/src/lumiera/main.cpp b/src/lumiera/main.cpp index f148965d6..d800db349 100644 --- a/src/lumiera/main.cpp +++ b/src/lumiera/main.cpp @@ -2,7 +2,7 @@ main.cpp - start the Lumiera Application Copyright (C) Lumiera.org - 2007-2008, Joel Holdsworth + 2007-2009, Joel Holdsworth Christian Thaeter Hermann Vosseler diff --git a/src/pre.hpp b/src/pre.hpp index d1495d952..6b12ea67f 100644 --- a/src/pre.hpp +++ b/src/pre.hpp @@ -41,9 +41,8 @@ #include #include #include -#include +#include #include -#include #include "proc/common.hpp" diff --git a/src/proc/common.hpp b/src/proc/common.hpp index 20112cadb..31e885f1d 100644 --- a/src/proc/common.hpp +++ b/src/proc/common.hpp @@ -43,7 +43,8 @@ #include "include/nobugcfg.h" #include "common/dummy-func.hpp" -#include "include/symbol.hpp" +#include "lib/lumitime.hpp" +#include "lib/symbol.hpp" /** diff --git a/src/tool/try.cpp b/src/tool/try.cpp index 0854e5310..fb41545d7 100644 --- a/src/tool/try.cpp +++ b/src/tool/try.cpp @@ -12,26 +12,40 @@ // 5/08 - how to guard a downcasting access, so it is compiled in only if the involved types are convertible // 7/08 - combining partial specialisation and subclasses // 10/8 - abusing the STL containers to hold noncopyable values +// 6/09 - investigating how to build a mixin template providing an operator bool() #include "include/nobugcfg.h" #include + +using std::rand; using std::string; using std::cout; int -main (int argc, char* argv[]) +main (int, char**) //(int argc, char* argv[]) { NOBUG_INIT; + for (int i=0; i<10; ++i) + { + TestIt1 testrosteron (i); + + if (testrosteron) + cout << "doIt \n"; + if (!testrosteron) + cout << i << "\n"; + } + cout << "size=" << sizeof(TestIt1) <<"\n"; + + char* horror = 0; + ERROR (all, "note: %s is a horrible thing", horror); + cout << "\n.gulp.\n"; - - int * my = 0; - int oh = *my; // Congratulations... return 0; } diff --git a/tests/test.sh b/tests/test.sh index 31c92da5b..89de9ae54 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Copyright (C) Lumiera.org # 2007 - 2008, Christian Thaeter # @@ -26,18 +26,35 @@ # stop testing on the first failure export LC_ALL=C +NOBUG_LOGREGEX='^\(\*\*[0-9]*\*\* \)\?[0-9]\{10,\}: \(TRACE\|INFO\|NOTICE\|WARNING\|ERR\|TODO\|PLANNED\|FIXME\|DEPRECATED\|UNIMPLEMENTED\):' arg0="$0" srcdir="$(dirname "$arg0")" +vgsuppression_mangle='/^\(\(==\)\|\(\*\*\)[0-9]*\(==\)\|\(\*\*\)\)\|\(\(\*\*[0-9]*\*\* \)\?[0-9]\{10,\}: ECHO:\)/d;' -ulimit -S -t 2 -v 524288 +ulimit -S -t 5 -v 524288 valgrind="" if [ "$VALGRINDFLAGS" = 'DISABLE' ]; then echo "valgrind explicit disabled" else if [ "$(which valgrind)" ]; then - valgrind="$(which valgrind) --leak-check=yes --show-reachable=yes -q $VALGRINDFLAGS" - ulimit -S -t 10 + ulimit -S -t 20 + if [[ -x 'vgsuppression' ]]; then + if [[ 'vgsuppression' -nt 'vgsuppression.supp' ]]; then + echo 'generating valgrind supression file' + + if [[ -x ".libs/vgsuppression" ]]; then + ./libtool --mode=execute valgrind --leak-check=yes --show-reachable=yes -q --gen-suppressions=all vgsuppression 2>&1 \ + | sed -e "$vgsuppression_mangle" >vgsuppression.supp + else + valgrind --leak-check=yes --show-reachable=yes -q --gen-suppressions=all ./vgsuppression 2>&1 \ + | sed -e "$vgsuppression_mangle" >vgsuppression.supp + fi + fi + valgrind="$(which valgrind) --leak-check=yes --show-reachable=no --suppressions=vgsuppression.supp -q $VALGRINDFLAGS" + else + valgrind="$(which valgrind) --leak-check=yes --show-reachable=no -q $VALGRINDFLAGS" + fi else echo "no valgrind found, go without it" fi @@ -50,6 +67,7 @@ TESTCNT=0 SKIPCNT=0 FAILCNT=0 + # the old testlog if existing will be used to check for previous test states if test -f ,testlog; then mv ,testlog ,testlog.pre @@ -59,6 +77,40 @@ fi date >,testlog +function compare_regex() # rxfile plainfile +{ + local regex + local line + local miss + local lineno=1 + local regexno=1 + { + IFS='' read -u 3 -r regex || return 0 + IFS='' read -u 4 -r line || { echo "no output"; return 1; } + while true; do + if [[ $line =~ $regex ]]; then + IFS='' read -u 4 -r line || + if IFS='' read -u 3 -r regex; then + echo "premature end in output, expecting: '$regex':$regexno" + return 1 + else + return 0 + fi + : $((++lineno)) + miss=0 + else + if [[ $((++miss)) -gt 1 ]]; then + echo -e "'$line':$lineno\ndoes not match\n'$regex':$regexno" + return 1 + fi + IFS='' read -u 3 -r regex || { echo "more output than expected: '$line':$lineno"; return 1; } + : $((++regexno)) + fi + done + } 3<"$1" 4<"$2" +} + + function TEST() { name="$1" @@ -66,11 +118,15 @@ function TEST() rm -f ,send_stdin rm -f ,expect_stdout rm -f ,expect_stderr + expect_return=0 while read -r line; do cmd="${line%%:*}" - arg="${line#*: }" - expect_return=0 + arg="${line#*:}" + arg="${arg:1}" + if [[ ! "$arg" ]]; then + arg='^$' + fi case $cmd in 'in') @@ -85,6 +141,9 @@ function TEST() 'return') expect_return="$arg" ;; + '#'*|'') + : + ;; *) echo "UNKOWN TEST COMMAND '$cmd'" 1>&2 exit @@ -122,42 +181,58 @@ function TEST() echo -n >,testtmp - if ! test -x $TESTBIN; then + local CALL + if declare -F | grep $TESTBIN >&/dev/null; then + CALL= + elif test -x $TESTBIN; then + CALL="env $TESTBIN_PREFIX" + else + CALL='-' echo -n >,stdout echo "test binary '$TESTBIN' not found" >,stderr ((fails+=1)) + fi + + if test "$CALL" != '-'; then - else if test -f ,send_stdin; then - cat ,send_stdin | $valgrind $TESTBIN "$@" 2>,stderr >,stdout + $CALL $TESTBIN "$@" <,send_stdin 2>,stderr >,stdout else - $valgrind $TESTBIN "$@" 2>,stderr >,stdout + $CALL $TESTBIN "$@" 2>,stderr >,stdout fi &>/dev/null return=$? if test -f ,expect_stdout; then - if ! cmp ,expect_stdout ,stdout &>/dev/null; then + grep -v "$NOBUG_LOGREGEX" <,stdout >,tmp + if ! compare_regex ,expect_stdout ,tmp >>,cmptmp; then echo "unexpected data on stdout" >>,testtmp - grep -v ': \(TRACE\|INFO\|NOTICE\|WARNING\|ERR\):' <,stdout >,tmp - diff -ua ,expect_stdout ,tmp >>,testtmp - rm ,tmp + cat ,cmptmp >>,testtmp ((fails+=1)) fi + rm ,tmp ,cmptmp fi if test -f ,expect_stderr; then - if ! cmp ,expect_stderr ,stderr &>/dev/null; then + grep -v "$NOBUG_LOGREGEX" <,stderr >,tmp + cat ,tmp >>,testtmp + if ! compare_regex ,expect_stderr ,tmp >>,cmptmp; then echo "unexpected data on stderr" >>,testtmp - grep -v ': \(TRACE\|INFO\|NOTICE\|WARNING\|ERR\):' <,stderr >,tmp - diff -ua ,expect_stderr ,tmp >>,testtmp - rm ,tmp + cat ,cmptmp >>,testtmp ((fails+=1)) fi + rm ,tmp ,cmptmp fi - if test "$expect_return" != "$return"; then - echo "unexpected return value $return" >>,testtmp - ((fails+=1)) + if [[ "${expect_return:0:1}" = '!' ]]; then + if [[ "${expect_return#\!}" = "$return" ]]; then + echo "unexpected return value $return, expected $expect_return" >>,testtmp + ((fails+=1)) + fi + else + if [[ "${expect_return}" != "$return" ]]; then + echo "unexpected return value $return, expected $expect_return" >>,testtmp + ((fails+=1)) + fi fi fi @@ -224,7 +299,14 @@ function TESTING() { echo echo "$1" - TESTBIN=$2 + echo -e "\n#### $1" >>,testlog + + if [[ -x ".libs/$2" ]]; then + TESTBIN_PREFIX="./libtool --mode=execute $valgrind" + else + TESTBIN_PREFIX="$valgrind" + fi + TESTBIN="$2" } TESTSUITES="${TESTSUITES}${1:+${TESTSUITES:+,}$1}"