• 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_debug04.sh
15#
16# Description:  Meminfo's dimension measurement information extension test
17#
18# Authors:     Wangyuting - wangyuting36@huawei.com
19#
20# History:     Mar 20 2022 - init scripts
21#
22################################################################################
23source tst_oh.sh
24
25do_setup()
26{
27    zcat /proc/config.gz | grep CONFIG_PAGE_TRACING=y || tst_res TCONF "ONFIG_PAGE_TRACING=y not satisfied!"
28
29    avail_buffers=/dev/memcg/memory.avail_buffers
30
31    local zswapd_s=/dev/memcg/memory.zswapd_pressure_show
32    local buffer_size=$(cat $zswapd_s | grep 'buffer_size' | awk -F ':' '{print$2}')
33
34    avail_buffers_def=$(cat /dev/memcg/memory.avail_buffers | awk '$1=="avail_buffers:"{print $2}')
35    min_avail_buffers_def=$(cat /dev/memcg/memory.avail_buffers | awk '$1=="min_avail_buffers:"{print $2}')
36    high_avail_buffers_def=$(cat /dev/memcg/memory.avail_buffers | awk '$1=="high_avail_buffers:"{print $2}')
37    free_swap_threshold_def=$(cat /dev/memcg/memory.avail_buffers | awk '$1=="free_swap_threshold:"{print $2}')
38
39    echo 0 $(( $buffer_size + 50 )) $(( $buffer_size + 100 )) 0 > $avail_buffers
40    sleep 3
41}
42
43do_test()
44{
45    local ret=0
46
47    sh ../../../mem_debug_t_uninit.sh
48    local old_vmallocused=$(cat /proc/meminfo | awk '$1=="VmallocUsed:"{print $2}')
49    local old_zspageused=$(cat /proc/meminfo | awk '$1=="ZspageUsed:"{print $2}')
50    local old_gltrack=$(cat /proc/meminfo | awk '$1=="GLTrack:"{print $2}')
51
52    sh ../../../mem_debug_t_init.sh
53    aa start -b com.ohos.settings -a com.ohos.settings.MainAbility
54    aa start -b ohos.samples.airquality -a ohos.samples.airquality.default
55    aa start -b ohos.samples.ecg -a ohos.samples.ecg.MainAbility
56    aa start -b ohos.samples.flashlight -a ohos.samples.flashlight.default
57    aa start -b ohos.samples.clock -a ohos.samples.clock.default
58
59    local new_vmallocused=$(cat /proc/meminfo | awk '$1=="VmallocUsed:"{print $2}')
60    local new_zspageused=$(cat /proc/meminfo | awk '$1=="ZspageUsed:"{print $2}')
61    local new_gltrack=$(cat /proc/meminfo | awk '$1=="GLTrack:"{print $2}')
62
63    if [ "$old_gltrack" == "-" ] && [ "$new_gltrack" == "-" ]; then
64        tst_res TPASS "Gltrack equals '-'"
65    else
66        tst_res TFAIL "Gltrack not equals '-'"
67        ret=$(($ret + 1))
68    fi
69
70    local res_vmallocused=$(($new_vmallocused - $old_vmallocused))
71    local res_zspageused=$(($new_zspageused - $old_zspageused))
72
73    if [ $res_vmallocused -le 0 ]; then
74        tst_res TFAIL "Vmallocused not growing"
75        ret=$(($ret + 1))
76    fi
77    if [ $res_zspageused -le 0 ]; then
78        tst_res TFAIL "ZspageUsed not growing"
79        ret=$(($ret + 1))
80    fi
81
82    if [ $ret -eq 0 ]; then
83        tst_res TPASS "Meminfo's dimension measurement information extension test pass."
84    else
85        tst_res TFAIL "Meminfo's dimension measurement information extension test failed!"
86    fi
87}
88
89do_clean()
90{
91    echo $avail_buffers_def $min_avail_buffers_def $high_avail_buffers_def $free_swap_threshold_def > $avail_buffers
92}
93
94do_setup
95do_test
96do_clean
97tst_exit