|
|
Go to the documentation of this file.
27void usage( const std::string& msg= "") {
29 std::cerr << "valfaudes: error: " << msg << std::endl;
30 std::cerr << std::endl;
31 std::flush(std::cerr);
32 std::flush(std::cout);
35 std::cerr << "valfaudes --- run and validate testcases (" << faudes::VersionString() << ")" << std::endl;
36 std::cerr << std::endl;
37 std::cerr << "usage:" << std::endl;
38 std::cerr << " valfaudes [-v|q] [-t <tmp>] <main-in>" << std::endl;
39 std::cerr << std::endl;
40 std::cerr << "with:" << std::endl;
41 std::cerr << " <main-in> specify '.prot' or a '.flx' input" << std::endl;
42 std::cerr << std::endl;
43 std::cerr << "options:" << std::endl;
44 std::cerr << " -t <tmp> temp dir for extracting/validating flx packages" << std::endl;
45 std::cerr << std::endl;
46 std::cerr << "note: this tool is meant to facilitate the libFAUDES build process and" << std::endl;
47 std::cerr << "relies on std libFAUDES folder layout" << std::endl;
48 std::cerr << std::endl;
73std::string exesfx( void) { return "";}
76std::string exesfx( void) { return ".exe";}
79std::string exesfx( void) { return "";}
84 std::string cmd=command;
87 cmd = cmd + " > /dev/null 2>&1 ";
92 cmd = cmd + " > NUL 2>&1";
95 std::cout << "valfaudes: running: \"" << cmd << "\"" << std::endl;
96 std::flush(std::cout);
97 std::flush(std::cerr);
98 int res= std::system(cmd.c_str());
103int runfexec( const std::string& command, const std::string& arguments= "") {
104 std::string cmd=command;
107 if((cmd.at(0)!= '/') && (cmd.at(0)!= '.'))
109 if(!arguments.empty())
110 cmd += " " + arguments;
114 if(!arguments.empty())
115 cmd += " " + arguments;
121int runsexec( const std::string& command, const std::string& arguments= "") {
122 std::string cmd=command;
124 if(!arguments.empty())
125 cmd += " " + arguments;
129 if(!arguments.empty())
130 cmd += " " + arguments;
136int rundiff( const std::string& file1, const std::string& file2) {
139 cmd= "diff -w --context=3 --show-function-line=mark " + file1 + " " + file2;
146 std::cout << "valfaudes: running: \"" << cmd << "\"" << std::endl;
147 std::flush(std::cout);
148 std::flush(std::cerr);
149 return std::system(cmd.c_str());
172 std::cout << "valfaudes: could not find luafaudes ( last try \"" << mLuaFaudes << "\""
182 if( runshell( "python3 --version")==0) {
186 if( runshell( "python --version")==0) {
193 if( runshell( "python3 --version")==0) {
197 if( runshell( "py.exe --version")==0) {
206 std::cout << "valfaudes: could not find python" <<std::endl;
213 std::cout << "valfaudes: using faudes module in current directory" <<std::endl;
218 if( FileExists( "../../pybindings/obj/faudes.py")) {
220 std::cout << "valfaudes: using faudes module from pybindings plug-in" <<std::endl;
227 std::cout << "valfaudes: failed to locate faudes module" <<std::endl;
234int main( int argc, char *argv[]) {
237 for( int i=1; i<argc; i++) {
238 std::string option(argv[i]);
240 if((option== "-?") || (option== "--help")) {
245 if((option== "-v") || (option== "--verbose")) {
251 if((option== "-q") || (option== "--quiet")) {
257 if((option== "-t") || (option== "--temp")) {
259 usage( "cannot read temp dir (-t)");
264 if(option.c_str()[0]== '-') {
265 usage( "unknown option "+ option);
274 usage( "no more than one argument must be specified" );
279 usage( "no input file specified");
283 std::cout << "valfaudes: input file: \"" << mArgFile << "\"" << std::endl;
292 size_t seppos= mTestCase.find_last_of( '_');
293 if(seppos==std::string::npos) {
294 usage( "could not figure test type (no seperator '_' in '.prot' file)");
320 usage( "could not figure test type");
326 if(datapos==std::string::npos) {
327 usage( "could not figure working dir (path must end with 'data' [a])");
330 usage( "could not figure working dir (path must end with 'data' [b])");
333 usage( "could not figure working dir (layout mismatch)");
341 std::cout << "valfaudes:" << std::endl;
342 std::cout << " test case: \"" << mTestCase << "\"" << std::endl;
343 std::cout << " test working dir: \"" << mTestPath << "\"" << std::endl;
345 std::cout << " exeutable: \"" << mBinFile << "\"" << std::endl;
347 std::cout << " lua script: \"" << mLuaFile << "\"" << std::endl;
349 std::cout << " python script: \"" << mPyFile << "\"" << std::endl;
351 std::cout << " flx file: \"" << mFlxFile << "\"" << std::endl;
359 std::cout << "valfaudes: error: nothing we can validate" << std::endl;
366 usage( "could not figure current working dir");
370 usage( "could change to test working dir");
380#ifndef FAUDES_PLUGIN_LUABINDINGS
381 std::cout << "valfaudes: no luabindings, silently skipping test case" << std::endl;
385 usage( "could not find luafaudes");
396#ifndef FAUDES_PLUGIN_PYBINDINGS
397 std::cout << "valfaudes: no pybindings, silently skipping test case" << std::endl;
401 usage( "could not find python");
406 std::string args= "-c ";
408 args += "import sys; sys.path.append('" + mPythonPath + "'); ";
409 args += "import faudes; faudes.FAUDES_TEST_NAME='" + mPyFile + "'; ";
410 args += " exec(open('" + mPyFile + "').read()); ";
422 args+= "-tbin ../bin";
425 testok= runfexec( "../bin/flxinstall",args);
431 usage( "could nod change back working dir");
436 usage( "test failed to run");
453 std::cout << "valfaudes: no differences detected: test passed" << std::endl;
455 std::cout << "valfaudes: diff returncode \"" << testok << "\": test failed" << std::endl;
458 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 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)
int runshell(const std::string &command)
libFAUDES 2.34d
--- 2026.03.11
--- c++ api documentaion by doxygen
|