diff mbox series

[v2,2/5] syscalls/mallopt01: Use tst_print_mallinfo api

Message ID 1612440762-22389-2-git-send-email-xuyang2018.jy@cn.fujitsu.com
State Superseded
Headers show
Series [v2,1/5] tst_mallinfo.c: Add a common print helper for mallinfo | expand

Commit Message

Yang Xu Feb. 4, 2021, 12:12 p.m. UTC
Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
---
 testcases/kernel/syscalls/mallopt/mallopt01.c | 22 +++----------------
 1 file changed, 3 insertions(+), 19 deletions(-)
diff mbox series

Patch

diff --git a/testcases/kernel/syscalls/mallopt/mallopt01.c b/testcases/kernel/syscalls/mallopt/mallopt01.c
index f799aaf9d..271079c12 100644
--- a/testcases/kernel/syscalls/mallopt/mallopt01.c
+++ b/testcases/kernel/syscalls/mallopt/mallopt01.c
@@ -12,10 +12,9 @@ 
  * Basic mallinfo() and mallopt() testing.
 \*/
 
-#include <malloc.h>
-
 #include "tst_test.h"
 #include "tst_safe_macros.h"
+#include "tst_mallinfo.h"
 
 #ifdef HAVE_MALLOPT
 
@@ -23,21 +22,6 @@ 
 
 struct mallinfo info;
 
-void print_mallinfo(void)
-{
-	tst_res(TINFO, "mallinfo structure:");
-	tst_res(TINFO, "mallinfo.arena = %d", info.arena);
-	tst_res(TINFO, "mallinfo.ordblks = %d", info.ordblks);
-	tst_res(TINFO, "mallinfo.smblks = %d", info.smblks);
-	tst_res(TINFO, "mallinfo.hblkhd = %d", info.hblkhd);
-	tst_res(TINFO, "mallinfo.hblks = %d", info.hblks);
-	tst_res(TINFO, "mallinfo.usmblks = %d", info.usmblks);
-	tst_res(TINFO, "mallinfo.fsmblks = %d", info.fsmblks);
-	tst_res(TINFO, "mallinfo.uordblks = %d", info.uordblks);
-	tst_res(TINFO, "mallinfo.fordblks = %d", info.fordblks);
-	tst_res(TINFO, "mallinfo.keepcost = %d", info.keepcost);
-}
-
 void test_mallopt(void)
 {
 	char *buf;
@@ -46,11 +30,11 @@  void test_mallopt(void)
 
 	info = mallinfo();
 	if (info.uordblks < 20480) {
-		print_mallinfo();
+		tst_print_mallinfo("Test uordblks", &info);
 		tst_res(TFAIL, "mallinfo() failed: uordblks < 20K");
 	}
 	if (info.smblks != 0) {
-		print_mallinfo();
+		tst_print_mallinfo("Test smblks", &info);
 		tst_res(TFAIL, "mallinfo() failed: smblks != 0");
 	}
 	if (info.uordblks >= 20480 && info.smblks == 0)