public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH] syscalls/getrusage03: flush stdout to avoid duplicated output
@ 2012-01-10  3:38 Caspar Zhang
  2012-01-10  3:40 ` Caspar Zhang
  2012-01-13  5:43 ` Mike Frysinger
  0 siblings, 2 replies; 12+ messages in thread
From: Caspar Zhang @ 2012-01-10  3:38 UTC (permalink / raw)
  To: LTP List

[-- Attachment #1: Type: text/plain, Size: 391 bytes --]


when executing with `$BIN/runltp` command, getrusage03 puts out
duplicated information due to buffered stdout. Using fflush(stdout) to
solve this issue.

Signed-off-by: Caspar Zhang <caspar@casparzhang.com>
---
 testcases/kernel/syscalls/getrusage/getrusage03.c  |    7 +++++++
 .../kernel/syscalls/getrusage/getrusage03_child.c  |    1 +
 2 files changed, 8 insertions(+), 0 deletions(-)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-syscalls-getrusage03-flush-stdout-to-avoid-duplicate.patch --]
[-- Type: text/x-patch; name="0001-syscalls-getrusage03-flush-stdout-to-avoid-duplicate.patch", Size: 2544 bytes --]

diff --git a/testcases/kernel/syscalls/getrusage/getrusage03.c b/testcases/kernel/syscalls/getrusage/getrusage03.c
index 3ec5284..df25ff0 100644
--- a/testcases/kernel/syscalls/getrusage/getrusage03.c
+++ b/testcases/kernel/syscalls/getrusage/getrusage03.c
@@ -104,6 +104,7 @@ static void inherit_fork(void)
 	SAFE_GETRUSAGE(cleanup, RUSAGE_SELF, &ru);
 	tst_resm(TINFO, "initial.self = %ld", ru.ru_maxrss);
 
+	fflush(stdout);
 	switch (pid = fork()) {
 	case -1:
 		tst_brkm(TBROK|TERRNO, cleanup, "fork #1");
@@ -135,6 +136,7 @@ static void inherit_fork2(void)
 	else
 		tst_resm(TFAIL, "initial.children !~= 100MB");
 
+	fflush(stdout);
 	switch (pid = fork()) {
 	case -1:
 		tst_brkm(TBROK|TERRNO, cleanup, "fork #2");
@@ -161,6 +163,7 @@ static void fork_malloc(void)
 	SAFE_GETRUSAGE(cleanup, RUSAGE_SELF, &ru);
 	tst_resm(TINFO, "initial.self = %ld", ru.ru_maxrss);
 
+	fflush(stdout);
 	switch (pid = fork()) {
 	case -1:
 		tst_brkm(TBROK|TERRNO, cleanup, "fork #3");
@@ -190,6 +193,7 @@ static void grandchild_maxrss(void)
 	SAFE_GETRUSAGE(cleanup, RUSAGE_CHILDREN, &ru);
 	tst_resm(TINFO, "initial.children = %ld", ru.ru_maxrss);
 
+	fflush(stdout);
 	switch (pid = fork()) {
 	case -1:
 		tst_brkm(TBROK|TERRNO, cleanup, "fork #4");
@@ -225,6 +229,7 @@ static void zombie(void)
 	tst_resm(TINFO, "initial.children = %ld", ru.ru_maxrss);
 	maxrss_init = ru.ru_maxrss;
 
+	fflush(stdout);
 	switch (pid = fork()) {
 	case -1:
 		tst_brkm(TBROK, cleanup, "fork #5");
@@ -269,6 +274,7 @@ static void sig_ign(void)
 	signal(SIGCHLD, SIG_IGN);
 	maxrss_init = ru.ru_maxrss;
 
+	fflush(stdout);
 	switch (pid = fork()) {
 	case -1:
 		tst_brkm(TBROK, cleanup, "fork #6");
@@ -306,6 +312,7 @@ static void exec_without_fork(void)
 	maxrss_child = ru.ru_maxrss;
 	tst_resm(TINFO, "initial.self = %ld, initial.children = %ld",
 		    maxrss_self, maxrss_child);
+	fflush(stdout);
 
 	sprintf(str_maxrss_self, "%ld", maxrss_self);
 	sprintf(str_maxrss_child, "%ld", maxrss_child);
diff --git a/testcases/kernel/syscalls/getrusage/getrusage03_child.c b/testcases/kernel/syscalls/getrusage/getrusage03_child.c
index a9c1d38..f5d2850 100644
--- a/testcases/kernel/syscalls/getrusage/getrusage03_child.c
+++ b/testcases/kernel/syscalls/getrusage/getrusage03_child.c
@@ -87,6 +87,7 @@ int main(int argc, char *argv[])
 			grand_consume_nr = get_long(grand_consume_str);
 			tst_resm(TINFO, "grandchild allocate %ldMB",
 				    grand_consume_nr);
+			fflush(stdout);
 			switch (pid = fork()) {
 			case -1:
 				tst_brkm(TBROK, cleanup, "fork");

[-- Attachment #3: Type: text/plain, Size: 355 bytes --]

------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create 
new or port existing apps to sell to consumers worldwide. Explore the 
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev

[-- Attachment #4: Type: text/plain, Size: 155 bytes --]

_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2012-01-20 14:25 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-10  3:38 [LTP] [PATCH] syscalls/getrusage03: flush stdout to avoid duplicated output Caspar Zhang
2012-01-10  3:40 ` Caspar Zhang
2012-01-10  3:43   ` Wanlong Gao
2012-01-11 12:20   ` Cyril Hrubis
2012-01-11 12:41   ` Jan Stancek
2012-01-11 12:56     ` Cyril Hrubis
     [not found]       ` <aa1139e7-47d6-40d4-8406-4cef27343f29@zmail16.collab.prod.int.phx2.redhat.com>
2012-01-11 14:34         ` Cyril Hrubis
     [not found]           ` <201201130101.06630.vapier@gentoo.org>
2012-01-13 13:07             ` Cyril Hrubis
     [not found]               ` <201201131216.03211.vapier@gentoo.org>
2012-01-18 16:17                 ` Cyril Hrubis
     [not found]                   ` <201201181139.19497.vapier@gentoo.org>
2012-01-19 17:43                     ` Cyril Hrubis
     [not found]                       ` <201201191334.47413.vapier@gentoo.org>
2012-01-20 14:37                         ` Cyril Hrubis
2012-01-13  5:43 ` Mike Frysinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox