|
Go to the documentation of this file.
27 void usage( const std::string& msg= "") {
29 std::cerr << "valfaudes: error: " << msg << std::endl;
30 std::cerr << std::endl;
33 std::cerr << "valfaudes --- run and validate testcases (" << faudes::VersionString() << ")" << std::endl;
34 std::cerr << std::endl;
35 std::cerr << "usage:" << std::endl;
36 std::cerr << " valfaudes [-v|q] [-t <tmp>] <main-in>" << std::endl;
37 std::cerr << std::endl;
38 std::cerr << "with:" << std::endl;
39 std::cerr << " <main-in> specify '.prot' or a '.flx' input" << std::endl;
40 std::cerr << std::endl;
41 std::cerr << "options:" << std::endl;
42 std::cerr << " -t <tmp> temp dir for extracting/validating flx packages" << std::endl;
43 std::cerr << std::endl;
44 std::cerr << "note: this tool is meant to facilitate the libFAUDES build process and" << std::endl;
45 std::cerr << "relies on std libFAUDES folder layout" << std::endl;
46 std::cerr << std::endl;
70 std::string exesfx( void) { return "";}
73 std::string exesfx( void) { return ".exe";}
76 std::string exesfx( void) { return "";}
81 int runfexec( const std::string& command, const std::string& arguments= "") {
82 std::string cmd=command;
85 if((cmd.at(0)!= '/') && (cmd.at(0)!= '.'))
87 if(!arguments.empty())
88 cmd += " " + arguments;
90 cmd = cmd + " > /dev/null 2>&1 ";
94 if(!arguments.empty())
95 cmd += " " + arguments;
97 cmd = cmd + " > NUL 2>&1";
100 std::cout << "valfaudes: running: \"" << cmd << "\"" << std::endl;
101 return std::system(cmd.c_str());
105 int runsexec( const std::string& command, const std::string& arguments= "") {
106 std::string cmd=command;
108 if(!arguments.empty())
109 cmd += " " + arguments;
111 cmd = cmd + " > /dev/null 2>&1 ";
113 #ifdef FAUDES_WINDOWS
115 if(!arguments.empty())
116 cmd += " " + arguments;
118 cmd = cmd + " > NUL 2>&1";
121 std::cout << "valfaudes: running: \"" << cmd << "\"" << std::endl;
122 return std::system(cmd.c_str());
126 int rundiff( const std::string& file1, const std::string& file2) {
130 cmd = cmd + " > /dev/null 2>&1 ";
131 cmd= "diff -w --context=3 --show-function-line=mark " + file1 + " " + file2;
133 #ifdef FAUDES_WINDOWS
136 cmd = cmd + " > NUL 2>&1";
139 std::cout << "valfaudes: running: \"" << cmd << "\"" << std::endl;
140 return std::system(cmd.c_str());
163 std::cout << "valfaudes: could not find luafaudes ( last try \"" << mLuaFaudes << "\""
170 int main( int argc, char *argv[]) {
173 for( int i=1; i<argc; i++) {
174 std::string option(argv[i]);
176 if((option== "-?") || (option== "--help")) {
181 if((option== "-v") || (option== "--verbose")) {
187 if((option== "-q") || (option== "--quiet")) {
193 if((option== "-t") || (option== "--temp")) {
195 usage( "cannot read temp dir (-t)");
200 if(option.c_str()[0]== '-') {
201 usage( "unknown option "+ option);
210 usage( "no more than one argument must be specified" );
215 usage( "no input file specified");
219 std::cout << "varfaudes: input file: \"" << mArgFile << "\"" << std::endl;
228 size_t seppos= mTestCase.find_last_of( '_');
229 if(seppos==std::string::npos) {
230 usage( "could not figure test type (no seperator '_' in '.prot' file)");
256 usage( "could not figure test type");
262 if(datapos==std::string::npos) {
263 usage( "could not figure working dir (path must end with 'data' [a])");
266 usage( "could not figure working dir (path must end with 'data' [b])");
269 usage( "could not figure working dir (layout mismatch)");
277 std::cout << "varfaudes:" << std::endl;
278 std::cout << " test case: \"" << mTestCase << "\"" << std::endl;
279 std::cout << " test working dir: \"" << mTestPath << "\"" << std::endl;
281 std::cout << " exeutable: \"" << mBinFile << "\"" << std::endl;
283 std::cout << " lua script: \"" << mLuaFile << "\"" << std::endl;
285 std::cout << " python script: \"" << mPyFile << "\"" << std::endl;
287 std::cout << " flx file: \"" << mFlxFile << "\"" << std::endl;
295 std::cout << "varfaudes: error: nothing we can validate" << std::endl;
302 usage( "could not figure current working dir");
306 usage( "could change to test working dir");
317 #ifdef FAUDES_PLUGIN_LUABUINDINGS
318 usage( "could not find luafaudes");
320 std::cout << "valfaudes: silently skipping test case" << std::endl;
337 args+= "-tbin ../bin";
340 testok= runfexec( "../bin/flxinstall",args);
346 usage( "could change to back working dir");
351 usage( "test failed to run");
368 std::cout << "valfaudes: no differences detected: test passed" << std::endl;
370 std::cout << "valfaudes: diff returncode \"" << testok << "\": test failed" << std::endl;
373 return (testok==0 ? 0 : 1);
std::string VersionString()
std::string ExtractDirectory(const std::string &rFullPath)
std::string PrependPath(const std::string &rLeft, const std::string &rRight)
std::string ExtractFilename(const std::string &rFullPath)
std::string ToLowerCase(const std::string &rString)
std::string ExtractBasename(const std::string &rFullPath)
bool FileExists(const std::string &rFilename)
std::string ExtractSuffix(const std::string &rFullPath)
int main(int argc, char *argv[])
int runfexec(const std::string &command, const std::string &arguments="")
void usage(const std::string &msg="")
int runsexec(const std::string &command, const std::string &arguments="")
int rundiff(const std::string &file1, const std::string &file2)
libFAUDES 2.33h
--- 2025.06.18
--- c++ api documentaion by doxygen
|