summaryrefslogtreecommitdiffstats
path: root/Source/kwsys/testProcess.c
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2015-08-31 13:55:01 (GMT)
committerBrad King <brad.king@kitware.com>2015-08-31 13:55:01 (GMT)
commit49d293a795c42c0325aa677d6a7c0f55c647da91 (patch)
tree4fd9904c8c03be327f754589d910d36c24ffcf10 /Source/kwsys/testProcess.c
parent51d7a7bb3f03b3562c8ca82ddfefcc5185dc2455 (diff)
parentca96be228345d93f51cb4edbd0428b709f529b84 (diff)
downloadCMake-49d293a795c42c0325aa677d6a7c0f55c647da91.zip
CMake-49d293a795c42c0325aa677d6a7c0f55c647da91.tar.gz
CMake-49d293a795c42c0325aa677d6a7c0f55c647da91.tar.bz2
Merge branch 'upstream-kwsys' into update-kwsys
Diffstat (limited to 'Source/kwsys/testProcess.c')
-rw-r--r--Source/kwsys/testProcess.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/Source/kwsys/testProcess.c b/Source/kwsys/testProcess.c
index d0e20c1..8fd3382 100644
--- a/Source/kwsys/testProcess.c
+++ b/Source/kwsys/testProcess.c
@@ -21,6 +21,7 @@
#endif
#include <assert.h>
+#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -74,6 +75,16 @@ int runChild(const char* cmd[], int state, int exception, int value,
static int test1(int argc, const char* argv[])
{
+ /* This is a very basic functional test of kwsysProcess. It is repeated
+ numerous times to verify that there are no resource leaks in kwsysProcess
+ that eventually lead to an error. Many versions of OS X will fail after
+ 256 leaked file handles, so 257 iterations seems to be a good test. On
+ the other hand, too many iterations will cause the test to time out -
+ especially if the test is instrumented with e.g. valgrind.
+
+ If you have problems with this test timing out on your system, or want to
+ run more than 257 iterations, you can change the number of iterations by
+ setting the KWSYS_TEST_PROCESS_1_COUNT environment variable. */
(void)argc; (void)argv;
fprintf(stdout, "Output on stdout from test returning 0.\n");
fprintf(stderr, "Output on stderr from test returning 0.\n");
@@ -557,6 +568,10 @@ int runChild(const char* cmd[], int state, int exception, int value,
result = runChild2(kp, cmd, state, exception, value, share,
output, delay, timeout, poll, disown, createNewGroup,
interruptDelay);
+ if(result)
+ {
+ break;
+ }
}
kwsysProcess_Delete(kp);
return result;
@@ -660,13 +675,24 @@ int main(int argc, const char* argv[])
int delays[10] = {0, 0, 0, 0, 0, 1, 0, 0, 0, 0};
double timeouts[10] = {10, 10, 10, 30, 30, 10, -1, 10, 6, 4};
int polls[10] = {0, 0, 0, 0, 0, 0, 1, 0, 0, 0};
- int repeat[10] = {2, 1, 1, 1, 1, 1, 1, 1, 1, 1};
+ int repeat[10] = {257, 1, 1, 1, 1, 1, 1, 1, 1, 1};
int createNewGroups[10] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 1};
unsigned int interruptDelays[10] = {0, 0, 0, 0, 0, 0, 0, 0, 3, 2};
int r;
const char* cmd[4];
#ifdef _WIN32
char* argv0 = 0;
+#endif
+ char* test1IterationsStr = getenv("KWSYS_TEST_PROCESS_1_COUNT");
+ if(test1IterationsStr)
+ {
+ long int test1Iterations = strtol(test1IterationsStr, 0, 10);
+ if(test1Iterations > 10 && test1Iterations != LONG_MAX)
+ {
+ repeat[0] = (int)test1Iterations;
+ }
+ }
+#ifdef _WIN32
if(n == 0 && (argv0 = strdup(argv[0])))
{
/* Try converting to forward slashes to see if it works. */