Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Rocstar Namespace Reference

Namespaces

 Rocin
 
 TestFixture
 Namespace for storing simple test utility fixtures.
 

Classes

class  TestingObject
 Project-specific testing object. More...
 
class  TestComLine
 ComLineObject for Rocstar testing command-line interface. More...
 

Typedefs

typedef IRAD::Util::TestResults TestResults
 Project-specific test results type. More...
 
typedef
IRAD::Comm::CommunicatorObject 
CommType
 Convenience typedef for CommunicatorObject. More...
 

Functions

int ParallelTest (int argc, char *argv[])
 Drives the Rocstar::TestObject. More...
 
int Test (int argc, char *argv[])
 Drives the Rocstar::TestObject. More...
 

Typedef Documentation

typedef IRAD::Comm::CommunicatorObject CommType

Convenience typedef for CommunicatorObject.

Definition at line 20 of file ParallelTestRocstar.C.

typedef IRAD::Util::TestResults TestResults

Project-specific test results type.

Test results types can be custom implemented by the project developer. The requirement is that they produce the proper test results output when used with outstreams.

Definition at line 41 of file RocstarTest.H.

Function Documentation

int Rocstar::ParallelTest ( int  argc,
char *  argv[] 
)

Drives the Rocstar::TestObject.

Parameters
argcnumber of string command line tokens
argvstring command line tokens
Returns
0 if successful, 1 otherwise

Drives the Rocstar::TestObject, which should encapsulate all the tests for the Rocstar namespace (and thus the project).

Command line documentation:

      rocstar_test [-h] [-v [level] -o <filename> -l <filename> -n <TestName> ] 

      -h,--help
         Print out long version of help and exit.

      -v,--verblevel [level]
         Set the verbosity level. (default = 0)

      -o,--output <filename>
         Set the output file to <filename>. (default = stdout)

      -l,--list <filename>
         Set the list file name to <filename>. (no default). The list file should be a text file with one test name per line.

      -n,--name <TestName>
         Run test by name. (no default)

Definition at line 50 of file ParallelTestRocstar.C.

References TestComLine::Initialize(), rank, and test().

Referenced by main().

