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_debug02.sh 18# 19# Description: Sum of static memory excluding cma test 20# 21# Authors: Wangyuting - wangyuting36@huawei.com 22# 23# History: Mar 23 2022 - init scripts 24# 25################################################################################ 26source tst_oh.sh 27 28do_setup() 29{ 30 zcat /proc/config.gz | grep CONFIG_DEBUG_FS=y || tst_res TCONF "CONFIG_DEBUG_FS=y not satisfied!" 31} 32 33do_test() 34{ 35 local code_low_add=$( cat /proc/iomem | grep Kernel | awk '$4=="code"{print $1}' | awk 'BEGIN{FS="-"}{print $1}') 36 local code_high_add=$( cat /proc/iomem | grep Kernel | awk '$4=="code"{print $1}' | awk 'BEGIN{FS="-"}{print $2}') 37 local code_size=$((16#$code_high_add - 16#$code_low_add)) 38 39 local data_low_add=$( cat /proc/iomem | grep Kernel | awk '$4=="data"{print $1}' | awk 'BEGIN{FS="-"}{print $1}') 40 local data_high_add=$( cat /proc/iomem | grep Kernel | awk '$4=="data"{print $1}' | awk 'BEGIN{FS="-"}{print $2}') 41 local data_size=$((16#$data_high_add - 16#$data_low_add)) 42 43 local kernel_size=$(($code_size + $data_size)) 44 local ksize_kb=$(($kernel_size / 1024)) 45 46 local memtotal=$(cat /proc/meminfo | awk '$1=="MemTotal:"{print $2}') 47 local total_size=$(($ksize_kb + $memtotal)) 48 local maxsize=$((2 * 1024 * 1024)) 49 50 if [ $total_size -le $maxsize ]; then 51 tst_res TPASS "Sum of static memory excluding cma test pass." 52 else 53 tst_res TFAIL "Sum of static memory excluding cma test failed!" 54 fi 55} 56 57do_clean() 58{ 59 60} 61 62do_setup 63do_test 64do_clean 65tst_exit