• 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# 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_debug07.sh
18#
19# Description: Information of lowmem killer debug display test
20#
21# Authors:     Wangyuting - wangyuting36@huawei.com
22#
23# History:     Mar 23 2022 - init scripts
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}
33
34do_test()
35{
36    local ret=0
37
38    lmkd_oom_score_adj_def=$(cat /proc/lmkd_dbg_trigger | awk 'BEGIN{FS=":"} $1=="lmkd_oom_score_adj"{print $2}')
39    echo 1 > /proc/lmkd_dbg_trigger
40
41    local lmkd_oom_score_adj=$(cat /proc/lmkd_dbg_trigger | awk 'BEGIN{FS=":"} $1=="lmkd_oom_score_adj"{print $2}')
42
43    if [ $lmkd_oom_score_adj -ne 1 ]; then
44        tst_res TFAIL "lmkd_ dbg_ Trigger doesn't set successfully"
45        ret=$(($ret + 1))
46    fi
47
48    local dmesg_lowmem_info=$(dmesg | grep "lowmem" | grep pid | grep uid | grep tgid | grep total_vm  \
49    | grep rss | grep nptes | grep swap | grep adj | grep s | grep name)
50
51    if [ "$dmesg_lowmem_info" == "" ]; then
52        tst_res TFAIL "The information of lowmem in dmesg is displayed incorrectly"
53        ret=$(($ret + 1))
54    fi
55
56    if [ $ret -eq 0 ]; then
57        tst_res TPASS "Information of lowmem killer debug display test pass."
58    else
59        tst_res TFAIL "Information of lowmem killer debug display test failed!"
60    fi
61}
62
63do_clean()
64{
65    echo $lmkd_oom_score_adj_def > /proc/lmkd_dbg_trigger
66}
67
68do_setup
69do_test
70do_clean
71tst_exit