[LTP] [PATCH 05/13]Add some preprocessor variables

tangchen
2011-01-06T11:00:18Z

KSM is not supported on RHEL5.

Signed-off-by: Tang Chen <tangchen@cn.fujitsu.com>
---
testcases/kernel/mem/ksm/ksm01.c | 18 +++++++++++++++---
testcases/kernel/syscalls/mmap/mmap10.c | 6 +++++-
2 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/testcases/kernel/mem/ksm/ksm01.c
b/testcases/kernel/mem/ksm/ksm01.c
index 09f71d7..2b10fef 100644
--- a/testcases/kernel/mem/ksm/ksm01.c
+++ b/testcases/kernel/mem/ksm/ksm01.c
@@ -70,11 +70,15 @@
#include "test.h"
#include "usctest.h"

-#define _PATH_KSM "/sys/kernel/mm/ksm/"
-#define MB (1024 * 1024)

char *TCID = "ksm01";
int TST_TOTAL = 1;
+
+#ifdef MADV_MERGEABLE
+
+#define _PATH_KSM "/sys/kernel/mm/ksm/"
+#define MB (1024 * 1024)
+
static int opt_num, opt_size;
static char *opt_numstr, *opt_sizestr;
/* memory pointer to identify per process, MB, and byte like
@@ -536,4 +540,12 @@ void group_check(int run, int pages_shared, int
pages_sharing,
check("pages_unshared", NULL, pages_unshared);
check("sleep_millisecs", NULL, sleep_millisecs);
check("pages_to_scan", NULL, pages_to_scan);
-}
\ No newline at end of file
+}
+
+#else
+int main(int argc, char *argv[])
+{
+ tst_brkm(TRETR, tst_exit, "KSM is unsupported");
+}
+#endif
+
diff --git a/testcases/kernel/syscalls/mmap/mmap10.c
b/testcases/kernel/syscalls/mmap/mmap10.c
index b31975e..e3a158e 100644
--- a/testcases/kernel/syscalls/mmap/mmap10.c
+++ b/testcases/kernel/syscalls/mmap/mmap10.c
@@ -115,9 +115,13 @@ void mmapzero(void)
if (x == MAP_FAILED)
tst_brkm(TBROK|TERRNO, cleanup, "mmap");
if (opt_ksm) {
+#ifdef MADV_MERGEABLE
tst_resm(TINFO, "add to KSM regions.");
if (madvise(x, SIZE+SIZE-4096, MADV_MERGEABLE) == -1)
tst_brkm(TBROK|TERRNO, cleanup, "madvise");
+#else
+ tst_brkm(TRETR, cleanup, "KSM is unsupported.");
+#endif
}
x[SIZE] = 0;

@@ -175,4 +179,4 @@ void help(void)
{
printf(" -a Test anonymous pages\n");
printf(" -s Add to KSM regions\n");
-}
\ No newline at end of file
+}
--
1.7.0.4

--
Best Regards,
Tang chen