fork13 is a test prog backported from upstream mainline:
5fdee8c4a5e1800489ce61963208f8cc55e42ea1. However, it produces flooding
outputs that may cause syscall output log too large (30GB+!!); also
10e+7 times fork is too time consuming, 10e+6 should be valid enough
to reproduce the issue and it takes less time (~3min); if the test
fails, it would put an error msg, this might cause flood error msg in
output log as well, so I make it break the iteration when a failure
occurs.

v2: removed more flooding outputs, return immediately when failure occurs.

Signed-off-by: Caspar Zhang <[email protected]>
---
 runtest/syscalls                        |    2 +-
 testcases/kernel/syscalls/fork/fork13.c |   38
++++++++++++++++++++----------
 2 files changed, 26 insertions(+), 14 deletions(-)

diff --git a/runtest/syscalls b/runtest/syscalls
index d402531..3bd9c50 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -274,7 +274,7 @@ fork08 fork08
 fork09 fork09
 fork10 fork10
 fork11 fork11
-fork13 fork13 -c 2 -i 10000000
+fork13 fork13 -c 2 -i 1000000

 fpathconf01 fpathconf01

diff --git a/testcases/kernel/syscalls/fork/fork13.c
b/testcases/kernel/syscalls/fork/fork13.c
index 7c72352..d9dc8b8 100644
--- a/testcases/kernel/syscalls/fork/fork13.c
+++ b/testcases/kernel/syscalls/fork/fork13.c
@@ -86,15 +86,14 @@ int main(int argc, char* argv[])

 void check(void)
 {
-       int lc;
+       long lc;
+       int fail = 0;
        pid_t last_pid = 0;
        pid_t pid;
        int child_exit_code, distance, reaped, status;

        for (lc = 0; TEST_LOOPING(lc); lc++) {
                Tst_count = 0;
-               if (lc % PIDMAX == 0)
-                       tst_resm(TINFO, "Iter: %d", lc/PIDMAX);
                child_exit_code = lc % RETURN;
                switch (pid = fork()) {
                case -1:
@@ -103,31 +102,44 @@ void check(void)
                        exit(child_exit_code);
                default:
                        if (lc > 0) {
-                               tst_resm(TINFO, "last_pid = %d pid = %d",
-                                       last_pid, pid);
+                               if (lc % PIDMAX == 0)
+                                       tst_resm(TINFO, "Iter: %ld", lc/PIDMAX);
                                distance = pid_distance(last_pid, pid);
-                               if (distance == 0)
+                               if (distance == 0) {
                                        tst_resm(TFAIL,
                                                "Unexpected pid sequence: "
                                                "previous fork: pid=%d, "
                                                "current fork: pid=%d for "
-                                               "iteration=%d.", last_pid, pid,
+                                               "iteration=%ld.", last_pid, pid,
                                                lc);
+                                       fail++;
+                                       break;
+                               }
                        }
                        last_pid = pid;

                        reaped = wait(&status);
-                       if (reaped != pid)
+                       if (reaped != pid) {
                                tst_resm(TFAIL,
                                        "Wait return value: expected pid=%d, "
-                                       "got %d, iteration %d.", pid, reaped,
+                                       "got %d, iteration %ld.", pid, reaped,
                                        lc);
-                       else if (WEXITSTATUS(status) != child_exit_code)
+                               fail++;
+                               break;
+                       }
+                       else if (WEXITSTATUS(status) != child_exit_code) {
                                tst_resm(TFAIL, "Unexpected exit status %x, "
-                                       "iteration %d.", WEXITSTATUS(status),
+                                       "iteration %ld.", WEXITSTATUS(status),
                                        lc);
+                               fail++;
+                               break;
+                       }
                }
        }
+       if (fail)
+               tst_resm(TFAIL, "%ld pids forked, failure occured", lc);
+       else
+               tst_resm(TPASS, "%ld pids forked, all passed", lc);
 }

 void setup(void)
@@ -171,9 +183,9 @@ void cleanup(void)
        TEST_CLEANUP;
 }

-/* The distance mod 32768 between two pids, where the first pid is
+/* The distance mod PIDMAX between two pids, where the first pid is
    expected to be smaller than the second. */
 int pid_distance(pid_t first, pid_t second)
 {
-       return (second + 32768 - first) % 32768;
+       return (second + PIDMAX - first) % PIDMAX;
 }
-- 
1.7.4.1


From b30f6f184e293405ffdf0f7b8a2d293afcd2f853 Mon Sep 17 00:00:00 2001
From: Caspar Zhang <[email protected]>
Date: Thu, 3 Mar 2011 21:45:25 +0800
Subject: [PATCH] fork13 output too large

