[3/8] Use loop in disp-step-fork.c and disp-step-vfork.c
Commit Message
We can call fork/vfork more easily in the test.
gdb/testsuite:
2016-02-19 Yao Qi <yao.qi@linaro.org>
* gdb.base/disp-step-fork.c (main): Use loop.
* gdb.base/disp-step-vfork.c (main): Likewise.
---
gdb/testsuite/gdb.base/disp-step-fork.c | 35 ++++++--------------
gdb/testsuite/gdb.base/disp-step-vfork.c | 55 ++++++++++----------------------
2 files changed, 26 insertions(+), 64 deletions(-)
Comments
On 02/19/2016 02:36 PM, Yao Qi wrote:
> We can call fork/vfork more easily in the test.
How about instead simply restarting the program / gdb? Keeping the program
alive for multiple test sequences is more prone to cascading FAILs.
Thanks,
Pedro Alves
@@ -24,33 +24,18 @@ marker () {}
int
main (void)
{
- int pid;
+ int i, pid;
- pid = fork ();
- if (pid == 0) /* child */
- {
- exit (0); /* at exit */
- }
- else
- {
- }
-
- pid = fork ();
- if (pid == 0) /* child */
- {
- exit (0); /* at exit */
- }
- else
- {
- }
-
- pid = fork ();
- if (pid == 0) /* child */
- {
- exit (0); /* at exit */
- }
- else
+ for (i = 0; i < 3; i++)
{
+ pid = fork ();
+ if (pid == 0) /* child */
+ {
+ exit (0); /* at exit */
+ }
+ else
+ {
+ }
}
marker ();
@@ -23,45 +23,22 @@ marker () {}
int
main (void)
{
- int pid;
-
- pid = vfork ();
- if (pid == -1)
- {
- return 1;
- }
- else if (pid != 0)
- {
- }
- else
- {
- _exit (0);
- }
-
- pid = vfork ();
- if (pid == -1)
- {
- return 1;
- }
- else if (pid != 0)
- {
- }
- else
- {
- _exit (0);
- }
-
- pid = vfork ();
- if (pid == -1)
- {
- return 1;
- }
- else if (pid != 0)
- {
- }
- else
- {
- _exit (0);
+ int i, pid;
+
+ for (i = 0; i < 3; i++)
+ {
+ pid = vfork ();
+ if (pid == -1)
+ {
+ return 1;
+ }
+ else if (pid != 0)
+ {
+ }
+ else
+ {
+ _exit (0);
+ }
}
marker ();