[LTP] [PATCH v1] zram03: unload zram when it is loaded during test run

Xiao Liang xiliang@redhat.com
Mon Sep 5 09:43:30 CEST 2022


Signed-off-by: Xiao Liang <xiliang@redhat.com>
---
 testcases/kernel/device-drivers/zram/zram03.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/testcases/kernel/device-drivers/zram/zram03.c b/testcases/kernel/device-drivers/zram/zram03.c
index b9867a573..98eb61e1c 100644
--- a/testcases/kernel/device-drivers/zram/zram03.c
+++ b/testcases/kernel/device-drivers/zram/zram03.c
@@ -187,16 +187,15 @@ static void setup(void)
 
 	 /* zram module was built in or being used on old kernel */
 	SAFE_CMD(cmd_modprobe, NULL, NULL);
-	if (access(ZRAM_CONTROL_PATH, F_OK)) {
-		file = SAFE_FOPEN("/proc/modules", "r");
-		while (fgets(line, sizeof(line), file)) {
-			if (strstr(line, "zram")) {
-				modprobe = 1;
-				break;
-			}
+	file = SAFE_FOPEN("/proc/modules", "r");
+	while (fgets(line, sizeof(line), file)) {
+		if (strstr(line, "zram")) {
+			modprobe = 1;
+			break;
 		}
-		SAFE_FCLOSE(file);
-
+	}
+	SAFE_FCLOSE(file);
+	if (access(ZRAM_CONTROL_PATH, F_OK)) {
 		if (modprobe) {
 			tst_res(TINFO,
 				"rmmod zram before test on old kernel without zram-control interface");
-- 
2.37.2



More information about the ltp mailing list