PlasCom2  1.0
XPACC Multi-physics simluation application
TestResults.C
Go to the documentation of this file.
1 #include <iostream>
7 #include <fstream>
8 #include <sstream>
9 #include <string>
10 
11 #include "primitive_utilities.H"
12 #include "TestResults.H"
13 
14 namespace ix {
15 
16  int TestResults(int argc,char *argv[])
17  {
18  bool verbose = false;
19  std::istream *Ins = &std::cin;
20  std::ifstream Inf;
21  if(argc < 2){
22  std::cout << "Usage:\n\n"
23  << argv[0] << " [name of test] <testing results file>"
24  << std::endl;
25  return(1);
26  }
27  std::string name_of_test(argv[1]);
28  std::string name_of_results_file(argv[2]);
29  if(argc > 2){
30  Inf.open(argv[2]);
31  if(!Inf){
32  std::cout << "Error: Could not open indicated results file, "
33  << argv[2] << "." << std::endl;
34  return(1);
35  }
36  Ins = &Inf;
37  }
38  if(argc > 3)
39  verbose = true;
40  std::string line;
41  if(verbose)
42  std::cout << "Searching for " << name_of_test << " in "
43  << name_of_results_file << std::endl;
44  int result = -1;
45  while(std::getline(*Ins,line)){
46 
47  std::string::size_type x = line.find("=");
48  if(x != std::string::npos){
49  std::string testname(line.substr(0,x));
50  std::string testresult(line.substr(x+1));
51  util::Trim(testname);
52  if(testname == name_of_test){
53  if(verbose)
54  std::cout << "Found " << name_of_test << ", reading result from "
55  << testresult << std::endl;
56  std::istringstream Istr(testresult);
57  Istr >> result;
58  // if(result == 1)
59  // return(0);
60  // else
61  // return(1);
62  }
63  }
64  }
65  if(result == 1)
66  return(0);
67  return(1);
68  }
69 };
70 
71 int main(int argc,char *argv[])
72 {
73  return(ix::TestResults(argc,argv));
74 }
void Trim(std::string &instr, bool preserve_newline=false)
Creates space delimited tokens in place.
int TestResults(int argc, char *argv[])
Test results utility.
Definition: TestResults.C:16
Basic utility header.
Defines MPI-specific parallel global and program classes.
void const size_t const size_t const size_t const double const double * x
Test results utility header.
int main(int argc, char *argv[])
Definition: TestResults.C:71