[LTP] [RFC PATCH 05/13] mem/hugetlb: convert to new API

Li Wang liwang@redhat.com
Tue Mar 28 05:22:31 CEST 2017


Signed-off-by: Li Wang <liwang@redhat.com>
---
 testcases/kernel/mem/hugetlb/lib/hugetlb.c | 19 ++++++++++---------
 testcases/kernel/mem/hugetlb/lib/hugetlb.h |  9 +++++----
 2 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/testcases/kernel/mem/hugetlb/lib/hugetlb.c b/testcases/kernel/mem/hugetlb/lib/hugetlb.c
index 4a9d489..7afc7d4 100644
--- a/testcases/kernel/mem/hugetlb/lib/hugetlb.c
+++ b/testcases/kernel/mem/hugetlb/lib/hugetlb.c
@@ -32,6 +32,7 @@
  *	rm_shm()
  */
 
+#define TST_NO_DEFAULT_MAIN
 #include <sys/types.h>
 #include <sys/ipc.h>
 #include <sys/shm.h>
@@ -42,14 +43,14 @@
 void check_hugepage(void)
 {
 	if (access(PATH_HUGEPAGES, F_OK))
-		tst_brkm(TCONF, NULL, "Huge page is not supported.");
+		tst_brk(TCONF, "Huge page is not supported.");
 }
 
 /*
  * getipckey() - generates and returns a message key used by the "get"
  *		 calls to create an IPC resource.
  */
-int getipckey(void (*cleanup_fn) (void))
+int getipckey(void)
 {
 	const char a = 'a';
 	int ascii_a = (int)a;
@@ -60,7 +61,7 @@ int getipckey(void (*cleanup_fn) (void))
 
 	curdir = getcwd(curdir, size);
 	if (curdir == NULL)
-		tst_brkm(TBROK | TERRNO, cleanup_fn, "getcwd(curdir)");
+		tst_brk(TBROK | TERRNO, "getcwd(curdir)");
 
 	/*
 	 * Get a Sys V IPC key
@@ -79,7 +80,7 @@ int getipckey(void (*cleanup_fn) (void))
 
 	ipc_key = ftok(curdir, ascii_a + random() % 26);
 	if (ipc_key == -1)
-		tst_brkm(TBROK | TERRNO, cleanup_fn, "ftok");
+		tst_brk(TBROK | TERRNO, __func__);
 
 	return ipc_key;
 }
@@ -87,13 +88,13 @@ int getipckey(void (*cleanup_fn) (void))
 /*
  * getuserid() - return the integer value for the "user" id
  */
-int getuserid(void (*cleanup_fn) (void), char *user)
+int getuserid(char *user)
 {
 	struct passwd *ent;
 
 	ent = getpwnam(user);
 	if (ent == NULL)
-		tst_brkm(TBROK | TERRNO, cleanup_fn, "getpwnam");
+		tst_brk(TBROK | TERRNO, "getpwnam");
 
 	return ent->pw_uid;
 }
@@ -110,8 +111,8 @@ void rm_shm(int shm_id)
 	 * check for # of attaches ?
 	 */
 	if (shmctl(shm_id, IPC_RMID, NULL) == -1) {
-		tst_resm(TINFO, "WARNING: shared memory deletion failed.");
-		tst_resm(TINFO, "This could lead to IPC resource problems.");
-		tst_resm(TINFO, "id = %d", shm_id);
+		tst_res(TINFO, "WARNING: shared memory deletion failed.");
+		tst_res(TINFO, "This could lead to IPC resource problems.");
+		tst_res(TINFO, "id = %d", shm_id);
 	}
 }
diff --git a/testcases/kernel/mem/hugetlb/lib/hugetlb.h b/testcases/kernel/mem/hugetlb/lib/hugetlb.h
index 6b5c61e..1b5cc73 100644
--- a/testcases/kernel/mem/hugetlb/lib/hugetlb.h
+++ b/testcases/kernel/mem/hugetlb/lib/hugetlb.h
@@ -24,11 +24,12 @@
 #ifndef __HUGETLB_H
 #define __HUGETLB_H
 
+#include <stdlib.h>
 #include <sys/ipc.h>
 #include <sys/shm.h>
 #include <errno.h>
 #include <sys/wait.h>
-#include "test.h"
+#include "tst_test.h"
 
 #define SHM_RD	0400
 #define SHM_WR	0200
@@ -49,12 +50,12 @@ key_t shmkey;			/* an IPC key generated by ftok() */
 
 void check_hugepage(void);
 
-int getipckey(void (*cleanup_fn) (void));
-int getuserid(void (*cleanup_fn) (void), char *user);
+int getipckey(void);
+int getuserid(char *user);
 void rm_shm(int shm_id);
 
 char *nr_opt;
-int sflag;
+char *Hopt;
 long orig_hugepages;
 
 #endif /* hugetlb.h */
-- 
2.9.3



More information about the ltp mailing list