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_dubug10.sh 18# 19# Description: /proc/lmkd_dbg_trigger interface test 20# -1000-1000: valid lmkd_adj 21# others: not reserved error 22# 23# Authors: Wang Yuting - wangyuting36@huawei.com 24# 25# History: May 26 2022 - init scripts 26# 27################################################################################ 28 29source tst_oh.sh 30 31do_setup() 32{ 33 zcat /proc/config.gz | grep CONFIG_LOWMEM=y || tst_res TCONF "CONFIG_LOWMEM=y not satisfied!" 34 zcat /proc/config.gz | grep CONFIG_LMKD_DBG=y || tst_res TCONF "CONFIG_LMKD_DBG=y not satisfied!" 35 lmkd_dbg_trigger="/proc/lmkd_dbg_trigger" 36 lmkd_oom_score_adj_def=$(cat /proc/lmkd_dbg_trigger | awk 'BEGIN{FS=":"} $1=="lmkd_oom_score_adj"{print $2}') 37} 38 39do_test() 40{ 41 set_check_lmkd_oom_score_adj -1001 1 $lmkd_oom_score_adj_def 42 set_check_lmkd_oom_score_adj -1000 0 -1000 43 set_check_lmkd_oom_score_adj 1 0 1 44 set_check_lmkd_oom_score_adj 1000 0 1000 45 set_check_lmkd_oom_score_adj 1001 1 1000 46} 47 48set_check_lmkd_oom_score_adj() 49{ 50 local _set_lmkd_adj=$1 51 local _expect_ret=$2 52 local _expect_lmkd_adj=$3 53 54 echo $_set_lmkd_adj > $lmkd_dbg_trigger 55 if [ $? -eq $_expect_ret ]; then 56 tst_res TPASS "Interface lmkd_adj set to $_set_lmkd_adj expected." 57 else 58 tst_res TFAIL "Interface lmkd_adj set to $_set_lmkd_adj unexpected!" 59 fi 60 61 local _cur_lmkd_adj=$(cat $lmkd_dbg_trigger | awk 'BEGIN{FS=":"} $1=="lmkd_oom_score_adj"{print $2}') 62 if [ $_cur_lmkd_adj -eq $_expect_lmkd_adj ]; then 63 tst_res TPASS "Interface lmkd_adj $_cur_lmkd_adj equal to expected value." 64 else 65 tst_res TFAIL "Interface lmkd_adj $_cur_lmkd_adj unexpected value $_expect_lmkd_adj!" 66 fi 67} 68 69do_clean() 70{ 71 echo $lmkd_oom_score_adj_def > $lmkd_dbg_trigger 72} 73 74do_setup 75do_test 76do_clean 77tst_exit