From 4d9d53698f43d54f4bc8d4d455a748e13d55e83a Mon Sep 17 00:00:00 2001 From: Wang Yuting Date: Tue, 28 Jun 2022 21:18:15 +0800 Subject: [PATCH] fix mem_debug08.sh Dynamically get all processes that own ashmem and check Signed-off-by: Wang Yuting --- .../mem_debug_t/testcases/bin/mem_debug08.sh | 28 +++++++++++++++++-- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/test/moduletest/runtest/bin/mem_debug_t/testcases/bin/mem_debug08.sh b/test/moduletest/runtest/bin/mem_debug_t/testcases/bin/mem_debug08.sh index d3a3dc3..f20b0c9 100644 --- a/test/moduletest/runtest/bin/mem_debug_t/testcases/bin/mem_debug08.sh +++ b/test/moduletest/runtest/bin/mem_debug_t/testcases/bin/mem_debug08.sh @@ -33,13 +33,35 @@ do_setup() do_test() { - local pid=$(ps -ef | grep "com.ohos.launch" | grep -v grep | awk '{print $2}') + # find ashmem process + local pid=$(cat /proc/ashmem_process_info | awk 'NR>3 && $2!="" {print $2}' | sort -u) + local line=$(cat /proc/ashmem_process_info | awk 'NR>3 && $2!="" {print $2}' | sort -u | wc -l) + if [ $line -eq 0 ]; then + tst_res TFAIL "Cannot find program with ashmen!" + else + tst_res TPASS "The following $line ashmem processes have been found(PID): $pid." + fi + + # Confirm that each process ashmem information is correct + for p in $pid + do + tst_res TINFO "now going to check $p ashmem information" + ash_info_check $p + done + +} + +ash_info_check() +{ + local pid=$1 + tst_res TINFO "pid is $pid ." + local ashmem_info_lines=$(cat /proc/$pid/smaps | grep ashmem | wc -l) if [ $ashmem_info_lines -le 0 ]; then - tst_res TFAIL "Ashmem information display test failed!" + tst_res TFAIL "Cannot find ashmem information of $pid .Ashmem information display test failed!" else - tst_res TPASS "Ashmem information display test pass." + tst_res TPASS "$pid totally found $ashmem_info_lines ashmem messages.Ashmem information display test pass." fi } -- Gitee