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_debug08.sh 15# 16# Description: Ashmem information display 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 28} 29 30do_test() 31{ 32 # find ashmem process 33 local pid=$(cat /proc/ashmem_process_info | awk 'NR>3 && $2!="" {print $2}' | sort -u) 34 local line=$(cat /proc/ashmem_process_info | awk 'NR>3 && $2!="" {print $2}' | sort -u | wc -l) 35 if [ $line -eq 0 ]; then 36 tst_res TFAIL "Cannot find program with ashmen!" 37 else 38 tst_res TPASS "The following $line ashmem processes have been found(PID): $pid." 39 fi 40 41 # Confirm that each process ashmem information is correct 42 for p in $pid 43 do 44 tst_res TINFO "now going to check $p ashmem information" 45 ash_info_check $p 46 done 47 48} 49 50ash_info_check() 51{ 52 local pid=$1 53 tst_res TINFO "pid is $pid ." 54 55 local ashmem_info_lines=$(cat /proc/$pid/smaps | grep ashmem | wc -l) 56 57 if [ $ashmem_info_lines -le 0 ]; then 58 tst_res TFAIL "Cannot find ashmem information of $pid .Ashmem information display test failed!" 59 else 60 tst_res TPASS "$pid totally found $ashmem_info_lines ashmem messages.Ashmem information display test pass." 61 fi 62} 63 64do_clean() 65{ 66 67} 68 69do_setup 70do_test 71do_clean 72tst_exit