31 std::cout << comline.
LongUsage() << std::endl;
36 << std::endl << comline.
ShortUsage() << std::endl;
46 std::string OutFileName(comline.
GetOption(
"output"));
48 std::string ListName(comline.
GetOption(
"list"));
49 std::string FileName(comline.
GetOption(
"file"));
50 std::string sverb(comline.
GetOption(
"verblevel"));
51 std::string HostName(comline.
GetOption(
"hostname"));
52 std::string PlatformsName(comline.
GetOption(
"platforms"));
53 std::string SourceDirectory(comline.
GetOption(
"srcdir"));
54 std::string BinaryDirectory(comline.
GetOption(
"bindir"));
55 std::string ScriptArgument(comline.
GetOption(
"argument"));
56 bool keepFiles = !comline.
GetOption(
"keep").empty();
58 if(PlatformsName.empty() && ListName.empty() && FileName.empty()){
60 <<
"ix::RunTest> Error: One of --list or --platform or --file" 61 <<
" must be specified. Exiting (fail)." << std::endl;
64 if((!PlatformsName.empty() && !ListName.empty())||
65 (!FileName.empty() && (!PlatformsName.empty() || !ListName.empty()))){
66 std::cout << comline.
ShortUsage() << std::endl;
67 std::cout <<
"ix::RunTest> Error: Ambigous settings. --list, --platform, and" 68 <<
" --file are mutually exclusive. Exiting (fail)." << std::endl;
71 if(!HostName.empty() && PlatformsName.empty()){
72 std::cout <<
"ix::RunTest> Warning: Hostname option is meaningless without platforms file." 79 if(sverb !=
".true."){
80 std::istringstream Istr(sverb);
87 std::cout <<
"ix::RunTest> Starting up with the following environment:" << std::endl
88 <<
"ix::RunTest> OutFileName = " << OutFileName << std::endl
89 <<
"ix::RunTest> ListName = " << ListName << std::endl
90 <<
"ix::RunTest> FileName = " << FileName << std::endl
91 <<
"ix::RunTest> HostName = " << HostName << std::endl
92 <<
"ix::RunTest> PlatformsName = " << PlatformsName << std::endl
93 <<
"ix::RunTest> SourceDirectory = " << SourceDirectory << std::endl
94 <<
"ix::RunTest> BinaryDirectory = " << BinaryDirectory << std::endl;
97 bool keep_outfile =
false;
98 if(!OutFileName.empty()){
109 std::string name_stub(
"test_script.o");
111 OutFileName = name_stub;
114 if(HostName.empty()){
117 std::cout <<
"ix::RunTest> Found HostName = " << HostName << std::endl;
123 std::string BasePath;
124 if(!PlatformsName.empty()){
126 std::ifstream PlatInf;
127 std::string::size_type
x = PlatformsName.find_last_of(
"/");
128 if(x != std::string::npos)
129 BasePath.assign(PlatformsName.substr(0,x+1));
130 PlatInf.open(PlatformsName.c_str());
132 std::cout <<
"ix::RunTest> Error: Could not open platforms file, " 133 << PlatformsName <<
" for resolving platform-specific tests for " 134 << HostName <<
". Exiting (fail)." << std::endl;
138 std::string splatform;
139 std::string defaultRunningName;
140 while(std::getline(PlatInf,splatform) && ListName.empty()){
141 std::istringstream Istr(splatform);
142 std::string platform_name;
143 std::string running_name;
144 Istr >> platform_name >> running_name;
145 if(platform_name ==
"DEFAULT")
146 defaultRunningName = running_name;
147 if(HostName == platform_name){
148 ListName.assign(running_name);
149 }
else if(HostName.find(platform_name) != std::string::npos){
150 ListName.assign(running_name);
153 if(ListName.empty()){
154 std::cout <<
"ix::RunTest> Warning: Could not find a " << HostName
155 <<
"-specific configuration." << std::endl;
156 if(defaultRunningName.empty()){
157 std::cout <<
"ix::RunText> Error: No default platform, cannot continue." 161 std::cout <<
"ix::RunTest> Warning: Setting default configuration (" 162 << defaultRunningName <<
")." << std::endl;
163 ListName.assign(defaultRunningName);
169 std::vector<std::string> TestFileNames;
170 if(!ListName.empty()){
172 std::ifstream ListInf;
173 ListInf.open(ListName.c_str());
176 if(!BasePath.empty()){
177 RelName.assign(BasePath+ListName);
178 ListInf.open(RelName.c_str());
181 std::cout <<
"ix::RunTest> Error: Could not open list file, " 183 if(!RelName.empty()){
184 std::cout <<
" Tried relative path (" << RelName <<
").";
186 std::cout <<
" Exiting (fail)." << std::endl;
190 if(BasePath.empty()){
191 std::string::size_type
x = ListName.find_last_of(
"/");
192 if(x != std::string::npos)
193 BasePath.assign(ListName.substr(0,x+1));
195 std::string raw_test_name;
196 while(std::getline(ListInf,raw_test_name)){
198 std::string RelName(BasePath+raw_test_name);
200 std::cout <<
"ix::RunTest> Warning: Could not find test " 201 << raw_test_name <<
" from " << ListName <<
"." 205 TestFileNames.push_back(RelName);
209 TestFileNames.push_back(raw_test_name);
216 std::cout <<
"ix::RunTest> Error: Could not find specified test, " 217 << FileName <<
". Exiting (fail)." << std::endl;
220 TestFileNames.push_back(FileName);
225 std::vector<std::string>::iterator ti = TestFileNames.begin();
226 while(ti != TestFileNames.end()){
229 std::string TestPath(*ti++);
230 std::string TestName(TestPath);
231 std::string::size_type
x = TestName.find_last_of(
"/");
232 if(x != std::string::npos)
233 TestName = TestName.substr(x+1);
234 std::string LocalTest(
"./"+TestName);
236 std::cout <<
"ix::RunTest> Linking " << TestPath <<
" to " << LocalTest << std::endl;
239 std::cout <<
"ix::RunTest> Warning: Could not create symbolic link " 240 <<
"to " << TestPath <<
" at " << LocalTest <<
"." 244 std::cout <<
"ix::RunTest> Running " << TestName <<
"." << std::endl;
246 std::string Command(LocalTest+
" "+TmpComOut);
247 if(!SourceDirectory.empty())
248 Command = Command +
" " + SourceDirectory;
249 if(!BinaryDirectory.empty())
250 Command = Command +
" " + BinaryDirectory;
251 if(!ScriptArgument.empty())
252 Command = Command +
" " + ScriptArgument;
254 std::cout <<
"ix::RunTest> Running command: " << Command << std::endl;
256 std::string testoutline;
257 while(std::getline(TestProcess,testoutline)){
259 std::cout << testoutline << std::endl;
263 std::ifstream ComInf(TmpComOut.c_str());
265 std::cout <<
"ix::RunTest> Warning: Cannot access test results from " 266 << TestName <<
". Continuing." << std::endl;
271 Ouf.open(OutFileName.c_str(),std::ios::app);
273 std::cout <<
"ix::RunTest> Error: Cannot open outfile, " << OutFileName
274 <<
". Exiting (fail)." << std::endl;
278 while(std::getline(ComInf,comline))
279 Ouf << comline << std::endl;
286 if(err && (verblevel > 1))
287 std::cout <<
"ix::RunTest> Warning: " << err <<
" errors occurred during testing." 291 Inf.open(OutFileName.c_str());
293 std::cout <<
"ix::RunTest> Error: Could not open test output" 294 <<
". Test must have gone wrong. Exiting (fail)." 299 while(std::getline(Inf,line))
300 std::cout << line << std::endl;
310 int main(
int argc,
char *argv[])
int ProcessOptions()
Processes all command line tokens.
std::string ErrorReport()
Error reporting.
std::string GetOption(const char &s)
Get the value of an option.
int Remove(const std::string &fname)
int RunTest(int argc, char *argv[])
Runs test programs and scripts through a standard interface.
Defines MPI-specific parallel global and program classes.
ComLine object for test running utility.
void const size_t const size_t const size_t const double const double * x
std::string TempFileName(const std::string &stub)
int SymLink(const std::string &source, const std::string &target)
bool FILEEXISTS(const std::string &fname)
const std::string Hostname(bool longname=false)
int main(int argc, char *argv[])
void Initialize()
virtual function for program specific Initialization.
Unix System Tools interface.
Implements a command-line interface for runnning tests.
Implementation of stream object for Unix file descriptors.
std::string LongUsage()
Generate long usage string.
std::string ShortUsage()
Generate short usage string.