1#!/bin/sh 2################################################################################ 3# 4# Copyright (C) 2022 Huawei Device Co., Ltd. 5# SPDX-License-Identifier: GPL-2.0 6# 7# Unless required by applicable law or agreed to in writing, software 8# distributed under the License is distributed on an "AS IS" BASIS, 9# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10# See the License for the specific language governing permissions and 11# limitations under the License. 12# 13################################################################################ 14# File: mem_debug02.sh 15# 16# Description: Sum of static memory excluding cma test 17# 18# Authors: Wangyuting - wangyuting36@huawei.com 19# 20# History: Mar 23 2022 - init scripts 21# 22################################################################################ 23source tst_oh.sh 24 25do_setup() 26{ 27 zcat /proc/config.gz | grep CONFIG_DEBUG_FS=y || tst_res TCONF "CONFIG_DEBUG_FS=y not satisfied!" 28} 29 30do_test() 31{ 32 local code_low_add=$( cat /proc/iomem | grep Kernel | awk '$4=="code"{print $1}' | awk 'BEGIN{FS="-"}{print $1}') 33 local code_high_add=$( cat /proc/iomem | grep Kernel | awk '$4=="code"{print $1}' | awk 'BEGIN{FS="-"}{print $2}') 34 local code_size=$((16#$code_high_add - 16#$code_low_add)) 35 36 local data_low_add=$( cat /proc/iomem | grep Kernel | awk '$4=="data"{print $1}' | awk 'BEGIN{FS="-"}{print $1}') 37 local data_high_add=$( cat /proc/iomem | grep Kernel | awk '$4=="data"{print $1}' | awk 'BEGIN{FS="-"}{print $2}') 38 local data_size=$((16#$data_high_add - 16#$data_low_add)) 39 40 local kernel_size=$(($code_size + $data_size)) 41 local ksize_kb=$(($kernel_size / 1024)) 42 43 local memtotal=$(cat /proc/meminfo | awk '$1=="MemTotal:"{print $2}') 44 local total_size=$(($ksize_kb + $memtotal)) 45 local maxsize=$((2 * 1024 * 1024)) 46 47 if [ $total_size -le $maxsize ]; then 48 tst_res TPASS "Sum of static memory excluding cma test pass." 49 else 50 tst_res TFAIL "Sum of static memory excluding cma test failed!" 51 fi 52} 53 54do_clean() 55{ 56 57} 58 59do_setup 60do_test 61do_clean 62tst_exit