ENH: Extended test 0 to run the executable twice using the same process object. This tests the reusability of the objects.

This commit is contained in:
Brad King 2005-07-07 09:06:56 -04:00
parent 7e7249cbd1
commit 3f14dae716
1 changed files with 29 additions and 14 deletions

View File

@ -31,7 +31,8 @@
#endif
int runChild(const char* cmd[], int state, int exception, int value,
int share, int output, int delay, double timeout, int poll);
int share, int output, int delay, double timeout, int poll,
int repeat);
int test1(int argc, const char* argv[])
{
@ -97,7 +98,7 @@ int test5(int argc, const char* argv[])
fflush(stdout);
fflush(stderr);
r = runChild(cmd, kwsysProcess_State_Exception,
kwsysProcess_Exception_Fault, 1, 1, 1, 0, 15, 0);
kwsysProcess_Exception_Fault, 1, 1, 1, 0, 15, 0, 1);
fprintf(stdout, "Output on stdout after recursive test.\n");
fprintf(stderr, "Output on stderr after recursive test.\n");
fflush(stdout);
@ -150,7 +151,8 @@ int test7(int argc, const char* argv[])
return 0;
}
int runChild(const char* cmd[], int state, int exception, int value,
int runChild2(kwsysProcess* kp,
const char* cmd[], int state, int exception, int value,
int share, int output, int delay, double timeout,
int poll)
{
@ -159,13 +161,6 @@ int runChild(const char* cmd[], int state, int exception, int value,
int length = 0;
double userTimeout = 0;
double* pUserTimeout = 0;
kwsysProcess* kp = kwsysProcess_New();
if(!kp)
{
fprintf(stderr, "kwsysProcess_New returned NULL!\n");
return 1;
}
kwsysProcess_SetCommand(kp, cmd);
if(timeout >= 0)
{
@ -289,6 +284,25 @@ int runChild(const char* cmd[], int state, int exception, int value,
result = 1;
}
return result;
}
int runChild(const char* cmd[], int state, int exception, int value,
int share, int output, int delay, double timeout,
int poll, int repeat)
{
int result;
kwsysProcess* kp = kwsysProcess_New();
if(!kp)
{
fprintf(stderr, "kwsysProcess_New returned NULL!\n");
return 1;
}
while(repeat-- > 0)
{
result = runChild2(kp, cmd, state, exception, value, share,
output, delay, timeout, poll);
}
kwsysProcess_Delete(kp);
return result;
}
@ -369,6 +383,7 @@ int main(int argc, const char* argv[])
int delays[7] = {0, 0, 0, 0, 0, 1, 0};
double timeouts[7] = {10, 10, 10, 10, 30, 10, -1};
int polls[7] = {0, 0, 0, 0, 0, 0, 1};
int repeat[7] = {2, 1, 1, 1, 1, 1, 1};
int r;
const char* cmd[4];
#ifdef _WIN32
@ -402,7 +417,7 @@ int main(int argc, const char* argv[])
fflush(stderr);
r = runChild(cmd, states[n-1], exceptions[n-1], values[n-1], 0,
outputs[n-1], delays[n-1], timeouts[n-1],
polls[n-1]);
polls[n-1], repeat[n-1]);
fprintf(stdout, "Output on stdout after test %d.\n", n);
fprintf(stderr, "Output on stderr after test %d.\n", n);
fflush(stdout);