All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH v5 1/4] swapping01: skip test if zram-swap is being used
@ 2021-12-20  6:52 Yang Xu
  2021-12-20  6:52 ` [LTP] [PATCH v5 2/4] zram/zram_lib.sh: adapt the situation that zram device " Yang Xu
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Yang Xu @ 2021-12-20  6:52 UTC (permalink / raw)
  To: ltp

For the swapping test we attempt to allocate 130% of the available RAM and
we make sure that the overflow would fit the swap, but as long as swap is
backed by RAM this obviously false. So skip it if zram-swap is being used.

Also make check happy.

Fixes: #888
Reviewed-by: Petr Vorel <pvorel@suse.cz>
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
---
 testcases/kernel/mem/swapping/swapping01.c | 25 ++++++++++++++++------
 1 file changed, 18 insertions(+), 7 deletions(-)

diff --git a/testcases/kernel/mem/swapping/swapping01.c b/testcases/kernel/mem/swapping/swapping01.c
index 392b79d65..498f502c1 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,16 +67,27 @@ 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")) {
+			SAFE_FCLOSE(file);
+			tst_brk(TCONF, "zram-swap is being used!");
+		}
+	}
+	SAFE_FCLOSE(file);
 
 	init_meminfo();
 
 	switch (pid = SAFE_FORK()) {
-		case 0:
-			do_alloc(0);
-			do_alloc(1);
-			exit(0);
-		default:
-			check_swapping();
+	case 0:
+		do_alloc(0);
+		do_alloc(1);
+		exit(0);
+	default:
+		check_swapping();
 	}
 }
 
-- 
2.23.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2021-12-22 14:12 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-20  6:52 [LTP] [PATCH v5 1/4] swapping01: skip test if zram-swap is being used Yang Xu
2021-12-20  6:52 ` [LTP] [PATCH v5 2/4] zram/zram_lib.sh: adapt the situation that zram device " Yang Xu
2021-12-20 10:45   ` Petr Vorel
2021-12-21  1:33     ` xuyang2018.jy
2021-12-20  6:52 ` [LTP] [PATCH v5 3/4] zram/zram03: Convert into new api Yang Xu
2021-12-20  6:52 ` [LTP] [PATCH v5 4/4] zram/zram01.sh: replacing data stored in this disk with allocated for this disk Yang Xu
2021-12-20 10:49   ` Petr Vorel
2021-12-21  2:18     ` xuyang2018.jy
2021-12-21  8:41       ` Petr Vorel
2021-12-22  9:33         ` xuyang2018.jy
2021-12-22 14:12           ` Petr Vorel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.