15 namespace OpenFoamModuleDriver{
20 typedef IRAD::Comm::CommunicatorObject
CommType;
53 int com_initialized = COM_initialized();
54 bool com_initialized_pass = (com_initialized <= 0);
56 COM_init(&argc, &argv);
57 if(com_initialized_pass)
58 com_initialized = (COM_initialized() > 0);
65 int rank = communicator.Rank();
66 int nproc = communicator.Size();
67 bool do_stdout = !rank;
80 int clerr = comline.ProcessOptions();
82 if(!comline.GetOption(
"help").empty()){
85 std::cout << comline.LongUsage() << std::endl;
87 std::cout <<
"OpenFoamModuleDriver::ParallelTest: Exiting test function (success)"
90 communicator.SetExit(1);
92 if(communicator.Check())
96 std::cout << comline.ErrorReport() << std::endl
97 << std::endl << comline.ShortUsage() << std::endl;
99 std::cout <<
"OpenFoamModuleDriver::ParallelTest: Exiting test function (fail)" << std::endl;
101 communicator.SetExit(1);
103 if(communicator.Check())
109 std::ostream *Out = NULL;
115 std::string OutFileName(comline.GetOption(
"output"));
116 std::string TestName(comline.GetOption(
"name"));
117 std::string ListName(comline.GetOption(
"list"));
118 std::string sverb(comline.GetOption(
"verblevel"));
119 std::string SourcePath(comline.GetOption(
"source"));
124 if(sverb !=
".true."){
125 std::istringstream Istr(sverb);
133 if(!OutFileName.empty()){
135 Ouf.open(OutFileName.c_str());
137 std::cout <<
"OpenFoamModuleDriver::ParallelTest> Error: Could not open output file, "
138 << OutFileName <<
" for test output. Exiting (fail)." << std::endl;
139 communicator.SetExit(1);
143 if(communicator.Check())
147 if(verblevel > 1 && Out)
148 *Out <<
"OpenFoamModuleDriver::ParallelTest: Entering test function" << std::endl;
151 OpenFoamModuleDriver::ParallelTestingObject<OpenFoamModuleDriver::CommType,OpenFoamModuleDriver::TestResults> test(communicator);
156 if(!SourcePath.empty()){
157 test.SetSourceDirPath(SourcePath);
161 if(!TestName.empty()){
163 test.RunTest(TestName,results);
167 else if(!ListName.empty()){
168 std::ifstream ListInf;
169 ListInf.open(ListName.c_str());
172 *Out <<
"OpenFoamModuleDriver::ParallelTest> Error: Could not open list of tests in file "
173 << ListName <<
". Exiting (fail)." << std::endl;
174 communicator.SetExit(1);
176 if(communicator.Check())
178 std::string testname;
179 while(std::getline(ListInf,testname))
180 test.RunTest(testname,results);
185 test.Process(results);
189 *Out << results << std::endl;
195 if(com_initialized_pass)
196 com_initialized_pass = (COM_initialized() <= 0);
198 if((verblevel > 1) && Out)
199 *Out <<
"OpenFoamModuleDriver::ParallelTest: Exiting test function (success)" << std::endl;
205 int main(
int argc,
char *argv[])
ComLineObject for OpenFoamModuleDriver testing command-line interface.
IRAD::Comm::CommunicatorObject CommType
Convenience typedef for CommunicatorObject.
IRAD::Util::TestResults TestResults
Project-specific test results type.
Testing utilities for OpenFoamModuleDriver.
int ParallelTest(int argc, char *argv[])
Drives the OpenFoamModuleDriver::TestObject.