When i build the LTP at RHEL5.5GA, the following error was caught.

make[4]: Entering directory 
`/home/biannm/gitsrc/ltp-dev/testcases/kernel/syscalls/mmap'
gcc -g -O2 -g -O2 -fno-strict-aliasing -pipe -Wall  
-I/home/biannm/gitsrc/ltp-dev/testcases/kernel/include -I../../../../include 
-I../../../../include   -L../../../../lib  mmap10.c   -lltp -lpthread -o mmap10
mmap10.c: In function ‘mmapzero’:
mmap10.c:120: error: ‘MADV_MERGEABLE’ undeclared (first use in this function)
mmap10.c:120: error: (Each undeclared identifier is reported only once
mmap10.c:120: error: for each function it appears in.)
make[4]: *** [mmap10] Error 1

So, what about this patch?
---------------------------------------------------------------------

KSM is unsupported before 2.6.32. So if MADV_MERGEABLE is undefine,
we should not test the following cases.

1. mmap10 with the option "-s".
2. ksm01.

Signed-off-by: Bian Naimeng <[email protected]>

---
 testcases/kernel/mem/ksm/ksm01.c        |   15 ++++++++++++---
 testcases/kernel/syscalls/mmap/mmap10.c |    4 ++++
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/testcases/kernel/mem/ksm/ksm01.c b/testcases/kernel/mem/ksm/ksm01.c
index 1143791..9b575ff 100644
--- a/testcases/kernel/mem/ksm/ksm01.c
+++ b/testcases/kernel/mem/ksm/ksm01.c
@@ -70,12 +70,14 @@
 #include "test.h"
 #include "usctest.h"
 
-#define _PATH_KSM      "/sys/kernel/mm/ksm/"
-#define MB             (1024 * 1024)
-
 char *TCID = "ksm01";
 int TST_TOTAL = 1;
 extern int Tst_count;
+
+#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
@@ -538,3 +540,10 @@ void group_check(int run, int pages_shared, int 
pages_sharing,
        check("sleep_millisecs", NULL, sleep_millisecs);
        check("pages_to_scan", NULL, pages_to_scan);
 }
+
+#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 fe9d622..be988cf 100644
--- a/testcases/kernel/syscalls/mmap/mmap10.c
+++ b/testcases/kernel/syscalls/mmap/mmap10.c
@@ -116,9 +116,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;
 
-- 
1.7.0.4




-- 
Regards
Bian Naimeng


------------------------------------------------------------------------------
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to