Oh... I sent the wrong v2 patch. here is the correct PATCH v2. Sorry for
noise...

On 03/03/2011 10:38 PM, Caspar Zhang wrote:

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

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 return immediately when a failure
occurs.

Signed-off-by: Caspar Zhang <[email protected]>
---
 runtest/syscalls                        |    2 +-
 testcases/kernel/syscalls/fork/fork13.c |   29
++++++++++++++++-------------
 2 files changed, 17 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..4804ea1 100644
--- a/testcases/kernel/syscalls/fork/fork13.c
+++ b/testcases/kernel/syscalls/fork/fork13.c
@@ -86,15 +86,13 @@ int main(int argc, char* argv[])

 void check(void)
 {
-       int lc;
+       long lc;
        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 +101,36 @@ void check(void)
                        exit(child_exit_code);
                default:
                        if (lc > 0) {
-                               tst_resm(TINFO, "last_pid = %d pid = %d",
-                                       last_pid, pid);
                                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);
+                                       return;
+                               }
                        }
                        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)
+                               return;
+                       }
+                       else if (WEXITSTATUS(status) != child_exit_code) {
                                tst_resm(TFAIL, "Unexpected exit status %x, "
-                                       "iteration %d.", WEXITSTATUS(status),
+                                       "iteration %ld.", WEXITSTATUS(status),
                                        lc);
+                               return;
+                       }
                }
        }
+       tst_resm(TPASS, "%ld pids forked, all passed", lc);
 }

 void setup(void)
@@ -171,9 +174,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 4c1f6db5f41df2b4c9c55423f05ff37d48559f85 Mon Sep 17 00:00:00 2001
From: Caspar Zhang <[email protected]>
Date: Thu, 3 Mar 2011 22:25:24 +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 return immediately when a failure
occurs.

Signed-off-by: Caspar Zhang <[email protected]>
---
 runtest/syscalls                        |    2 +-
 testcases/kernel/syscalls/fork/fork13.c |   29 ++++++++++++++++-------------
 2 files changed, 17 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..4804ea1 100644
--- a/testcases/kernel/syscalls/fork/fork13.c
+++ b/testcases/kernel/syscalls/fork/fork13.c
@@ -86,15 +86,13 @@ int main(int argc, char* argv[])
 
 void check(void)
 {
-       int lc;
+       long lc;
        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 +101,36 @@ void check(void)
                        exit(child_exit_code);
                default:
                        if (lc > 0) {
-                               tst_resm(TINFO, "last_pid = %d pid = %d",
-                                       last_pid, pid);
                                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);
+                                       return;
+                               }
                        }
                        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)
+                               return;
+                       }
+                       else if (WEXITSTATUS(status) != child_exit_code) {
                                tst_resm(TFAIL, "Unexpected exit status %x, "
-                                       "iteration %d.", WEXITSTATUS(status),
+                                       "iteration %ld.", WEXITSTATUS(status),
                                        lc);
+                               return;
+                       }
                }
        }
+       tst_resm(TPASS, "%ld pids forked, all passed", lc);
 }
 
 void setup(void)
@@ -171,9 +174,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