51  {
52 
53  // The default verbosity is 0
54  int verblevel = 0;
55 
56  // This sets everything up with MPI
57  Rocstar::CommType communicator(&argc,&argv);
58  int rank = communicator.Rank();
59  int nproc = communicator.Size();
60  bool do_stdout = !rank;
61 
62  // This line creates the Rocstar::TestComLine object and passes in
63  // the command line arguments as a (const char **).
64  TestComLine comline((const char **)(argv));
65  // The call to comline.Initialize() reads the command line arguments
66  // from the array passed in the previous line.
67  comline.Initialize();
68 
69 
70  // The ProcessOptions() call does detailed examination of the command
71  // line arguments to check for user errors or other problems. This call
72  // will return non-zero if there were errors on the commandline.
73  int clerr = comline.ProcessOptions();
74  // Check if the user just wanted to get the help and exit
75  if(!comline.GetOption("help").empty()){
76  // Print out the "long usage" (i.e. help) message to stdout
77  if(do_stdout){
78  std::cout << comline.LongUsage() << std::endl;
79  if(verblevel > 1)
80  std::cout << "Rocstar::ParallelTest: Exiting test function (success)"
81  << std::endl;
82  }
83  communicator.SetExit(1);
84  }
85  if(communicator.Check())
86  return(0);
87  if(clerr){
88  if(do_stdout){
89  std::cout << comline.ErrorReport() << std::endl
90  << std::endl << comline.ShortUsage() << std::endl;
91  if(verblevel > 2)
92  std::cout << "Rocstar::ParallelTest: Exiting test function (fail)" << std::endl;
93  }
94  communicator.SetExit(1);
95  }
96  if(communicator.Check())
97  return(1);
98 
99  // These outstreams allow the output to file to be set up and separated
100  // from the stdout.
101  std::ofstream Ouf;
102  std::ostream *Out = NULL;
103  if(do_stdout)
104  Out = &std::cout;
105 
106  // The next few lines populate some strings based on the
107  // users input from the commandline.
108  std::string OutFileName(comline.GetOption("output"));
109  std::string TestName(comline.GetOption("name"));
110  std::string ListName(comline.GetOption("list"));
111  std::string sverb(comline.GetOption("verblevel"));
112 
113  // The following block parses and sets the verbosity level
114  if(!sverb.empty()){
115  verblevel = 1;
116  if(sverb != ".true."){
117  std::istringstream Istr(sverb);
118  Istr >> verblevel;
119  if(verblevel < 0)
120  verblevel = 1;
121  }
122  }
123 
124  // This block sets up the output file if the user specified one
125  if(!OutFileName.empty()){
126  if(Out){
127  Ouf.open(OutFileName.c_str());
128  if(!Ouf){
129  std::cout << "Rocstar::ParallelTest> Error: Could not open output file, "
130  << OutFileName << " for test output. Exiting (fail)." << std::endl;
131  communicator.SetExit(1);
132  }
133  Out = &Ouf;
134  }
135  if(communicator.Check())
136  return(1);
137  }
138 
139  if(verblevel > 1 && Out)
140  *Out << "Rocstar::ParallelTest: Entering test function" << std::endl;
141 
142  // Make an instance of the Rocstar testing object, Rocstar::ParallelTestingObject
143  Rocstar::ParallelTestingObject<Rocstar::CommType,Rocstar::TestResults> test(communicator);
144  // Make an instance of the Rocstar results object, Rocstar::TestResults
145  Rocstar::TestResults results;
146 
147  // If the user specified a name, then run only the named test
148  if(!TestName.empty()){
149  // This call runs a test by name
150  test.RunTest(TestName,results);
151  }
152  // Otherwise, if the user specified a list, then read the list and
153  // run the listed tests.
154  else if(!ListName.empty()){
155  std::ifstream ListInf;
156  ListInf.open(ListName.c_str());
157  if(!ListInf){
158  if(Out)
159  *Out << "Rocstar::ParallelTest> Error: Could not open list of tests in file "
160  << ListName << ". Exiting (fail)." << std::endl;
161  communicator.SetExit(1);
162  }
163  if(communicator.Check())
164  return(1);
165  std::string testname;
166  while(std::getline(ListInf,testname))
167  test.RunTest(testname,results);
168  ListInf.close();
169  }
170  else {
171  // This call runs all the tests for the Rocstar namespace.
172  test.Process(results);
173  }
174  if(Out)
175  *Out << results << std::endl;
176 
177  if(Out && Ouf)
178  Ouf.close();
179 
180  if((verblevel > 1) && Out)
181  *Out << "Rocstar::ParallelTest: Exiting test function (success)" << std::endl;
182 
183  return(0);
184  }
IRAD::Comm::CommunicatorObject CommType
Convenience typedef for CommunicatorObject.
void test(void)
Definition: flotsam.C:99
ComLineObject for testing app.
Definition: Test.C:12
static int rank
Definition: advectest.C:66
IRAD::Util::TestResults TestResults
Project-specific test results type.
Definition: RocstarTest.H:41

Here is the call graph for this function:

Here is the caller graph for this function:

int Rocstar::Test ( int  argc,
char *  argv[] 
)

Drives the Rocstar::TestObject.

Parameters
argcnumber of string command line tokens
argvstring command line tokens
Returns
0 if successful, 1 otherwise

Drives the Rocstar::TestObject, which should encapsulate all the tests for the Rocstar namespace (and thus the project).

Command line documentation:

      rocstar_test [-h] [-v [level] -o <filename> -l <filename> -n <TestName> ] 

      -h,--help
         Print out long version of help and exit.

      -v,--verblevel [level]
         Set the verbosity level. (default = 0)

      -o,--output <filename>
         Set the output file to <filename>. (default = stdout)

      -l,--list <filename>
         Set the list file name to <filename>. (no default). The list file should be a text file with one test name per line.

      -n,--name <TestName>
         Run test by name. (no default)

Definition at line 45 of file TestRocstar.C.

References TestComLine::Initialize(), TestingObject< ResultsType >::Process(), TestingObject< ResultsType >::RunTest(), and test().

Referenced by main().

