ENH: Added optional display of output for tests. Avoid printing alot of output for test 6.

This commit is contained in:
Brad King 2004-09-30 17:42:42 -04:00
parent 77209d371f
commit f2e46cf172

View File

@ -22,7 +22,7 @@
#endif #endif
int runChild(const char* cmd[], int state, int exception, int value, int runChild(const char* cmd[], int state, int exception, int value,
int share, int delay, double timeout); int share, int output, int delay, double timeout);
int test1(int argc, const char* argv[]) int test1(int argc, const char* argv[])
{ {
@ -84,7 +84,7 @@ int test5(int argc, const char* argv[])
fflush(stdout); fflush(stdout);
fflush(stderr); fflush(stderr);
r = runChild(cmd, kwsysProcess_State_Exception, r = runChild(cmd, kwsysProcess_State_Exception,
kwsysProcess_Exception_Fault, 1, 1, 0, 2); kwsysProcess_Exception_Fault, 1, 1, 1, 0, 2);
fprintf(stdout, "Output on stdout after recursive test.\n"); fprintf(stdout, "Output on stdout after recursive test.\n");
fprintf(stderr, "Output on stderr after recursive test.\n"); fprintf(stderr, "Output on stderr after recursive test.\n");
fflush(stdout); fflush(stdout);
@ -115,7 +115,7 @@ int test6(int argc, const char* argv[])
int runChild(const char* cmd[], int state, int exception, int value, int runChild(const char* cmd[], int state, int exception, int value,
int share, int delay, double timeout) int share, int output, int delay, double timeout)
{ {
int result = 0; int result = 0;
char* data = 0; char* data = 0;
@ -139,11 +139,15 @@ int runChild(const char* cmd[], int state, int exception, int value,
if(!share) if(!share)
{ {
while(kwsysProcess_WaitForData(kp, &data, &length, 0)) while(kwsysProcess_WaitForData(kp, &data, &length, 0))
{
if(output)
{ {
fwrite(data, 1, length, stdout); fwrite(data, 1, length, stdout);
fflush(stdout); fflush(stdout);
}
if(delay) if(delay)
{ {
/* Purposely sleeping only on Win32 to let pipe fill up. */
#if defined(_WIN32) #if defined(_WIN32)
Sleep(100); Sleep(100);
#endif #endif
@ -271,6 +275,7 @@ int main(int argc, const char* argv[])
kwsysProcess_Exception_None kwsysProcess_Exception_None
}; };
int values[6] = {0, 123, 1, 1, 0, 0}; int values[6] = {0, 123, 1, 1, 0, 0};
int outputs[6] = {1, 1, 1, 1, 1, 0};
int delays[6] = {0, 0, 0, 0, 0, 1}; int delays[6] = {0, 0, 0, 0, 0, 1};
double timeouts[6] = {3, 3, 3, 3, 3, 0.1}; double timeouts[6] = {3, 3, 3, 3, 3, 0.1};
int r; int r;
@ -284,7 +289,7 @@ int main(int argc, const char* argv[])
fflush(stdout); fflush(stdout);
fflush(stderr); fflush(stderr);
r = runChild(cmd, states[n-1], exceptions[n-1], values[n-1], 0, r = runChild(cmd, states[n-1], exceptions[n-1], values[n-1], 0,
delays[n-1], timeouts[n-1]); outputs[n-1], delays[n-1], timeouts[n-1]);
fprintf(stdout, "Output on stdout after test %d.\n", n); fprintf(stdout, "Output on stdout after test %d.\n", n);
fprintf(stderr, "Output on stderr after test %d.\n", n); fprintf(stderr, "Output on stderr after test %d.\n", n);
fflush(stdout); fflush(stdout);