fork13 is a test prog backported from upstream mainline:
5fdee8c4a5e1800489ce61963208f8cc55e42ea1. However, it produces flooding
outputs that may cause syscall output log too large (30GB+!!); also
10e+7 times fork is too time consuming, 10e+6 should be valid enough
to reproduce the issue and it takes less time (~3min); if the test
fails, it would put an error msg, this might cause flood error msg in
output log as well, so I make it break the iteration when a failure
occurs.

Signed-off-by: Caspar Zhang <[email protected]>
---
 runtest/syscalls                        |    2 +-
 testcases/kernel/syscalls/fork/fork13.c |   38 ++++++++++++++++++++----------
 2 files changed, 26 insertions(+), 14 deletions(-)

diff --git a/runtest/syscalls b/runtest/syscalls
index d402531..3bd9c50 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -274,7 +274,7 @@ fork08 fork08
 fork09 fork09
 fork10 fork10
 fork11 fork11
-fork13 fork13 -c 2 -i 10000000
+fork13 fork13 -c 2 -i 1000000
 
 fpathconf01 fpathconf01
 
diff --git a/testcases/kernel/syscalls/fork/fork13.c 
b/testcases/kernel/syscalls/fork/fork13.c
index 7c72352..d9dc8b8 100644
--- a/testcases/kernel/syscalls/fork/fork13.c
+++ b/testcases/kernel/syscalls/fork/fork13.c
@@ -86,15 +86,14 @@ int main(int argc, char* argv[])
 
 void check(void)
 {
-       int lc;
+       long lc;
+       int fail = 0;
        pid_t last_pid = 0;
        pid_t pid;
        int child_exit_code, distance, reaped, status;
 
        for (lc = 0; TEST_LOOPING(lc); lc++) {
                Tst_count = 0;
-               if (lc % PIDMAX == 0)
-                       tst_resm(TINFO, "Iter: %d", lc/PIDMAX);
                child_exit_code = lc % RETURN;
                switch (pid = fork()) {
                case -1:
@@ -103,31 +102,44 @@ void check(void)
                        exit(child_exit_code);
                default:
                        if (lc > 0) {
-                               tst_resm(TINFO, "last_pid = %d pid = %d",
-                                       last_pid, pid);
+                               if (lc % PIDMAX == 0)
+                                       tst_resm(TINFO, "Iter: %ld", lc/PIDMAX);
                                distance = pid_distance(last_pid, pid);
-                               if (distance == 0)
+                               if (distance == 0) {
                                        tst_resm(TFAIL,
                                                "Unexpected pid sequence: "
                                                "previous fork: pid=%d, "
                                                "current fork: pid=%d for "
-                                               "iteration=%d.", last_pid, pid,
+                                               "iteration=%ld.", last_pid, pid,
                                                lc);
+                                       fail++;
+                                       break;
+                               }
                        }
                        last_pid = pid;
 
                        reaped = wait(&status);
-                       if (reaped != pid)
+                       if (reaped != pid) {
                                tst_resm(TFAIL,
                                        "Wait return value: expected pid=%d, "
-                                       "got %d, iteration %d.", pid, reaped,
+                                       "got %d, iteration %ld.", pid, reaped,
                                        lc);
-                       else if (WEXITSTATUS(status) != child_exit_code)
+                               fail++;
+                               break;
+                       }
+                       else if (WEXITSTATUS(status) != child_exit_code) {
                                tst_resm(TFAIL, "Unexpected exit status %x, "
-                                       "iteration %d.", WEXITSTATUS(status),
+                                       "iteration %ld.", WEXITSTATUS(status),
                                        lc);
+                               fail++;
+                               break;
+                       }
                }
        }
+       if (fail)
+               tst_resm(TFAIL, "%ld pids forked, failure occured", lc);
+       else
+               tst_resm(TPASS, "%ld pids forked, all passed", lc);
 }
 
 void setup(void)
@@ -171,9 +183,9 @@ void cleanup(void)
        TEST_CLEANUP;
 }
 
-/* The distance mod 32768 between two pids, where the first pid is
+/* The distance mod PIDMAX between two pids, where the first pid is
    expected to be smaller than the second. */
 int pid_distance(pid_t first, pid_t second)
 {
-       return (second + 32768 - first) % 32768;
+       return (second + PIDMAX - first) % PIDMAX;
 }
-- 
1.7.4.1

------------------------------------------------------------------------------
Free Software Download: Index, Search & Analyze Logs and other IT data in 
Real-Time with Splunk. Collect, index and harness all the fast moving IT data 
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business 
insights. http://p.sf.net/sfu/splunk-dev2dev 
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to