46  {
47 
48  // The default verbosity is 0
49  int verblevel = 0;
50 
51  // This line creates the Rocstar::TestComLine object and passes in
52  // the command line arguments as a (const char **).
53  TestComLine comline((const char **)(argv));
54  // The call to comline.Initialize() reads the command line arguments
55  // from the array passed in the previous line.
56  comline.Initialize();
57  // The ProcessOptions() call does detailed examination of the command
58  // line arguments to check for user errors or other problems. This call
59  // will return non-zero if there were errors on the commandline.
60  int clerr = comline.ProcessOptions();
61  // Check if the user just wanted to get the help and exit
62  if(!comline.GetOption("help").empty()){
63  // Print out the "long usage" (i.e. help) message to stdout
64  std::cout << comline.LongUsage() << std::endl;
65  if(verblevel > 2)
66  std::cout << "Rocstar::Test: Exiting test function (success)" << std::endl;
67  return(0);
68  }
69  if(clerr){
70  std::cout << comline.ErrorReport() << std::endl
71  << std::endl << comline.ShortUsage() << std::endl;
72  if(verblevel > 2)
73  std::cout << "Rocstar::Test: Exiting test function (fail)" << std::endl;
74  return(1);
75  }
76  // These outstreams allow the output to file to be set up and separated
77  // from the stdout.
78  std::ofstream Ouf;
79  std::ostream *Out = &std::cout;
80 
81  // The next few lines populate some strings based on the
82  // users input from the commandline.
83  std::string OutFileName(comline.GetOption("output"));
84  std::string TestName(comline.GetOption("name"));
85  std::string ListName(comline.GetOption("list"));
86  std::string sverb(comline.GetOption("verblevel"));
87 
88  // The following block parses and sets the verbosity level
89  if(!sverb.empty()){
90  verblevel = 1;
91  if(sverb != ".true."){
92  std::istringstream Istr(sverb);
93  Istr >> verblevel;
94  if(verblevel < 0)
95  verblevel = 1;
96  }
97  }
98 
99  // This block sets up the output file if the user specified one
100  if(!OutFileName.empty()){
101  Ouf.open(OutFileName.c_str());
102  if(!Ouf){
103  std::cout << "Rocstar::Test> Error: Could not open output file, "
104  << OutFileName << " for test output. Exiting (fail)." << std::endl;
105  return(1);
106  }
107  Out = &Ouf;
108  }
109 
110  if(verblevel > 2)
111  std::cout << "Rocstar::Test: Entering test function" << std::endl;
112 
113  // Make an instance of the Rocstar testing object, Rocstar::TestingObject
115  // Make an instance of the Rocstar results object, Rocstar::TestResults
116  Rocstar::TestResults results;
117 
118  // If the user specified a name, then run only the named test
119  if(!TestName.empty()){
120  // This call runs a test by name
121  test.RunTest(TestName,results);
122  }
123  // Otherwise, if the user specified a list, then read the list and
124  // run the listed tests.
125  else if(!ListName.empty()){
126  std::ifstream ListInf;
127  ListInf.open(ListName.c_str());
128  if(!ListInf){
129  std::cout << "Rocstar::Test> Error: Could not open list of tests in file "
130  << ListName << ". Exiting (fail)." << std::endl;
131  return(1);
132  }
133  std::string testname;
134  while(std::getline(ListInf,testname))
135  test.RunTest(testname,results);
136  ListInf.close();
137  }
138  else {
139  // This call runs all the tests for the Rocstar namespace.
140  test.Process(results);
141  }
142  *Out << results << std::endl;
143 
144  if(Ouf)
145  Ouf.close();
146 
147  if(verblevel > 2)
148  *Out << "Rocstar::Test: Exiting test function (success)" << std::endl;
149 
150  return(0);
151  }
virtual void Process(ResultsType &result)
Runs all tests implemented by the Rocstar::TestingObject.
Definition: RocstarTest.H:255
Project-specific testing object.
Definition: RocstarTest.H:71
virtual void RunTest(const std::string &name, ResultsType &result)
Runs a test specified by name.
Definition: RocstarTest.H:269
void test(void)
Definition: flotsam.C:99
ComLineObject for testing app.
Definition: Test.C:12
IRAD::Util::TestResults TestResults
Project-specific test results type.
Definition: RocstarTest.H:41

Here is the call graph for this function:

Here is the caller graph for this function: