[LTP] [PATCH] memcg_conctrol_test: fix if CONFIG_SWAP=n

Joerg Vehlow lkml@jv-coder.de
Wed Nov 23 16:01:04 CET 2022


From: Joerg Vehlow <joerg.vehlow@aox.de>

This allows the test to run successfully on systems without swap enabled
It restores the behaviour of the test before
a77b65bbe ("controllers: Update memcg_control_test to newer test lib and cgroup lib")

Signed-off-by: Joerg Vehlow <joerg.vehlow@aox.de>
---
 .../kernel/controllers/memcg/control/memcg_control_test.sh  | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/testcases/kernel/controllers/memcg/control/memcg_control_test.sh b/testcases/kernel/controllers/memcg/control/memcg_control_test.sh
index 093d50c2a..941d918fc 100644
--- a/testcases/kernel/controllers/memcg/control/memcg_control_test.sh
+++ b/testcases/kernel/controllers/memcg/control/memcg_control_test.sh
@@ -47,7 +47,11 @@ test1()
 	tst_res TINFO "Test #1: Checking if the memory usage limit imposed by the topmost group is enforced"
 
 	ROD echo "$ACTIVE_MEM_LIMIT" \> "$test_dir/$memory_limit"
-	ROD echo "$TOT_MEM_LIMIT" \> "$test_dir/$memsw_memory_limit"
+	
+	# If the kernel is built without swap, the $memsw_memory_limit file is missing
+	if [ -e "$test_dir/$memsw_memory_limit" ]; then
+		ROD echo "$TOT_MEM_LIMIT" \> "$test_dir/$memsw_memory_limit"
+	fi
 
 	KILLED_CNT=0
 	test_proc_kill
-- 
2.25.1



More information about the ltp mailing list