[MOAB-dev] r3915 - MOAB/trunk/test/h5file

kraftche at cae.wisc.edu kraftche at cae.wisc.edu
Tue May 18 17:01:38 CDT 2010


Author: kraftche
Date: 2010-05-18 17:01:38 -0500 (Tue, 18 May 2010)
New Revision: 3915

Modified:
   MOAB/trunk/test/h5file/h5file_test.cpp
Log:
add command line flags to enable debug output when running test

Modified: MOAB/trunk/test/h5file/h5file_test.cpp
===================================================================
--- MOAB/trunk/test/h5file/h5file_test.cpp	2010-05-18 15:48:17 UTC (rev 3914)
+++ MOAB/trunk/test/h5file/h5file_test.cpp	2010-05-18 22:01:38 UTC (rev 3915)
@@ -23,6 +23,9 @@
 
 #define filename "h5test.h5m"
 
+#include <iostream>
+#include <sstream>
+
 using namespace moab;
 
 // Dense tag name
@@ -48,11 +51,39 @@
 
 void moab_error( const char* function );
 
-int main()
+int main(int argc, char* argv[])
 {
   ErrorCode rval;
   std::string msg;
   
+  std::string read_opt;
+  std::string write_opt("DEBUG_BINIO");
+  
+  for (int i = 1; i < argc; ++i) {
+    long val;
+    char* endptr;
+    if (argv[i][0] == '-' && (argv[i][1] == 'r' || argv[i][1] == 'w') 
+        && i+1 < argc && (val = strtol(argv[i+1],&endptr,0)) >= 0 && !*endptr)
+    {
+      std::string& s = argv[i][1] == 'r' ? read_opt : write_opt;
+      std::ostringstream str;
+      str << "DEBUG_IO=" << val;
+      if (s.empty())
+        s = str.str();
+      else {
+        s += ';';
+        s += str.str();
+      }
+      ++i;
+    }
+    else 
+    {
+      std::cerr << "Usage: " << argv[0] << " [-r <n>] [-w <n>]" << std::endl;
+      return 1;
+    }
+  }
+  


More information about the moab-dev mailing list