From de89f6c752909925ef6fa75eac5b39471e38947d Mon Sep 17 00:00:00 2001 From: Wang Yuting Date: Fri, 27 May 2022 17:53:53 +0800 Subject: [PATCH] test: add memory debug testsuite Signed-off-by: Wang Yuting --- .../mem_debug_t/testcases/bin/mem_debug01.sh | 53 +++++++++ .../mem_debug_t/testcases/bin/mem_debug02.sh | 66 +++++++++++ .../mem_debug_t/testcases/bin/mem_debug03.sh | 56 +++++++++ .../mem_debug_t/testcases/bin/mem_debug04.sh | 101 +++++++++++++++++ .../mem_debug_t/testcases/bin/mem_debug05.sh | 106 ++++++++++++++++++ .../mem_debug_t/testcases/bin/mem_debug06.sh | 55 +++++++++ .../mem_debug_t/testcases/bin/mem_debug07.sh | 72 ++++++++++++ .../mem_debug_t/testcases/bin/mem_debug08.sh | 54 +++++++++ .../mem_debug_t/testcases/bin/mem_debug09.sh | 73 ++++++++++++ .../mem_debug_t/testcases/bin/mem_debug10.sh | 78 +++++++++++++ .../runtest/bin/mem_debug_t_init.sh | 73 ++++++++++++ .../runtest/bin/mem_debug_t_uninit.sh | 43 +++++++ test/moduletest/runtest/conf/OH_RK3568_config | 1 + test/moduletest/runtest/tests/mem_debug_t | 35 ++++++ 14 files changed, 866 insertions(+) create mode 100644 test/moduletest/runtest/bin/mem_debug_t/testcases/bin/mem_debug01.sh create mode 100644 test/moduletest/runtest/bin/mem_debug_t/testcases/bin/mem_debug02.sh create mode 100644 test/moduletest/runtest/bin/mem_debug_t/testcases/bin/mem_debug03.sh create mode 100644 test/moduletest/runtest/bin/mem_debug_t/testcases/bin/mem_debug04.sh create mode 100644 test/moduletest/runtest/bin/mem_debug_t/testcases/bin/mem_debug05.sh create mode 100644 test/moduletest/runtest/bin/mem_debug_t/testcases/bin/mem_debug06.sh create mode 100644 test/moduletest/runtest/bin/mem_debug_t/testcases/bin/mem_debug07.sh create mode 100644 test/moduletest/runtest/bin/mem_debug_t/testcases/bin/mem_debug08.sh create mode 100644 test/moduletest/runtest/bin/mem_debug_t/testcases/bin/mem_debug09.sh create mode 100644 test/moduletest/runtest/bin/mem_debug_t/testcases/bin/mem_debug10.sh create mode 100644 test/moduletest/runtest/bin/mem_debug_t_init.sh create mode 100644 test/moduletest/runtest/bin/mem_debug_t_uninit.sh create mode 100644 test/moduletest/runtest/tests/mem_debug_t diff --git a/test/moduletest/runtest/bin/mem_debug_t/testcases/bin/mem_debug01.sh b/test/moduletest/runtest/bin/mem_debug_t/testcases/bin/mem_debug01.sh new file mode 100644 index 0000000..7886afe --- /dev/null +++ b/test/moduletest/runtest/bin/mem_debug_t/testcases/bin/mem_debug01.sh @@ -0,0 +1,53 @@ +#!/bin/sh +################################################################################ +# +# Copyright (C) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +################################################################################ +# File: mem_debug01.sh +# +# Description: Static memory reservation query test +# +# Authors: Wangyuting - wangyuting36@huawei.com +# +# History: Mar 19 2022 - init scripts +# +################################################################################ +source tst_oh.sh + +do_setup() +{ + zcat /proc/config.gz | grep CONFIG_DEBUG_FS=y || tst_res TCONF "CONFIG_DEBUG_FS=y not satisfied!" +} + +do_test() +{ + local rmem_lines=$(cat /sys/kernel/debug/dt_reserved_mem/dt_reserved_memory | wc -l) + + if [ $rmem_lines -gt 1 ]; then + tst_res TPASS "Static memory reservation query test pass." + else + tst_res TFAIL "Static memory reservation query test failed!" + fi +} + +do_clean() +{ + +} + +do_setup +do_test +do_clean +tst_exit \ No newline at end of file diff --git a/test/moduletest/runtest/bin/mem_debug_t/testcases/bin/mem_debug02.sh b/test/moduletest/runtest/bin/mem_debug_t/testcases/bin/mem_debug02.sh new file mode 100644 index 0000000..90c7d4c --- /dev/null +++ b/test/moduletest/runtest/bin/mem_debug_t/testcases/bin/mem_debug02.sh @@ -0,0 +1,66 @@ +#!/bin/sh +################################################################################ +# +# Copyright (C) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +################################################################################ +# File: mem_debug02.sh +# +# Description: Sum of static memory excluding cma test +# +# Authors: Wangyuting - wangyuting36@huawei.com +# +# History: Mar 23 2022 - init scripts +# +################################################################################ +source tst_oh.sh + +do_setup() +{ + zcat /proc/config.gz | grep CONFIG_DEBUG_FS=y || tst_res TCONF "CONFIG_DEBUG_FS=y not satisfied!" +} + +do_test() +{ + local code_low_add=$( cat /proc/iomem | grep Kernel | awk '$4=="code"{print $1}' | awk 'BEGIN{FS="-"}{print $1}') + local code_high_add=$( cat /proc/iomem | grep Kernel | awk '$4=="code"{print $1}' | awk 'BEGIN{FS="-"}{print $2}') + local code_size=$((16#$code_high_add - 16#$code_low_add)) + + local data_low_add=$( cat /proc/iomem | grep Kernel | awk '$4=="data"{print $1}' | awk 'BEGIN{FS="-"}{print $1}') + local data_high_add=$( cat /proc/iomem | grep Kernel | awk '$4=="data"{print $1}' | awk 'BEGIN{FS="-"}{print $2}') + local data_size=$((16#$data_high_add - 16#$data_low_add)) + + local kernel_size=$(($code_size + $data_size)) + local ksize_kb=$(($kernel_size / 1024)) + + local memtotal=$(cat /proc/meminfo | awk '$1=="MemTotal:"{print $2}') + local total_size=$(($ksize_kb + $memtotal)) + local maxsize=$((2 * 1024 * 1024)) + + if [ $total_size -le $maxsize ]; then + tst_res TPASS "Sum of static memory excluding cma test pass." + else + tst_res TFAIL "Sum of static memory excluding cma test failed!" + fi +} + +do_clean() +{ + +} + +do_setup +do_test +do_clean +tst_exit \ No newline at end of file diff --git a/test/moduletest/runtest/bin/mem_debug_t/testcases/bin/mem_debug03.sh b/test/moduletest/runtest/bin/mem_debug_t/testcases/bin/mem_debug03.sh new file mode 100644 index 0000000..e12812d --- /dev/null +++ b/test/moduletest/runtest/bin/mem_debug_t/testcases/bin/mem_debug03.sh @@ -0,0 +1,56 @@ +#!/bin/sh +################################################################################ +# +# Copyright (C) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +################################################################################ +# File: mem_debug03.sh +# +# Description: Dmabuf usage of process query test +# +# Authors: Wangyuting - wangyuting36@huawei.com +# +# History: Mar 20 2022 - init scripts +# +################################################################################ +source tst_oh.sh + +do_setup() +{ + zcat /proc/config.gz | grep CONFIG_DMABUF_PROCESS_INFO=y || \ + tst_res TCONF "CONFIG_DMABUF_PROCESS_INFO=y not satisfied!" +} + +do_test() +{ + local result=$(cat /proc/process_dmabuf_info | grep Process | grep pid \ + | grep fd | grep size_bytes | grep ino | grep exp_pid | grep exp_task_comm \ + | grep buf_name | grep exp_name) + + if [ "$result" == "" ]; then + tst_res TFAIL "Dmabuf usage of process query test failed!" + else + tst_res TPASS "Dmabuf usage of process query test pass." + fi +} + +do_clean() +{ + +} + +do_setup +do_test +do_clean +tst_exit \ No newline at end of file diff --git a/test/moduletest/runtest/bin/mem_debug_t/testcases/bin/mem_debug04.sh b/test/moduletest/runtest/bin/mem_debug_t/testcases/bin/mem_debug04.sh new file mode 100644 index 0000000..cdfcb09 --- /dev/null +++ b/test/moduletest/runtest/bin/mem_debug_t/testcases/bin/mem_debug04.sh @@ -0,0 +1,101 @@ +#!/bin/sh +################################################################################ +# +# Copyright (C) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +################################################################################ +# File: mem_debug04.sh +# +# Description: Meminfo's dimension measurement information extension test +# +# Authors: Wangyuting - wangyuting36@huawei.com +# +# History: Mar 20 2022 - init scripts +# +################################################################################ +source tst_oh.sh + +do_setup() +{ + zcat /proc/config.gz | grep CONFIG_PAGE_TRACING=y || tst_res TCONF "ONFIG_PAGE_TRACING=y not satisfied!" + + avail_buffers=/dev/memcg/memory.avail_buffers + + local zswapd_s=/dev/memcg/memory.zswapd_pressure_show + local buffer_size=$(cat $zswapd_s | grep 'buffer_size' | awk -F ':' '{print$2}') + + avail_buffers_def=$(cat /dev/memcg/memory.avail_buffers | awk '$1=="avail_buffers:"{print $2}') + min_avail_buffers_def=$(cat /dev/memcg/memory.avail_buffers | awk '$1=="min_avail_buffers:"{print $2}') + high_avail_buffers_def=$(cat /dev/memcg/memory.avail_buffers | awk '$1=="high_avail_buffers:"{print $2}') + free_swap_threshold_def=$(cat /dev/memcg/memory.avail_buffers | awk '$1=="free_swap_threshold:"{print $2}') + + echo 0 $(( $buffer_size + 50 )) $(( $buffer_size + 100 )) 0 > $avail_buffers + sleep 3 +} + +do_test() +{ + local ret=0 + + sh ../../../mem_debug_t_uninit.sh + local old_vmallocused=$(cat /proc/meminfo | awk '$1=="VmallocUsed:"{print $2}') + local old_zspageused=$(cat /proc/meminfo | awk '$1=="ZspageUsed:"{print $2}') + local old_gltrack=$(cat /proc/meminfo | awk '$1=="GLTrack:"{print $2}') + + sh ../../../mem_debug_t_init.sh + aa start -b com.ohos.settings -a com.ohos.settings.MainAbility + aa start -b ohos.samples.airquality -a ohos.samples.airquality.default + aa start -b ohos.samples.ecg -a ohos.samples.ecg.default + aa start -b ohos.samples.flashlight -a ohos.samples.flashlight.default + aa start -b ohos.samples.clock -a ohos.samples.clock.default + + local new_vmallocused=$(cat /proc/meminfo | awk '$1=="VmallocUsed:"{print $2}') + local new_zspageused=$(cat /proc/meminfo | awk '$1=="ZspageUsed:"{print $2}') + local new_gltrack=$(cat /proc/meminfo | awk '$1=="GLTrack:"{print $2}') + + if [ "$old_gltrack" == "-" ] && [ "$new_gltrack" == "-" ]; then + tst_res TPASS "Gltrack equals '-'" + else + tst_res TFAIL "Gltrack not equals '-'" + ret=$(($ret + 1)) + fi + + local res_vmallocused=$(($new_vmallocused - $old_vmallocused)) + local res_zspageused=$(($new_zspageused - $old_zspageused)) + + if [ $res_vmallocused -le 0 ]; then + tst_res TFAIL "Vmallocused not growing" + ret=$(($ret + 1)) + fi + if [ $res_zspageused -le 0 ]; then + tst_res TFAIL "ZspageUsed not growing" + ret=$(($ret + 1)) + fi + + if [ $ret -eq 0 ]; then + tst_res TPASS "Meminfo's dimension measurement information extension test pass." + else + tst_res TFAIL "Meminfo's dimension measurement information extension test failed!" + fi +} + +do_clean() +{ + echo $avail_buffers_def $min_avail_buffers_def $high_avail_buffers_def $free_swap_threshold_def > $avail_buffers +} + +do_setup +do_test +do_clean +tst_exit \ No newline at end of file diff --git a/test/moduletest/runtest/bin/mem_debug_t/testcases/bin/mem_debug05.sh b/test/moduletest/runtest/bin/mem_debug_t/testcases/bin/mem_debug05.sh new file mode 100644 index 0000000..c900e9a --- /dev/null +++ b/test/moduletest/runtest/bin/mem_debug_t/testcases/bin/mem_debug05.sh @@ -0,0 +1,106 @@ +#!/bin/sh +################################################################################ +# +# Copyright (C) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +################################################################################ +# File: mem_debug05.sh +# +# Description: Dimension measurement information of DR/kswapd/zswapd test +# +# Authors: Wangyuting - wangyuting36@huawei.com +# +# History: Mar 23 2022 - init scripts +# +################################################################################ +source tst_oh.sh + +do_setup() +{ + zcat /proc/config.gz | grep CONFIG_RECLAIM_ACCT=y || tst_res TCONF "CONFIG_RECLAIM_ACCT=y not satisfied!" + + avail_buffers=/dev/memcg/memory.avail_buffers + + local zswapd_s=/dev/memcg/memory.zswapd_pressure_show + local buffer_size=$(cat $zswapd_s | grep 'buffer_size' | awk -F ':' '{print$2}') + + avail_buffers_def=$(cat /dev/memcg/memory.avail_buffers | awk '$1=="avail_buffers:"{print $2}') + min_avail_buffers_def=$(cat /dev/memcg/memory.avail_buffers | awk '$1=="min_avail_buffers:"{print $2}') + high_avail_buffers_def=$(cat /dev/memcg/memory.avail_buffers | awk '$1=="high_avail_buffers:"{print $2}') + free_swap_threshold_def=$(cat /dev/memcg/memory.avail_buffers | awk '$1=="free_swap_threshold:"{print $2}') + + echo 0 $(( $buffer_size + 50 )) $(( $buffer_size + 100 )) 0 > $avail_buffers + sleep 3 +} + +do_test() +{ + local ret=0 + + reclaim_acct_disable="/sys/module/reclaim_acct/parameters/disable" + reclaim_acct_disable_def=$(cat /sys/module/reclaim_acct/parameters/disable) + echo 0 > $reclaim_acct_disable + + wukong exec -s 10 -i 1000 -a 0.28 -t 0.72 -c 1000000 & + sleep 100 + + check_reclaim_efficiency "reclaim" + check_reclaim_efficiency "kswapd" + check_reclaim_efficiency "zswapd" + +} + +check_reclaim_efficiency() +{ + local mem_type=$1 + + local total_process_time=$(cat /proc/reclaim_efficiency | grep -A5 $mem_type | grep total_process | awk '{print $2}') + local drain_pages_time=$(cat /proc/reclaim_efficiency | grep -A5 $mem_type | grep drain_pages | awk '{print $2}') + local shrink_file_time=$(cat /proc/reclaim_efficiency | grep -A5 $mem_type | grep shrink_file | awk '{print $2}') + local shrink_anon_time=$(cat /proc/reclaim_efficiency | grep -A5 $mem_type | grep shrink_anon | awk '{print $2}') + local shrink_slab_time=$(cat /proc/reclaim_efficiency | grep -A5 $mem_type | grep shrink_slab | awk '{print $2}') + local sum_time_a=$(($drain_pages_time + $shrink_file_time)) + local sum_time_b=$(($shrink_anon_time + $shrink_slab_time)) + local sum_time=$(($sum_time_a + $sum_time_b)) + + if [ $sum_time -le $total_process_time ]; then + tst_res TPASS "total_process_time in $mem_type isn't less than sum of subprocess." + else + tst_res TFAIL "total_process_time in $mem_type is less than sum of subprocess." + fi + + local total_process_freed=$(cat /proc/reclaim_efficiency | grep -A5 $mem_type | grep total_process | awk '{print $3}') + local shrink_file_freed=$(cat /proc/reclaim_efficiency | grep -A5 $mem_type | grep shrink_file | awk '{print $3}') + local shrink_anon_freed=$(cat /proc/reclaim_efficiency | grep -A5 $mem_type | grep shrink_anon | awk '{print $3}') + local sum_freed=$(($shrink_file_freed + $shrink_anon_freed)) + + if [ $sum_freed -eq $total_process_freed ]; then + tst_res TPASS "total_process_freed in $mem_type calculate correctly." + else + tst_res TFAIL "total_process_freed in $mem_type calculate incorrectly." + fi +} + +do_clean() +{ + local pid=$(ps -ef | grep wukong | grep -v grep | awk '{print $2}') + kill -9 $pid + echo $reclaim_acct_disable_def > $reclaim_acct_disable + echo $avail_buffers_def $min_avail_buffers_def $high_avail_buffers_def $free_swap_threshold_def > $avail_buffers +} + +do_setup +do_test +do_clean +tst_exit \ No newline at end of file diff --git a/test/moduletest/runtest/bin/mem_debug_t/testcases/bin/mem_debug06.sh b/test/moduletest/runtest/bin/mem_debug_t/testcases/bin/mem_debug06.sh new file mode 100644 index 0000000..562b82e --- /dev/null +++ b/test/moduletest/runtest/bin/mem_debug_t/testcases/bin/mem_debug06.sh @@ -0,0 +1,55 @@ +#!/bin/sh +################################################################################ +# +# Copyright (C) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +################################################################################ +# File: mem_debug06.sh +# +# Description: Default information of lowmem killer debug display test +# +# Authors: Wangyuting - wangyuting36@huawei.com +# +# History: Mar 20 2022 - init scripts +# +################################################################################ +source tst_oh.sh + +do_setup() +{ + zcat /proc/config.gz | grep CONFIG_LOWMEM=y || tst_res TCONF "CONFIG_LOWMEM=y & CONFIG_LMKD_DBG=y not satisfied!" + zcat /proc/config.gz | grep CONFIG_LMKD_DBG=y || tst_res TCONF "CONFIG_LOWMEM=y & CONFIG_LMKD_DBG=y not satisfied!" +} + +do_test() +{ + local lmkd_oom_score_adj=$(cat /proc/lmkd_dbg_trigger | awk 'BEGIN{FS=":"} $1=="lmkd_oom_score_adj"{print $2}') + local lmkd_no_cma_cnt=$(cat /proc/lmkd_dbg_trigger | awk 'BEGIN{FS=":"} $1=="lmkd_no_cma_cnt"{print $2}') + + if [ $lmkd_oom_score_adj -ne 0 ] && [ $lmkd_no_cma_cnt -ne 0 ]; then + tst_res TFAIL "Default information of lowmem killer debug display test failed!" + else + tst_res TPASS "Default information of lowmem killer debug display test pass." + fi +} + +do_clean() +{ + +} + +do_setup +do_test +do_clean +tst_exit \ No newline at end of file diff --git a/test/moduletest/runtest/bin/mem_debug_t/testcases/bin/mem_debug07.sh b/test/moduletest/runtest/bin/mem_debug_t/testcases/bin/mem_debug07.sh new file mode 100644 index 0000000..84a406c --- /dev/null +++ b/test/moduletest/runtest/bin/mem_debug_t/testcases/bin/mem_debug07.sh @@ -0,0 +1,72 @@ +#!/bin/sh +################################################################################ +# +# Copyright (C) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +################################################################################ +# File: mem_debug07.sh +# +# Description: Information of lowmem killer debug display test +# +# Authors: Wangyuting - wangyuting36@huawei.com +# +# History: Mar 23 2022 - init scripts +# +################################################################################ +source tst_oh.sh + +do_setup() +{ + zcat /proc/config.gz | grep CONFIG_LOWMEM=y || tst_res TCONF "CONFIG_LOWMEM=y not satisfied!" + zcat /proc/config.gz | grep CONFIG_LMKD_DBG=y || tst_res TCONF "CONFIG_LMKD_DBG=y not satisfied!" +} + +do_test() +{ + local ret=0 + + lmkd_oom_score_adj_def=$(cat /proc/lmkd_dbg_trigger | awk 'BEGIN{FS=":"} $1=="lmkd_oom_score_adj"{print $2}') + echo 1 > /proc/lmkd_dbg_trigger + + local lmkd_oom_score_adj=$(cat /proc/lmkd_dbg_trigger | awk 'BEGIN{FS=":"} $1=="lmkd_oom_score_adj"{print $2}') + + if [ $lmkd_oom_score_adj -ne 1 ]; then + tst_res TFAIL "lmkd_ dbg_ Trigger doesn't set successfully" + ret=$(($ret + 1)) + fi + + local dmesg_lowmem_info=$(dmesg | grep "lowmem" | grep pid | grep uid | grep tgid | grep total_vm \ + | grep rss | grep nptes | grep swap | grep adj | grep s | grep name) + + if [ "$dmesg_lowmem_info" == "" ]; then + tst_res TFAIL "The information of lowmem in dmesg is displayed incorrectly" + ret=$(($ret + 1)) + fi + + if [ $ret -eq 0 ]; then + tst_res TPASS "Information of lowmem killer debug display test pass." + else + tst_res TFAIL "Information of lowmem killer debug display test failed!" + fi +} + +do_clean() +{ + echo $lmkd_oom_score_adj_def > /proc/lmkd_dbg_trigger +} + +do_setup +do_test +do_clean +tst_exit \ No newline at end of file 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 new file mode 100644 index 0000000..d3a3dc3 --- /dev/null +++ b/test/moduletest/runtest/bin/mem_debug_t/testcases/bin/mem_debug08.sh @@ -0,0 +1,54 @@ +#!/bin/sh +################################################################################ +# +# Copyright (C) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +################################################################################ +# File: mem_debug08.sh +# +# Description: Ashmem information display test +# +# Authors: Wangyuting - wangyuting36@huawei.com +# +# History: Mar 23 2022 - init scripts +# +################################################################################ +source tst_oh.sh + +do_setup() +{ + +} + +do_test() +{ + local pid=$(ps -ef | grep "com.ohos.launch" | grep -v grep | awk '{print $2}') + 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!" + else + tst_res TPASS "Ashmem information display test pass." + fi +} + +do_clean() +{ + +} + +do_setup +do_test +do_clean +tst_exit \ No newline at end of file diff --git a/test/moduletest/runtest/bin/mem_debug_t/testcases/bin/mem_debug09.sh b/test/moduletest/runtest/bin/mem_debug_t/testcases/bin/mem_debug09.sh new file mode 100644 index 0000000..e884f50 --- /dev/null +++ b/test/moduletest/runtest/bin/mem_debug_t/testcases/bin/mem_debug09.sh @@ -0,0 +1,73 @@ +#!/bin/sh +################################################################################ +# +# Copyright (C) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +################################################################################ +# File: mem_dubug09.sh +# +# Description: /sys/module/reclaim_acct/parameters/disable interface test +# 0: valid disable +# nonzero: reserved +# +# Authors: Wang Yuting - wangyuting36@huawei.com +# +# History: May 26 2022 - init scripts +# +################################################################################ + +source tst_oh.sh + +do_setup() +{ + zcat /proc/config.gz | grep CONFIG_RECLAIM_ACCT=y || tst_res TCONF "CONFIG_RECLAIM_ACCT=y not satisfied!" + reclaim_acct_disable="/sys/module/reclaim_acct/parameters/disable" + reclaim_acct_disable_def=$(cat /sys/module/reclaim_acct/parameters/disable) +} + +do_test() +{ + set_check_disable 0 0 + set_check_disable -1 -1 +} + +set_check_disable() +{ + local _set_disable=$1 + local _expect_disable=$2 + + echo $_set_disable > $reclaim_acct_disable + if [ $? -eq 0 ]; then + tst_res TPASS "Interface disable set to $_set_disable expected." + else + tst_res TFAIL "Interface disable set to $_set_disable unexpected!" + fi + + local _cur_disable=$(cat $reclaim_acct_disable) + if [ $_cur_disable -eq $_expect_disable ]; then + tst_res TPASS "Interface disable $_cur_disable equal to expected value." + else + tst_res TFAIL "Interface disable $_cur_disable unexpected value $_expect_disable!" + fi +} + +do_clean() +{ + echo $reclaim_acct_disable_def > $reclaim_acct_disable +} + +do_setup +do_test +do_clean +tst_exit \ No newline at end of file diff --git a/test/moduletest/runtest/bin/mem_debug_t/testcases/bin/mem_debug10.sh b/test/moduletest/runtest/bin/mem_debug_t/testcases/bin/mem_debug10.sh new file mode 100644 index 0000000..38c2f03 --- /dev/null +++ b/test/moduletest/runtest/bin/mem_debug_t/testcases/bin/mem_debug10.sh @@ -0,0 +1,78 @@ +#!/bin/sh +################################################################################ +# +# Copyright (C) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +################################################################################ +# File: mem_dubug10.sh +# +# Description: /proc/lmkd_dbg_trigger interface test +# -1000-1000: valid lmkd_adj +# others: not reserved error +# +# Authors: Wang Yuting - wangyuting36@huawei.com +# +# History: May 26 2022 - init scripts +# +################################################################################ + +source tst_oh.sh + +do_setup() +{ + zcat /proc/config.gz | grep CONFIG_LOWMEM=y || tst_res TCONF "CONFIG_LOWMEM=y not satisfied!" + zcat /proc/config.gz | grep CONFIG_LMKD_DBG=y || tst_res TCONF "CONFIG_LMKD_DBG=y not satisfied!" + lmkd_dbg_trigger="/proc/lmkd_dbg_trigger" + lmkd_oom_score_adj_def=$(cat /proc/lmkd_dbg_trigger | awk 'BEGIN{FS=":"} $1=="lmkd_oom_score_adj"{print $2}') +} + +do_test() +{ + set_check_lmkd_oom_score_adj -1001 1 0 + set_check_lmkd_oom_score_adj -1000 0 -1000 + set_check_lmkd_oom_score_adj 1 0 1 + set_check_lmkd_oom_score_adj 1000 0 1000 + set_check_lmkd_oom_score_adj 1001 1 1000 +} + +set_check_lmkd_oom_score_adj() +{ + local _set_lmkd_adj=$1 + local _expect_ret=$2 + local _expect_lmkd_adj=$3 + + echo $_set_lmkd_adj > $lmkd_dbg_trigger + if [ $? -eq $_expect_ret ]; then + tst_res TPASS "Interface lmkd_adj set to $_set_lmkd_adj expected." + else + tst_res TFAIL "Interface lmkd_adj set to $_set_lmkd_adj unexpected!" + fi + + local _cur_lmkd_adj=$(cat $lmkd_dbg_trigger | awk 'BEGIN{FS=":"} $1=="lmkd_oom_score_adj"{print $2}') + if [ $_cur_lmkd_adj -eq $_expect_lmkd_adj ]; then + tst_res TPASS "Interface lmkd_adj $_cur_lmkd_adj equal to expected value." + else + tst_res TFAIL "Interface lmkd_adj $_cur_lmkd_adj unexpected value $_expect_lmkd_adj!" + fi +} + +do_clean() +{ + echo $lmkd_oom_score_adj_def > $lmkd_dbg_trigger +} + +do_setup +do_test +do_clean +tst_exit \ No newline at end of file diff --git a/test/moduletest/runtest/bin/mem_debug_t_init.sh b/test/moduletest/runtest/bin/mem_debug_t_init.sh new file mode 100644 index 0000000..78fbcc5 --- /dev/null +++ b/test/moduletest/runtest/bin/mem_debug_t_init.sh @@ -0,0 +1,73 @@ +#!/bin/sh +################################################################################ +# +# Copyright (C) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +################################################################################ +# File: mem_debug_t_init.sh +# +# Description: mem_debug_t testsuite init script +# +# Authors: Wang Yuting - wangyuting36@huawei.com +# +# History: May 25 2022 - init scripts +# +################################################################################ + +pre_condition() +{ + +} + +hp_init() +{ + dd if=/dev/random of=/data/hpdisk bs=4096 count=131072 + losetup /dev/block/loop6 /data/hpdisk + hyperhold_device=`cat /proc/sys/kernel/hyperhold/device` + echo /dev/block/loop6 > /proc/sys/kernel/hyperhold/device +} + +hp_enable() +{ + hyperhold_enable=`cat /proc/sys/kernel/hyperhold/enable` + echo enable > /proc/sys/kernel/hyperhold/enable +} + +zram_init() +{ + zram0_group=`cat /sys/block/zram0/group` + zram0_disksize=`cat /sys/block/zram0/disksize` + echo readwrite > /sys/block/zram0/group + echo 512M > /sys/block/zram0/disksize +} + +zram_enable() +{ + mkswap /dev/block/zram0 + swapon /dev/block/zram0 + aa start -b com.ohos.settings -a com.ohos.settings.MainAbility + aa start -b ohos.samples.airquality -a ohos.samples.airquality.default + aa start -b ohos.samples.ecg -a ohos.samples.ecg.default + aa start -b ohos.samples.flashlight -a ohos.samples.flashlight.default + aa start -b ohos.samples.clock -a ohos.samples.clock.default +} + +echo "***************************MEMDEBUG INIT START***************************" +free -m +pre_condition +hp_init +hp_enable +zram_init +zram_enable +echo "***************************MEMDEBUG INIT END***************************" \ No newline at end of file diff --git a/test/moduletest/runtest/bin/mem_debug_t_uninit.sh b/test/moduletest/runtest/bin/mem_debug_t_uninit.sh new file mode 100644 index 0000000..0f875ed --- /dev/null +++ b/test/moduletest/runtest/bin/mem_debug_t_uninit.sh @@ -0,0 +1,43 @@ +#!/bin/sh +################################################################################ +# +# Copyright (C) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +################################################################################ +# File: mem_debug_t_uninit.sh +# +# Description: mem_debug_t testsuite uninit script +# +# Authors: Wang Yuting - wangyuting36@huawei.com +# +# History: May 26 2022 - init scripts +# +################################################################################ + +uninit_platform() +{ + losetup -d /dev/block/loop6 + echo ${hyperhold_device} > /proc/sys/kernel/hyperhold/device + echo ${hyperhold_enable} > /proc/sys/kernel/hyperhold/enable + echo ${zram0_group} > /sys/block/zram0/group + echo ${zram0_disksize} > /sys/block/zram0/disksize + rm -rf /data/hpdisk + swapoff /dev/block/zram0 + echo 1 > /sys/block/zram0/reset +} + +echo "***************************MEMDEBUG UNINIT START***************************" +free -m +uninit_platform +echo "***************************MEMDEBUG UNINIT END***************************" \ No newline at end of file diff --git a/test/moduletest/runtest/conf/OH_RK3568_config b/test/moduletest/runtest/conf/OH_RK3568_config index b06cb61..66603f4 100644 --- a/test/moduletest/runtest/conf/OH_RK3568_config +++ b/test/moduletest/runtest/conf/OH_RK3568_config @@ -28,3 +28,4 @@ cpusetdecouple_cpuhotplug_t enhancedswap_t sched_rtg_t enhancedf2fs_t +mem_debug_t diff --git a/test/moduletest/runtest/tests/mem_debug_t b/test/moduletest/runtest/tests/mem_debug_t new file mode 100644 index 0000000..0dcc461 --- /dev/null +++ b/test/moduletest/runtest/tests/mem_debug_t @@ -0,0 +1,35 @@ +################################################################################ +# +# Copyright (C) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +################################################################################ +# File: mem_debug_t +# +# Description: mem debug testcase list +# +# Authors: Wang Yuting - wangyuting36@huawei.com +# +# History: May 24 2022 - init scripts +# +################################################################################ +mem_debug01 mem_debug01.sh +mem_debug02 mem_debug02.sh +mem_debug03 mem_debug03.sh +mem_debug04 mem_debug04.sh +mem_debug05 mem_debug05.sh +mem_debug06 mem_debug06.sh +mem_debug07 mem_debug07.sh +mem_debug08 mem_debug08.sh +mem_debug09 mem_debug09.sh +mem_debug10 mem_debug10.sh -- Gitee