1#!/bin/sh 2################################################################################ 3# 4# Copyright (C) 2022 Huawei Device Co., Ltd. 5# SPDX-License-Identifier: GPL-2.0 6# 7# Legacy blkg rwstat helpers enabled by CONFIG_BLK_CGROUP_RWSTAT. 8# Do not use in new code. 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15# 16################################################################################ 17# File: mem_debug04.sh 18# 19# Description: Meminfo's dimension measurement information extension test 20# 21# Authors: Wangyuting - wangyuting36@huawei.com 22# 23# History: Mar 20 2022 - init scripts 24# 25################################################################################ 26source tst_oh.sh 27 28do_setup() 29{ 30 zcat /proc/config.gz | grep CONFIG_PAGE_TRACING=y || tst_res TCONF "ONFIG_PAGE_TRACING=y not satisfied!" 31 32 avail_buffers=/dev/memcg/memory.avail_buffers 33 34 local zswapd_s=/dev/memcg/memory.zswapd_pressure_show 35 local buffer_size=$(cat $zswapd_s | grep 'buffer_size' | awk -F ':' '{print$2}') 36 37 avail_buffers_def=$(cat /dev/memcg/memory.avail_buffers | awk '$1=="avail_buffers:"{print $2}') 38 min_avail_buffers_def=$(cat /dev/memcg/memory.avail_buffers | awk '$1=="min_avail_buffers:"{print $2}') 39 high_avail_buffers_def=$(cat /dev/memcg/memory.avail_buffers | awk '$1=="high_avail_buffers:"{print $2}') 40 free_swap_threshold_def=$(cat /dev/memcg/memory.avail_buffers | awk '$1=="free_swap_threshold:"{print $2}') 41 42 echo 0 $(( $buffer_size + 50 )) $(( $buffer_size + 100 )) 0 > $avail_buffers 43 sleep 3 44} 45 46do_test() 47{ 48 local ret=0 49 50 sh ../../../mem_debug_t_uninit.sh 51 local old_vmallocused=$(cat /proc/meminfo | awk '$1=="VmallocUsed:"{print $2}') 52 local old_zspageused=$(cat /proc/meminfo | awk '$1=="ZspageUsed:"{print $2}') 53 local old_gltrack=$(cat /proc/meminfo | awk '$1=="GLTrack:"{print $2}') 54 55 sh ../../../mem_debug_t_init.sh 56 aa start -b com.ohos.settings -a com.ohos.settings.MainAbility 57 aa start -b ohos.samples.airquality -a ohos.samples.airquality.default 58 aa start -b ohos.samples.ecg -a ohos.samples.ecg.MainAbility 59 aa start -b ohos.samples.flashlight -a ohos.samples.flashlight.default 60 aa start -b ohos.samples.clock -a ohos.samples.clock.default 61 62 local new_vmallocused=$(cat /proc/meminfo | awk '$1=="VmallocUsed:"{print $2}') 63 local new_zspageused=$(cat /proc/meminfo | awk '$1=="ZspageUsed:"{print $2}') 64 local new_gltrack=$(cat /proc/meminfo | awk '$1=="GLTrack:"{print $2}') 65 66 if [ "$old_gltrack" == "-" ] && [ "$new_gltrack" == "-" ]; then 67 tst_res TPASS "Gltrack equals '-'" 68 else 69 tst_res TFAIL "Gltrack not equals '-'" 70 ret=$(($ret + 1)) 71 fi 72 73 local res_vmallocused=$(($new_vmallocused - $old_vmallocused)) 74 local res_zspageused=$(($new_zspageused - $old_zspageused)) 75 76 if [ $res_vmallocused -le 0 ]; then 77 tst_res TFAIL "Vmallocused not growing" 78 ret=$(($ret + 1)) 79 fi 80 if [ $res_zspageused -le 0 ]; then 81 tst_res TFAIL "ZspageUsed not growing" 82 ret=$(($ret + 1)) 83 fi 84 85 if [ $ret -eq 0 ]; then 86 tst_res TPASS "Meminfo's dimension measurement information extension test pass." 87 else 88 tst_res TFAIL "Meminfo's dimension measurement information extension test failed!" 89 fi 90} 91 92do_clean() 93{ 94 echo $avail_buffers_def $min_avail_buffers_def $high_avail_buffers_def $free_swap_threshold_def > $avail_buffers 95} 96 97do_setup 98do_test 99do_clean 100tst_exit