From 5e148fe4c2156addd26352816194af9ee8713db4 Mon Sep 17 00:00:00 2001 From: guido Date: Thu, 8 Jul 1999 08:53:15 +0000 Subject: [PATCH] make runs complete tests git-svn-id: https://svn.dealii.org/trunk@1555 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/base/Makefile | 167 +++++++++++++++++++++++++++++------ tests/base/logtest.cc | 6 +- tests/base/logtest.checked | 7 ++ tests/base/reference.cc | 28 +++--- tests/base/reference.checked | 25 ++++++ tests/base/tensor.cc | 36 ++++---- tests/base/tensor.checked | 13 +++ 7 files changed, 225 insertions(+), 57 deletions(-) create mode 100644 tests/base/logtest.checked create mode 100644 tests/base/reference.checked create mode 100644 tests/base/tensor.checked diff --git a/tests/base/Makefile b/tests/base/Makefile index 24d4db712e..fb1ed9f28f 100644 --- a/tests/base/Makefile +++ b/tests/base/Makefile @@ -1,49 +1,158 @@ -# $Id$ +############################################################ +# Directory with the DEAL distribution +############################################################ + +D = ../.. + + +############################################################ +# Include general settings for including DEAL libraries +############################################################ + +include $D/common/Make.global_options + + +############################################################ +# Set debug-mode as a default +############################################################ + +debug-mode = on + + +############################################################ +# Define library names +############################################################ + +libs = -llac -lbase +libs.g = -llac.g -lbase.g + + +############################################################ +# Select compiler flags according to debug-mode +############################################################ + +ifeq ($(debug-mode),on) +libraries = $(libs.g) +flags = $(CXXFLAGS.g) $(CXXFLAGS) +endif + +ifeq ($(debug-mode),off) +libraries = $(libs) +flags = $(CXXFLAGS.o) $(CXXFLAGS) +endif + +all: logtest.check reference.check tensor.check +exe: $(all:.check=.testcase) +output: $(all:.check=.output) +############################################################ +# Typical block for building a running program +# +# 1. provide a list of source files in ...-cc-files +# +# 2. generate the list of object files according to debug-mode +# +# 3. make executable # -# Set root directory of DEAL distribution. -# This is only one letter to make the rest MORE readable. +# 4. Explicit dependencies of object files (will be automatic soon) +# +############################################################ + +logtest-cc-files = logtest.cc + +ifeq ($(debug-mode),on) +logtest-o-files = $(logtest-cc-files:.cc=.go) +else +logtest-o-files = $(logtest-cc-files:.cc=.o) +endif + +logtest.testcase: $(logtest-o-files) $(libraries) + $(CXX) $(flags) -o $@ $^ + + +############################################################ + + +tensor-cc-files = tensor.cc + +ifeq ($(debug-mode),on) +tensor-o-files = $(tensor-cc-files:.cc=.go) +else +tensor-o-files = $(tensor-cc-files:.cc=.o) +endif -D=../.. +tensor.testcase: $(tensor-o-files) $(libraries) + $(CXX) $(flags) -o $@ $^ -include $D/deal.II/Make.global_options -%.go : %.cc - @echo ============================ Compiling with debugging information: $< - @$(CXX) $(CXXFLAGS) -c $< -o $@ -%.o : %.cc - @echo ============================ Compiling with optimization: $< - @$(CXX) $(CXXFLAGS) -c $< -o $@ +############################################################ -vpath %.a: $D/base/lib -vpath %.a: $D/lac/lib -vpath %.a: $D/deal.II/lib -test: run-reference run-logtest run-tensor +reference-cc-files = reference.cc +ifeq ($(debug-mode),on) +reference-o-files = $(reference-cc-files:.cc=.go) +else +reference-o-files = $(reference-cc-files:.cc=.o) +endif -reference: reference.go -lbase.g - $(CXX) $(CXXFLAGS) -o $@ $^ +reference.testcase: $(reference-o-files) $(libraries) + $(CXX) $(flags) -o $@ $^ -run-reference: reference - -./reference -logtest: logtest.go -lbase.g - $(CXX) $(CXXFLAGS) -o $@ $^ -run-logtest: logtest - -./logtest +############################################################ +# Continue with other targets if needed +############################################################ -tensor: tensor.go -lbase.g -llac.g - $(CXX) $(CXXFLAGS) -o $@ $^ -run-tensor: tensor - -./tensor +############################################################ +# Continue with other targets if needed +############################################################ +target1-cc-files = t1.cc t2.cc t3.cc + +ifeq ($(debug-mode),on) +target1-o-files = $(target1-cc-files:.cc=.go) +else +target1-o-files = $(target1-cc-files:.cc=.o) +endif + +target1: $(target1-o-files) $(libraries) + $(CXX) $(flags) -o $@ $^ + + +############################################################ +# Postprocessing +############################################################ + +%.output:%.testcase + $< + @perl -pi.bak -e 's/JobId.*//;s/value.*//;' $@ + @rm $@.bak + +%.check:%.output + @-diff $< $(patsubst %.output,%.checked, $<) +############################################################ +# Cleanup targets +############################################################ + clean: - -rm *.o *.go reference logtest tensor + rm -f *.o *.go *.output + +veryclean: clean + rm -f *.testcase *.inp *.gpl *.eps *.gnuplot + +############################################################ +# Automatic generation of dependencies +############################################################ +all-cc-files = $(wildcard *.cc) +Make.depend: $(all-cc-files) + @echo =====Dependecies=== Make.depend + @$(CXX) $(flags) $^ -M > $@ + @perl -pi~ -e 's/(^[^.]+)\.o:/\1.o \1.go:/;' $@ -.PHONY: test run-reference run-logtest run-tensor clean +include Make.depend diff --git a/tests/base/logtest.cc b/tests/base/logtest.cc index b2d1703948..d5dd315cf2 100644 --- a/tests/base/logtest.cc +++ b/tests/base/logtest.cc @@ -1,8 +1,12 @@ #include - +#include main() { + ofstream logfile("logtest.output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog << "Test" << endl; deallog.push("l1"); deallog << "Test1" << endl; diff --git a/tests/base/logtest.checked b/tests/base/logtest.checked new file mode 100644 index 0000000000..3e1bc2c930 --- /dev/null +++ b/tests/base/logtest.checked @@ -0,0 +1,7 @@ + +DEAL::Test +DEAL:l1::Test1 +DEAL:l1:l2::Test2Test3 +DEAL:l1:l2:l3::Test4Test5 +DEAL:l1::Test6 +DEAL::Test7 diff --git a/tests/base/reference.cc b/tests/base/reference.cc index 1ba549345e..db28098f55 100644 --- a/tests/base/reference.cc +++ b/tests/base/reference.cc @@ -1,8 +1,8 @@ -#include +#include #include #include - +#include class Test : public Subscriptor { @@ -11,19 +11,19 @@ public: Test(const char* n) : name(n) { - cout << "Construct " << name << endl; + deallog << "Construct " << name << endl; } ~Test() { - cout << "Destruct " << name << endl; + deallog << "Destruct " << name << endl; } void f() { - cout << "mutable" << endl; + deallog << "mutable" << endl; } void f() const { - cout << "const" << endl; + deallog << "const" << endl; } }; @@ -31,6 +31,10 @@ public: main() { + ofstream logfile("reference.output"); + deallog.attach(logfile); + deallog.depth_console(0); + cerr = logfile; Test a("A"); const Test b("B"); SmartPointer r=&a; @@ -40,19 +44,19 @@ main() SmartPointer u=&b; - cout << "a "; + deallog << "a "; a.f(); // should print "mutable", since #a# is not const - cout << "b "; + deallog << "b "; b.f(); // should print "const", since #b# is const - cout << "r "; + deallog << "r "; r->f(); // should print "mutable", since it points to the non-const #a# - cout << "s "; + deallog << "s "; s->f(); // should print "const", since it points to the const #b# // but we made it const - cout << "t "; + deallog << "t "; t->f(); // should print "mutable", since #b# is const, but // we casted the constness away - cout << "u "; + deallog << "u "; u->f(); // should print "const" since #b# is const // Now try if subscriptor works { diff --git a/tests/base/reference.checked b/tests/base/reference.checked new file mode 100644 index 0000000000..ad059ecfab --- /dev/null +++ b/tests/base/reference.checked @@ -0,0 +1,25 @@ + +DEAL::Construct A +DEAL::Construct B +DEAL::a mutable +DEAL::b const +DEAL::r mutable +DEAL::s const +DEAL::t mutable +DEAL::u const +DEAL::Construct C +DEAL::Construct D +DEAL::Destruct D +-------------------------------------------------------- +An error occurred in line <20> of file in function + Subscriptor::~Subscriptor() +The violated condition was: + counter == 0 +The name and call sequence of the exception was: + InUse() +Additional Information: +(none) +-------------------------------------------------------- +DEAL::Destruct C +DEAL::Destruct B +DEAL::Destruct A diff --git a/tests/base/tensor.cc b/tests/base/tensor.cc index aa3340d445..5abf3afaae 100644 --- a/tests/base/tensor.cc +++ b/tests/base/tensor.cc @@ -1,9 +1,15 @@ #include +#include #include -#include +#include -int main () { +int main () +{ + ofstream logfile("tensor.output"); + deallog.attach(logfile); + deallog.depth_console(0); + double a[3][3] = {{1, 2, 3}, {3, 4, 5}, {6, 7, 8}}; double b[3][3] = {{25,31,37}, {45,57,69}, {75,96,117}}; @@ -15,39 +21,39 @@ int main () { Vector unrolled(9); t.unroll(unrolled); - cout << "unrolled:"; + deallog << "unrolled:"; for (unsigned i=0;i<9;i++) - cout << ' ' << unrolled(i); - cout << endl; + deallog << ' ' << unrolled(i); + deallog << endl; - cout << "t=" << endl; + deallog << "t=" << endl; for (unsigned int i=0; i