summaryrefslogtreecommitdiffstats
path: root/Source/kwsys
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2005-07-07 13:06:56 (GMT)
committerBrad King <brad.king@kitware.com>2005-07-07 13:06:56 (GMT)
commit3f14dae7162f5a78748a13b03d6501b52bbea784 (patch)
treea41681d91adca00c66b94755560b811af7c35b42 /Source/kwsys
parent7e7249cbd185156e2e3d31f434519696a923b8e1 (diff)
downloadCMake-3f14dae7162f5a78748a13b03d6501b52bbea784.zip
CMake-3f14dae7162f5a78748a13b03d6501b52bbea784.tar.gz
CMake-3f14dae7162f5a78748a13b03d6501b52bbea784.tar.bz2
ENH: Extended test 0 to run the executable twice using the same process object. This tests the reusability of the objects.
Diffstat (limited to 'Source/kwsys')
-rw-r--r--Source/kwsys/testProcess.c43
1 files changed, 29 insertions, 14 deletions
diff --git a/Source/kwsys/testProcess.c b/Source/kwsys/testProcess.c
index acad83f..bbba948 100644
--- a/Source/kwsys/testProcess.c
+++ b/Source/kwsys/testProcess.c
@@ -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,22 +151,16 @@ int test7(int argc, const char* argv[])
return 0;
}
-int runChild(const char* cmd[], int state, int exception, int value,
- int share, int output, int delay, double timeout,
- int poll)
+int runChild2(kwsysProcess* kp,
+ const char* cmd[], int state, int exception, int value,
+ int share, int output, int delay, double timeout,
+ int poll)
{
int result = 0;
char* data = 0;
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)
{
@@ -288,7 +283,26 @@ int runChild(const char* cmd[], int state, int exception, int value,
poll, MINPOLL);
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);