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