• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_debug07.sh
15#
16# Description: Information of lowmem killer debug 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    zcat /proc/config.gz | grep CONFIG_LOWMEM=y || tst_res TCONF "CONFIG_LOWMEM=y not satisfied!"
28    zcat /proc/config.gz | grep CONFIG_LMKD_DBG=y || tst_res TCONF "CONFIG_LMKD_DBG=y not satisfied!"
29}
30
31do_test()
32{
33    local ret=0
34
35    lmkd_oom_score_adj_def=$(cat /proc/lmkd_dbg_trigger | awk 'BEGIN{FS=":"} $1=="lmkd_oom_score_adj"{print $2}')
36    echo 1 > /proc/lmkd_dbg_trigger
37
38    local lmkd_oom_score_adj=$(cat /proc/lmkd_dbg_trigger | awk 'BEGIN{FS=":"} $1=="lmkd_oom_score_adj"{print $2}')
39
40    if [ $lmkd_oom_score_adj -ne 1 ]; then
41        tst_res TFAIL "lmkd_ dbg_ Trigger doesn't set successfully"
42        ret=$(($ret + 1))
43    fi
44
45    local dmesg_lowmem_info=$(dmesg | grep "lowmem" | grep pid | grep uid | grep tgid | grep total_vm  \
46    | grep rss | grep nptes | grep swap | grep adj | grep s | grep name)
47
48    if [ "$dmesg_lowmem_info" == "" ]; then
49        tst_res TFAIL "The information of lowmem in dmesg is displayed incorrectly"
50        ret=$(($ret + 1))
51    fi
52
53    if [ $ret -eq 0 ]; then
54        tst_res TPASS "Information of lowmem killer debug display test pass."
55    else
56        tst_res TFAIL "Information of lowmem killer debug display test failed!"
57    fi
58}
59
60do_clean()
61{
62    echo $lmkd_oom_score_adj_def > /proc/lmkd_dbg_trigger
63}
64
65do_setup
66do_test
67do_clean
68tst_exit