This library includes a set of functions used to mount hugetlbfs automatically 
when doing the hugemmap tests.

Signed-off-by: Tang Chen <[email protected]>
---
 testcases/kernel/mem/hugetlb/hugemmap/Makefile |    6 ++-
 testcases/kernel/mem/hugetlb/hugemmap/libmnt.c |   58 ++++++++++++++++++++++++
 testcases/kernel/mem/hugetlb/hugemmap/libmnt.h |   25 ++++++++++
 3 files changed, 88 insertions(+), 1 deletions(-)
 create mode 100644 testcases/kernel/mem/hugetlb/hugemmap/libmnt.c
 create mode 100644 testcases/kernel/mem/hugetlb/hugemmap/libmnt.h

diff --git a/testcases/kernel/mem/hugetlb/hugemmap/Makefile 
b/testcases/kernel/mem/hugetlb/hugemmap/Makefile
index a1ba46e..e6ba4fe 100644
--- a/testcases/kernel/mem/hugetlb/hugemmap/Makefile
+++ b/testcases/kernel/mem/hugetlb/hugemmap/Makefile
@@ -23,5 +23,9 @@
 top_srcdir              ?= ../../../../..
 
 include $(top_srcdir)/include/mk/testcases.mk
-include $(abs_srcdir)/../Makefile.inc
+
+MAKE_TARGETS   := $(filter-out libmnt,$(patsubst 
$(abs_srcdir)/%.c,%,$(wildcard $(abs_srcdir)/*.c)))
+
+$(MAKE_TARGETS): %: %.o libmnt.o
+
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/mem/hugetlb/hugemmap/libmnt.c 
b/testcases/kernel/mem/hugetlb/hugemmap/libmnt.c
new file mode 100644
index 0000000..bf6f857
--- /dev/null
+++ b/testcases/kernel/mem/hugetlb/hugemmap/libmnt.c
@@ -0,0 +1,58 @@
+/*
+ *
+ *   Copyright (c) Fujitsu Corp., 2011
+ *
+ *   This program is free software;  you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or
+ *   (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY;  without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
+ *   the GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program;  if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/mount.h>
+#include <errno.h>
+
+#include "test.h"
+#include "libmnt.h"
+
+void
+hugepage_alloc(int num)
+{
+       FILE *file = fopen("/proc/sys/vm/nr_hugepages", "w+");
+       if (file == NULL) {
+               tst_brkm(TBROK|TERRNO, NULL, 
+                       "fopen failed on /proc/sys/vm/nr_hugepages");
+       }
+
+       if (fprintf(file, "%d", num) < 0) {
+               tst_brkm(TBROK|TERRNO, NULL, 
+                       "fprintf failed on /proc/sys/vm/nr_hugepages");
+       }
+
+       fclose(file);
+}
+
+void
+mount_hugetlbfs(char *mount_point)
+{
+       if (mount("none", mount_point, "hugetlbfs", 0, NULL) < 0) {
+               tst_brkm(TBROK|TERRNO, NULL, 
+                       "mount failed on %s", mount_point);
+       }
+}
+
+void
+umount_hugetlbfs(char *mount_point)
+{
+       umount(mount_point);
+}
diff --git a/testcases/kernel/mem/hugetlb/hugemmap/libmnt.h 
b/testcases/kernel/mem/hugetlb/hugemmap/libmnt.h
new file mode 100644
index 0000000..dc1ceed
--- /dev/null
+++ b/testcases/kernel/mem/hugetlb/hugemmap/libmnt.h
@@ -0,0 +1,25 @@
+/*
+ *   Copyright (c) Fujitsu  Corp., 2011
+ *
+ *   This program is free software;  you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or
+ *   (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY;  without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
+ *   the GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program;  if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+/*
+ *   libmnt.h - functions to mount hugetlbfs automatically.
+ */
+
+void hugepage_alloc(int num);
+void mount_hugetlbfs(char *mount_point);
+void umount_hugetlbfs(char *mount_point);
-- 
1.7.1

-- 
Best Regards,
Tang chen
>From 0cfe5ffb0f63ef18387d9414a4a7cfa554739a80 Mon Sep 17 00:00:00 2001
From: Tang Chen <[email protected]>
Date: Tue, 16 Aug 2011 14:19:45 +0800
Subject: [PATCH 2/6] A library used to mount hugetlbfs automatically.

This library includes a set of functions used to mount hugetlbfs automatically 
when doing the hugemmap tests.

Signed-off-by: Tang Chen <[email protected]>
---
 testcases/kernel/mem/hugetlb/hugemmap/Makefile |    6 ++-
 testcases/kernel/mem/hugetlb/hugemmap/libmnt.c |   58 ++++++++++++++++++++++++
 testcases/kernel/mem/hugetlb/hugemmap/libmnt.h |   25 ++++++++++
 3 files changed, 88 insertions(+), 1 deletions(-)
 create mode 100644 testcases/kernel/mem/hugetlb/hugemmap/libmnt.c
 create mode 100644 testcases/kernel/mem/hugetlb/hugemmap/libmnt.h

diff --git a/testcases/kernel/mem/hugetlb/hugemmap/Makefile 
b/testcases/kernel/mem/hugetlb/hugemmap/Makefile
index a1ba46e..e6ba4fe 100644
--- a/testcases/kernel/mem/hugetlb/hugemmap/Makefile
+++ b/testcases/kernel/mem/hugetlb/hugemmap/Makefile
@@ -23,5 +23,9 @@
 top_srcdir              ?= ../../../../..
 
 include $(top_srcdir)/include/mk/testcases.mk
-include $(abs_srcdir)/../Makefile.inc
+
+MAKE_TARGETS   := $(filter-out libmnt,$(patsubst 
$(abs_srcdir)/%.c,%,$(wildcard $(abs_srcdir)/*.c)))
+
+$(MAKE_TARGETS): %: %.o libmnt.o
+
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/mem/hugetlb/hugemmap/libmnt.c 
b/testcases/kernel/mem/hugetlb/hugemmap/libmnt.c
new file mode 100644
index 0000000..bf6f857
--- /dev/null
+++ b/testcases/kernel/mem/hugetlb/hugemmap/libmnt.c
@@ -0,0 +1,58 @@
+/*
+ *
+ *   Copyright (c) Fujitsu Corp., 2011
+ *
+ *   This program is free software;  you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or
+ *   (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY;  without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
+ *   the GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program;  if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/mount.h>
+#include <errno.h>
+
+#include "test.h"
+#include "libmnt.h"
+
+void
+hugepage_alloc(int num)
+{
+       FILE *file = fopen("/proc/sys/vm/nr_hugepages", "w+");
+       if (file == NULL) {
+               tst_brkm(TBROK|TERRNO, NULL, 
+                       "fopen failed on /proc/sys/vm/nr_hugepages");
+       }
+
+       if (fprintf(file, "%d", num) < 0) {
+               tst_brkm(TBROK|TERRNO, NULL, 
+                       "fprintf failed on /proc/sys/vm/nr_hugepages");
+       }
+
+       fclose(file);
+}
+
+void
+mount_hugetlbfs(char *mount_point)
+{
+       if (mount("none", mount_point, "hugetlbfs", 0, NULL) < 0) {
+               tst_brkm(TBROK|TERRNO, NULL, 
+                       "mount failed on %s", mount_point);
+       }
+}
+
+void
+umount_hugetlbfs(char *mount_point)
+{
+       umount(mount_point);
+}
diff --git a/testcases/kernel/mem/hugetlb/hugemmap/libmnt.h 
b/testcases/kernel/mem/hugetlb/hugemmap/libmnt.h
new file mode 100644
index 0000000..dc1ceed
--- /dev/null
+++ b/testcases/kernel/mem/hugetlb/hugemmap/libmnt.h
@@ -0,0 +1,25 @@
+/*
+ *   Copyright (c) Fujitsu  Corp., 2011
+ *
+ *   This program is free software;  you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or
+ *   (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY;  without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
+ *   the GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program;  if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+/*
+ *   libmnt.h - functions to mount hugetlbfs automatically.
+ */
+
+void hugepage_alloc(int num);
+void mount_hugetlbfs(char *mount_point);
+void umount_hugetlbfs(char *mount_point);
-- 
1.7.1

------------------------------------------------------------------------------
uberSVN's rich system and user administration capabilities and model 
configuration take the hassle out of deploying and managing Subversion and 
the tools developers use with it. Learn more about uberSVN and get a free 
download at:  http://p.sf.net/sfu/wandisco-dev2dev
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to