execm test driver: use to test rcldoc.py
This commit is contained in:
parent
28be1152ef
commit
9bb428aa3b
1 changed files with 84 additions and 76 deletions
|
@ -1071,22 +1071,25 @@ void ReExec::reexec()
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <signal.h>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
#include "debuglog.h"
|
#include "debuglog.h"
|
||||||
#include "cancelcheck.h"
|
#include "cancelcheck.h"
|
||||||
#include "execmd.h"
|
#include "execmd.h"
|
||||||
#include "smallut.h"
|
#include "smallut.h"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
|
||||||
// Testing with rclaudio: use an mp3 as parameter
|
// Testing with rclaudio: use an mp3 as parameter
|
||||||
static const string tstcmd("/usr/share/recoll/filters/rclaudio");
|
static const string tstcmd("/home/dockes/projets/fulltext/win-recoll/src/filters/rcldoc.py");
|
||||||
static const string mimetype("audio/mpeg");
|
static const string mimetype("text/html");
|
||||||
bool exercise_mhexecm(const string& filename)
|
bool exercise_mhexecm(vector<string>& files)
|
||||||
{
|
{
|
||||||
ExecCmd cmd;
|
ExecCmd cmd;
|
||||||
|
|
||||||
|
@ -1097,9 +1100,11 @@ bool exercise_mhexecm(const string& filename)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (vector<string>::const_iterator it = files.begin();
|
||||||
|
it != files.end(); it++) {
|
||||||
// Build request message
|
// Build request message
|
||||||
ostringstream obuf;
|
ostringstream obuf;
|
||||||
obuf << "FileName: " << filename.length() << "\n" << filename;
|
obuf << "Filename: " << (*it).length() << "\n" << (*it);
|
||||||
obuf << "Mimetype: " << mimetype.length() << "\n" << mimetype;
|
obuf << "Mimetype: " << mimetype.length() << "\n" << mimetype;
|
||||||
// Bogus parameter should be skipped by filter
|
// Bogus parameter should be skipped by filter
|
||||||
obuf << "BogusParam: " << string("bogus").length() << "\n" << "bogus";
|
obuf << "BogusParam: " << string("bogus").length() << "\n" << "bogus";
|
||||||
|
@ -1129,11 +1134,12 @@ bool exercise_mhexecm(const string& filename)
|
||||||
if (!ibuf.compare("\n")) {
|
if (!ibuf.compare("\n")) {
|
||||||
cerr << "Got empty line\n";
|
cerr << "Got empty line\n";
|
||||||
name.clear();
|
name.clear();
|
||||||
return true;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Filters will sometimes abort before entering the real protocol, ie if
|
// Filters will sometimes abort before entering the real
|
||||||
// a module can't be loaded. Check the special filter error first word:
|
// protocol, ie if a module can't be loaded. Check the
|
||||||
|
// special filter error first word:
|
||||||
if (ibuf.find("RECFILTERROR ") == 0) {
|
if (ibuf.find("RECFILTERROR ") == 0) {
|
||||||
cerr << "Got RECFILTERROR\n";
|
cerr << "Got RECFILTERROR\n";
|
||||||
return false;
|
return false;
|
||||||
|
@ -1151,7 +1157,8 @@ bool exercise_mhexecm(const string& filename)
|
||||||
string& slen = *it;
|
string& slen = *it;
|
||||||
int len;
|
int len;
|
||||||
if (sscanf(slen.c_str(), "%d", &len) != 1) {
|
if (sscanf(slen.c_str(), "%d", &len) != 1) {
|
||||||
cerr << "bad line in filter output (no len): [" << ibuf << "]\n";
|
cerr << "bad line in filter output (no len): [" <<
|
||||||
|
ibuf << "]\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Read element data
|
// Read element data
|
||||||
|
@ -1167,7 +1174,7 @@ bool exercise_mhexecm(const string& filename)
|
||||||
break;
|
break;
|
||||||
cerr << "Got name: [" << name << "] data [" << data << "]\n";
|
cerr << "Got name: [" << name << "] data [" << data << "]\n";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1227,7 +1234,7 @@ static char usage [] =
|
||||||
"trexecmd [-c|-r] cmd [arg1 arg2 ...]\n"
|
"trexecmd [-c|-r] cmd [arg1 arg2 ...]\n"
|
||||||
" -c : test cancellation (ie: trexecmd -c sleep 1000)\n"
|
" -c : test cancellation (ie: trexecmd -c sleep 1000)\n"
|
||||||
" -r : test reexec\n"
|
" -r : test reexec\n"
|
||||||
" -m <path to mp3 file>: test execm: needs installed and working rclaudio/mutagen\n"
|
" -m <file.doc> [...]: test execm:\n"
|
||||||
"trexecmd -w cmd : do the which thing\n"
|
"trexecmd -w cmd : do the which thing\n"
|
||||||
;
|
;
|
||||||
static void Usage(void)
|
static void Usage(void)
|
||||||
|
@ -1303,7 +1310,8 @@ int main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
if (op_flags & OPT_m) {
|
if (op_flags & OPT_m) {
|
||||||
return exercise_mhexecm(arg1) ? 0 : 1;
|
l.insert(l.begin(), arg1);
|
||||||
|
return exercise_mhexecm(l) ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////
|
//////////////
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue