]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
make runs complete tests
authorguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 8 Jul 1999 08:53:15 +0000 (08:53 +0000)
committerguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 8 Jul 1999 08:53:15 +0000 (08:53 +0000)
git-svn-id: https://svn.dealii.org/trunk@1555 0785d39b-7218-0410-832d-ea1e28bc413d

tests/base/Makefile
tests/base/logtest.cc
tests/base/logtest.checked [new file with mode: 0644]
tests/base/reference.cc
tests/base/reference.checked [new file with mode: 0644]
tests/base/tensor.cc
tests/base/tensor.checked [new file with mode: 0644]

index 24d4db712ec63a9289bade66f9a5d27cab68826d..fb1ed9f28f6e428d55eec6e35b06f6f0598946bf 100644 (file)
-# $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
index b2d170394825bd58e00f1343fad00b1f3da37fac..d5dd315cf27de20de292df56ce12dbf7c7645104 100644 (file)
@@ -1,8 +1,12 @@
 #include <base/logstream.h>
-
+#include <fstream>
 
 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 (file)
index 0000000..3e1bc2c
--- /dev/null
@@ -0,0 +1,7 @@
+
+DEAL::Test
+DEAL:l1::Test1
+DEAL:l1:l2::Test2Test3
+DEAL:l1:l2:l3::Test4Test5
+DEAL:l1::Test6
+DEAL::Test7
index 1ba549345e7fd809267c5bec083b6c4d349042d9..db28098f5585e413473d5ae8b17a2e256184511c 100644 (file)
@@ -1,8 +1,8 @@
 
-#include <iostream>
+#include <fstream>
 #include <base/subscriptor.h>
 #include <base/smartpointer.h>
-
+#include <base/logstream.h>
 
 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<Test>       r=&a;
@@ -40,19 +44,19 @@ main()
   SmartPointer<const Test> 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 (file)
index 0000000..ad059ec
--- /dev/null
@@ -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 <subscriptor.cc> 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
index aa3340d44599128297b68b801172d565b1142710..5abf3afaaeb7e98dcf24a56f9c4241146b0c5be9 100644 (file)
@@ -1,9 +1,15 @@
 #include <base/tensor.h>
+#include <base/logstream.h>
 #include <lac/vector.h>
-#include <iostream>
+#include <fstream>
 
 
-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<double> 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<dim; ++i)
     {
       for (unsigned int j=0; j<dim; ++j)
-       cout << t[i][j] << ' ';
-      cout << endl;
+       deallog << t[i][j] << ' ';
+      deallog << endl;
     };
-  cout << endl;
+  deallog << endl;
   
   contract (tt,t,t);
 
-  cout << "tt=" << endl;
+  deallog << "tt=" << endl;
   for (unsigned int i=0; i<dim; ++i)
     {
       for (unsigned int j=0; j<dim; ++j)
-       cout << tt[i][j] << ' ';
-      cout << endl;
+       deallog << tt[i][j] << ' ';
+      deallog << endl;
     };
-  cout << endl;
+  deallog << endl;
 
   if (tt==result)
     {
-      cout << "Result OK." << endl;
+      deallog << "Result OK." << endl;
       return 0;
     }
   else
     {
-      cout << "Result WRONG!" << endl;
+      deallog << "Result WRONG!" << endl;
       return 1;
     };
 };
diff --git a/tests/base/tensor.checked b/tests/base/tensor.checked
new file mode 100644 (file)
index 0000000..e78e6f0
--- /dev/null
@@ -0,0 +1,13 @@
+
+DEAL::unrolled: 1 2 3 3 4 5 6 7 8
+DEAL::t=
+DEAL::1 2 3 
+DEAL::3 4 5 
+DEAL::6 7 8 
+
+DEAL::tt=
+DEAL::25 31 37 
+DEAL::45 57 69 
+DEAL::75 96 117 
+
+DEAL::Result OK.

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.