[LTP] [PATCH v2 1/3] swapping01: skip test if zram-swap is being used

Cyril Hrubis chrubis@suse.cz
Fri Dec 10 12:52:19 CET 2021


Hi!
> diff --git a/testcases/kernel/mem/swapping/swapping01.c b/testcases/kernel/mem/swapping/swapping01.c
> index 392b79d65..aef47e9a4 100644
> --- a/testcases/kernel/mem/swapping/swapping01.c
> +++ b/testcases/kernel/mem/swapping/swapping01.c
> @@ -40,10 +40,10 @@
>  
>  #include <sys/types.h>
>  #include <sys/wait.h>
> -#include <stdio.h>
>  #include <stdlib.h>
>  #include <string.h>
>  #include <unistd.h>
> +#include "tst_safe_stdio.h"
>  #include "lapi/abisize.h"
>  #include "mem.h"
>  
> @@ -67,6 +67,14 @@ static void test_swapping(void)
>  #ifdef TST_ABI32
>  	tst_brk(TCONF, "test is not designed for 32-bit system.");
>  #endif
> +	FILE *file;
> +	char line[PATH_MAX];
> +
> +	file = SAFE_FOPEN("/proc/swaps", "r");
> +	while (fgets(line, sizeof(line), file)) {
> +		if (strstr(line, "/dev/zram"))
> +			tst_brk(TCONF, "zram-swap is being used!");
> +	}

Actually please add SAFE_FCLOSE(file) here, but otherwise Reviewed...

>  	init_meminfo();
>  
> -- 
> 2.23.0
> 
> 
> -- 
> Mailing list info: https://lists.linux.it/listinfo/ltp

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list