# HG changeset patch
# User Alpar Juttner <alpar@cs.elte.hu>
# Date 1323598779 -3600
# Node ID cf6519daa7fae5b9e1b3e5bb4f89a7afadbf65e6
# Parent  d7ce0311ece2e6df6e14f477bee8bbd719ae1cd9
Refactoring and test instance in test logs

diff -r d7ce0311ece2 -r cf6519daa7fa tests/CMakeLists.txt
--- a/tests/CMakeLists.txt	Sun Dec 11 07:33:29 2011 +0100
+++ b/tests/CMakeLists.txt	Sun Dec 11 11:19:39 2011 +0100
@@ -1,14 +1,20 @@
 INCLUDE_DIRECTORIES(
   ${CMAKE_SOURCE_DIR}/tests
-  # ${CMAKE_BINARY_DIR}/src
+  ${CMAKE_BINARY_DIR}/tests
 )
 
 LINK_DIRECTORIES(
   # ${CMAKE_BINARY_DIR}/lemon
 )
 
+SET(DATADIR_PATH ${CMAKE_BINARY_DIR}/data)
+CONFIGURE_FILE(
+  ${CMAKE_CURRENT_SOURCE_DIR}/paths.cc.cmake
+  ${CMAKE_CURRENT_BINARY_DIR}/paths.cc
+)
+
 ADD_EXECUTABLE(circulation
-        circulation.cc main.cc
+        circulation.cc file_main.cc paths.cc
 )
 
 TARGET_LINK_LIBRARIES(circulation
diff -r d7ce0311ece2 -r cf6519daa7fa tests/benchmark_tools.h
--- a/tests/benchmark_tools.h	Sun Dec 11 07:33:29 2011 +0100
+++ b/tests/benchmark_tools.h	Sun Dec 11 11:19:39 2011 +0100
@@ -6,16 +6,29 @@
 #include<iomanip>
 #include<lemon/time_measure.h>
 
-extern const char test_name[];
+extern std::string test_name;
+extern std::string instance_name;
 
-inline void logTime(const std::string &subtest_name, const
-                    lemon::TimeStamp &time)
+extern const std::string DATADIR_PATH;
+
+
+inline void logTime(const std::string &_instance_name,
+		    const std::string &subtest_name,
+		    const lemon::TimeStamp &time)
 {
-  std::cout << "*** " << test_name << ' ' << subtest_name << ' '
-	    << std::setiosflags(std::ios::fixed) << std::setprecision(4)
+  std::cout << "*** " << test_name
+	    << ' ' << _instance_name
+	    << ' ' << subtest_name
+	    << ' ' << std::setiosflags(std::ios::fixed) << std::setprecision(4)
 	    << time.realTime() << ' '
             << time.realTime()/(time.userTime()+time.systemTime()) - 1.0
             << std::endl;
 }
 
+inline void logTime(const std::string &subtest_name,
+		    const lemon::TimeStamp &time)
+{
+  logTime(instance_name,subtest_name,time);
+}
+
 #endif
diff -r d7ce0311ece2 -r cf6519daa7fa tests/circulation.cc
--- a/tests/circulation.cc	Sun Dec 11 07:33:29 2011 +0100
+++ b/tests/circulation.cc	Sun Dec 11 11:19:39 2011 +0100
@@ -4,15 +4,14 @@
 #include <lemon/lgf_reader.h>
 #include <lemon/dimacs.h>
 #include <lemon/error.h>
+#include <istream>
 
-const char test_name[] = "circulation";
+std::string test_name = "circulation";
 
 using namespace lemon;
 
-int testMain(int argc, char **argv)
+int testMain(std::istream &input)
 {
-  if(argc!=2) exit(1);
-
   typedef int Value;
   
   SmartDigraph g;
@@ -24,14 +23,12 @@
   
   Timer ti;
   try {
-    std::ifstream input;
-    input.open(argv[1]);
     readDimacsMin(input, g, lo_cap, up_cap, cost, sup);
   } catch (FormatError& error) {
     std::cerr << error.what() << std::endl;
     return 1;
   }
-  logTime("file-read",ti);
+  logTime("fread",ti);
 
   Timer tf;
   ti.restart();
diff -r d7ce0311ece2 -r cf6519daa7fa tests/file_main.cc
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/file_main.cc	Sun Dec 11 11:19:39 2011 +0100
@@ -0,0 +1,23 @@
+#include <benchmark_tools.h>
+#include <istream>
+#include <lemon/error.h>
+
+using namespace lemon;
+
+std::string instance_name;
+
+int testMain(std::istream &input);
+
+int main(int argc, char **argv)
+{
+  if(argc!=2) exit(1);
+
+  std::ifstream input;
+  input.open((DATADIR_PATH+"/"+argv[1]).c_str());
+  
+  instance_name = argv[1];
+
+  Timer ti;
+  testMain(input);
+  logTime("total",ti);
+}
diff -r d7ce0311ece2 -r cf6519daa7fa tests/main.cc
--- a/tests/main.cc	Sun Dec 11 07:33:29 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
-#include <benchmark_tools.h>
-
-using namespace lemon;
-
-int testMain(int argc, char **argv);
-
-int main(int argc, char **argv)
-{
-  Timer ti;
-  testMain(argc, argv);
-  logTime("total",ti);
-}
diff -r d7ce0311ece2 -r cf6519daa7fa tests/paths.cc.cmake
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/paths.cc.cmake	Sun Dec 11 11:19:39 2011 +0100
@@ -0,0 +1,4 @@
+#include <benchmark_tools.h>
+#include <string>
+
+const std::string DATADIR_PATH = "@DATADIR_PATH@";