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: purgeable_mem02.sh 18# 19# Description: Static memory reservation query test 20# 21# Authors: Ke Liu - liuke94@huawei.com 22# 23# History: Nov 2 2022 - init scripts 24# 25################################################################################ 26source tst_oh.sh 27 28do_setup() 29{ 30 zcat /proc/config.gz | grep CONFIG_MEM_PURGEABLE=y || tst_res TCONF "CONFIG_MEM_PURGEABLE=y not satisfied!" 31} 32 33do_test() 34{ 35 local testpath=$(find / -name purgeable_cpp_test | grep -v find) 36 if [ ! $testpath ];then 37 tst_res TFAIL "can not find purgeable_cpp_test!" 38 fi 39 (cd $(echo ${testpath%purgeable_cpp_test});chmod 777 purgeable_cpp_test;./purgeable_cpp_test &>/dev/null &) 40 local pid=$(pidof purgeable_cpp_test) 41 while [ "$pid" -eq '0' ] 42 do 43 pid=$(pidof purgeable_cpp_test) 44 done 45 while [ "$pid" -ne '0' ] 46 do 47 cat /proc/meminfo | grep -i purg | grep -v grep | grep -v Name >>mem.log 48 pid=$(pidof purgeable_cpp_test) 49 done 50 cat mem.log | grep -v '0 kB' >mem1.log 51 if [ -s mem1.log ];then 52 tst_res TPASS "Purgeable memory reservation query test pass." 53 else 54 tst_res TFAIL "Purgeable memory reservation query test error!" 55 fi 56 ls ${testpath%purgeable_cpp_test} >log2.log 57 local lastxml=$(tac log2.log | grep purgeable_cpp_test | grep xml| head -n 1) 58 rm ${testpath%purgeable_cpp_test}${lastxml} 59} 60 61do_clean() 62{ 63 rm mem.log 64 rm mem1.log 65 rm log2.log 66} 67 68do_setup 69do_test 70do_clean 71tst_exit 72