Hi,
 
Please ignore this patch. I do something wrong, thanks.

Regards,
Xiaoguang Wang


On 02/25/2014 11:09 AM, Xiaoguang Wang wrote:
> From: Xiaoguang Wang <[email protected]>
>
> Signed-off-by: Xiaoguang Wang <[email protected]>
> ---
>  testcases/kernel/syscalls/madvise/madvise02.c | 38 
> ++++++++++++++++++++++++---
>  1 file changed, 34 insertions(+), 4 deletions(-)
>
> diff --git a/testcases/kernel/syscalls/madvise/madvise02.c 
> b/testcases/kernel/syscalls/madvise/madvise02.c
> index e7f4656..08ed717 100644
> --- a/testcases/kernel/syscalls/madvise/madvise02.c
> +++ b/testcases/kernel/syscalls/madvise/madvise02.c
> @@ -27,6 +27,8 @@
>   *  2. advice is not a valid value
>   *  3. application is attempting to release
>   *     locked or shared pages (with MADV_DONTNEED)
> + *  4. MADV_MERGEABLE or MADV_UNMERGEABLE was specified in advice,
> + *     but kernel was not configured with CONFIG_KSM
>   *
>   * (B) Test Case for ENOMEM
>   *  4. addresses in the specified range are not currently mapped
> @@ -52,9 +54,14 @@
>  #include "usctest.h"
>  
>  #define MM_RLIMIT_RSS 5
> +/*
> + * when kernel is 2.6.32 or newer and /sys/kernel/mm/ksm is exist,
> + * we think kernel was configured with CONFIG_KSM.
> + */
> +#define KSM_SYS_DIR  "/sys/kernel/mm/ksm"
>  
>  char *TCID = "madvise02";
> -int TST_TOTAL = 7;
> +int TST_TOTAL = 8;
>  
>  static void setup(void);
>  static void cleanup(void);
> @@ -128,11 +135,34 @@ int main(int argc, char *argv[])
>               TEST(madvise(file, stat.st_size, MADV_DONTNEED));
>               check_and_print(EINVAL);
>  
> -             if (munmap(file, stat.st_size) == -1)
> -                     tst_brkm(TBROK | TERRNO, cleanup, "munmap failed");
>  #endif /* if !defined(UCLINUX) */
>  
> +#if defined(MADV_MERGEABLE) && defined(MADV_UNMERGEABLE)
>               /* Test Case 4 */
> +             if (tst_kvercmp(2, 6, 32) < 0) {
> +                     tst_resm(TCONF, "kernel samepage merging (KSM) needs "
> +                              "2.6.32 or higher, skip EINVAL test for "
> +                              "MADV_MERGEABLE and MADV_UNMERGEABLE.");
> +             } else {
> +                     if (access(KSM_SYS_DIR, F_OK) < 0) {
> +                             tst_resm(TINFO, "kernel was not configured "
> +                                      "with CONFIG_KSM");
> +
> +                             TEST(madvise(file, stat.st_size,
> +                                  MADV_MERGEABLE));
> +                             check_and_print(EINVAL);
> +
> +                             TEST(madvise(file, stat.st_size,
> +                                  MADV_UNMERGEABLE));
> +                             check_and_print(EINVAL);
> +                     }
> +             }
> +#endif
> +
> +             if (munmap(file, stat.st_size) == -1)
> +                     tst_brkm(TBROK | TERRNO, cleanup, "munmap failed");
> +
> +             /* Test Case 5 */
>  
>               /* We cannot be sure, which region is mapped, which is
>                * not, at runtime.
> @@ -169,7 +199,7 @@ int main(int argc, char *argv[])
>               TEST(madvise(low, len, MADV_NORMAL));
>               check_and_print(ENOMEM);
>  
> -             /* Test Case 5 */
> +             /* Test Case 6 */
>               /* Unmap the file map from low */
>               if (munmap(low, stat.st_size / 2) < 0)
>                       tst_brkm(TBROK | TERRNO, cleanup,


------------------------------------------------------------------------------
Flow-based real-time traffic analytics software. Cisco certified tool.
Monitor traffic, SLAs, QoS, Medianet, WAAS etc. with NetFlow Analyzer
Customize your own dashboards, set traffic alerts and generate reports.
Network behavioral analysis & security monitoring. All-in-one tool.
http://pubads.g.doubleclick.net/gampad/clk?id=126839071&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to