Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
K
KWSys
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sylvain Joubert
KWSys
Commits
10162a01
Commit
10162a01
authored
20 years ago
by
Brad King
Browse files
Options
Downloads
Patches
Plain Diff
ENH: Added test for runaway output.
parent
d7b2b373
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CMakeLists.txt
+1
-0
1 addition, 0 deletions
CMakeLists.txt
testProcess.c
+44
-10
44 additions, 10 deletions
testProcess.c
with
45 additions
and
10 deletions
CMakeLists.txt
+
1
−
0
View file @
10162a01
...
...
@@ -421,5 +421,6 @@ IF(KWSYS_STANDALONE)
ADD_TEST
(
testProcess-3 testProcess 3
)
ADD_TEST
(
testProcess-4 testProcess 4
)
ADD_TEST
(
testProcess-5 testProcess 5
)
ADD_TEST
(
testProcess-6 testProcess 6
)
ENDIF
(
BUILD_TESTING
)
ENDIF
(
KWSYS_STANDALONE
)
This diff is collapsed.
Click to expand it.
testProcess.c
+
44
−
10
View file @
10162a01
...
...
@@ -22,7 +22,7 @@
#endif
int
runChild
(
const
char
*
cmd
[],
int
state
,
int
exception
,
int
value
,
int
share
,
double
timeout
);
int
share
,
int
delay
,
double
timeout
);
int
test1
(
int
argc
,
const
char
*
argv
[])
{
...
...
@@ -84,7 +84,7 @@ int test5(int argc, const char* argv[])
fflush
(
stdout
);
fflush
(
stderr
);
r
=
runChild
(
cmd
,
kwsysProcess_State_Exception
,
kwsysProcess_Exception_Fault
,
1
,
1
,
2
);
kwsysProcess_Exception_Fault
,
1
,
1
,
0
,
2
);
fprintf
(
stdout
,
"Output on stdout after recursive test.
\n
"
);
fprintf
(
stderr
,
"Output on stderr after recursive test.
\n
"
);
fflush
(
stdout
);
...
...
@@ -92,9 +92,31 @@ int test5(int argc, const char* argv[])
return
r
;
}
#define TEST6_SIZE (4096*2)
int
test6
(
int
argc
,
const
char
*
argv
[])
{
int
i
;
char
runaway
[
TEST6_SIZE
+
2
];
(
void
)
argc
;
(
void
)
argv
;
for
(
i
=
0
;
i
<
TEST6_SIZE
;
++
i
)
{
runaway
[
i
]
=
'.'
;
}
runaway
[
TEST6_SIZE
]
=
'\n'
;
runaway
[
TEST6_SIZE
]
=
0
;
/* Generate huge amounts of output to test killing. */
for
(;;)
{
fwrite
(
runaway
,
1
,
TEST6_SIZE
+
2
,
stdout
);
fflush
(
stdout
);
}
return
0
;
}
int
runChild
(
const
char
*
cmd
[],
int
state
,
int
exception
,
int
value
,
int
share
,
double
timeout
)
int
share
,
int
delay
,
double
timeout
)
{
int
result
=
0
;
char
*
data
=
0
;
...
...
@@ -121,6 +143,12 @@ int runChild(const char* cmd[], int state, int exception, int value,
{
fwrite
(
data
,
1
,
length
,
stdout
);
fflush
(
stdout
);
if
(
delay
)
{
#if defined(_WIN32)
Sleep
(
100
);
#endif
}
}
}
...
...
@@ -203,7 +231,7 @@ int main(int argc, const char* argv[])
n
=
atoi
(
argv
[
2
]);
}
/* Check arguments. */
if
(
n
<
1
||
n
>
5
||
(
argc
==
3
&&
strcmp
(
argv
[
1
],
"run"
)
!=
0
))
if
(
n
<
1
||
n
>
6
||
(
argc
==
3
&&
strcmp
(
argv
[
1
],
"run"
)
!=
0
))
{
fprintf
(
stdout
,
"Usage: %s <test number>
\n
"
,
argv
[
0
]);
return
1
;
...
...
@@ -217,30 +245,35 @@ int main(int argc, const char* argv[])
case
3
:
return
test3
(
argc
,
argv
);
case
4
:
return
test4
(
argc
,
argv
);
case
5
:
return
test5
(
argc
,
argv
);
case
6
:
return
test6
(
argc
,
argv
);
}
fprintf
(
stderr
,
"Invalid test number %d.
\n
"
,
n
);
return
1
;
}
if
(
n
>=
0
&&
n
<=
5
)
if
(
n
>=
0
&&
n
<=
6
)
{
int
states
[
5
]
=
int
states
[
6
]
=
{
kwsysProcess_State_Exited
,
kwsysProcess_State_Exited
,
kwsysProcess_State_Expired
,
kwsysProcess_State_Exception
,
kwsysProcess_State_Exited
kwsysProcess_State_Exited
,
kwsysProcess_State_Expired
};
int
exceptions
[
5
]
=
int
exceptions
[
6
]
=
{
kwsysProcess_Exception_None
,
kwsysProcess_Exception_None
,
kwsysProcess_Exception_None
,
kwsysProcess_Exception_Fault
,
kwsysProcess_Exception_None
,
kwsysProcess_Exception_None
};
int
values
[
5
]
=
{
0
,
123
,
1
,
1
,
0
};
int
values
[
6
]
=
{
0
,
123
,
1
,
1
,
0
,
0
};
int
delays
[
6
]
=
{
0
,
0
,
0
,
0
,
0
,
1
};
double
timeouts
[
6
]
=
{
3
,
3
,
3
,
3
,
3
,
0
.
1
};
int
r
;
const
char
*
cmd
[
4
];
cmd
[
0
]
=
argv
[
0
];
...
...
@@ -251,7 +284,8 @@ int main(int argc, const char* argv[])
fprintf
(
stderr
,
"Output on stderr before test %d.
\n
"
,
n
);
fflush
(
stdout
);
fflush
(
stderr
);
r
=
runChild
(
cmd
,
states
[
n
-
1
],
exceptions
[
n
-
1
],
values
[
n
-
1
],
0
,
3
);
r
=
runChild
(
cmd
,
states
[
n
-
1
],
exceptions
[
n
-
1
],
values
[
n
-
1
],
0
,
delays
[
n
-
1
],
timeouts
[
n
-
1
]);
fprintf
(
stdout
,
"Output on stdout after test %d.
\n
"
,
n
);
fprintf
(
stderr
,
"Output on stderr after test %d.
\n
"
,
n
);
fflush
(
stdout
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment