mirror of
https://github.com/openharmony/kernel_linux_build.git
synced 2026-07-16 05:30:26 -04:00
linuxkerneltest: add enhancedswap test suite
Signed-off-by: Ma Feng <mafeng.ma@huawei.com>
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
#!/bin/sh
|
||||
################################################################################
|
||||
#
|
||||
# Copyright (C) 2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
################################################################################
|
||||
# File: enhancedswap01.sh
|
||||
#
|
||||
# Description: enhanced swap /dev/memcg/memory.avail_buffers interface test
|
||||
#
|
||||
# Authors: Ma Feng - mafeng.ma@huawei.com
|
||||
#
|
||||
# History: Mar 24 2022 - init scripts
|
||||
#
|
||||
################################################################################
|
||||
source tst_oh.sh
|
||||
|
||||
do_setup()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
do_test()
|
||||
{
|
||||
local ret=0
|
||||
local res=0
|
||||
local memcg_availbffers=/dev/memcg/memory.avail_buffers
|
||||
|
||||
tst_res TINFO "Start enhanced swap /dev/memcg/memory.avail_buffers \
|
||||
interface invalid setting test"
|
||||
echo 0 1620 1529 0 > $memcg_availbffers
|
||||
ret=$(($ret + $?))
|
||||
echo 0 1620 -100 0 > $memcg_availbffers
|
||||
ret=$(($ret + $?))
|
||||
echo 0 -100 -100 0 > $memcg_availbffers
|
||||
ret=$(($ret + $?))
|
||||
echo 0 10000001 10000000 0 > $memcg_availbffers
|
||||
ret=$(($ret + $?))
|
||||
|
||||
if [ $ret -ne 4 ]; then
|
||||
res=$(($res + 1))
|
||||
fi
|
||||
|
||||
if [ $res -eq 0 ]; then
|
||||
tst_res TPASS "enhanced swap /dev/memcg/memory.avail_buffers \
|
||||
interface invalid setting test pass."
|
||||
else
|
||||
tst_res TFAIL "enhanced swap /dev/memcg/memory.avail_buffers \
|
||||
interface invalid setting test failed!"
|
||||
fi
|
||||
}
|
||||
|
||||
do_clean()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
do_setup
|
||||
do_test
|
||||
do_clean
|
||||
tst_exit
|
||||
@@ -0,0 +1,83 @@
|
||||
#!/bin/sh
|
||||
################################################################################
|
||||
#
|
||||
# Copyright (C) 2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
################################################################################
|
||||
# File: enhancedswap02.sh
|
||||
#
|
||||
# Description: enhanced swap /dev/memcg/memory.zswapd_single_memcg_param and
|
||||
# /dev/memcg/100/memory.zswapd_single_memcg_param interface test
|
||||
#
|
||||
# Authors: Ma Feng - mafeng.ma@huawei.com
|
||||
#
|
||||
# History: Mar 24 2022 - init scripts
|
||||
#
|
||||
################################################################################
|
||||
source tst_oh.sh
|
||||
|
||||
do_setup()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
do_test()
|
||||
{
|
||||
local ret=0
|
||||
local res=0
|
||||
local memcg_100_zsmp=/dev/memcg/100/memory.zswapd_single_memcg_param
|
||||
local memcg_zsmp=/dev/memcg/memory.zswapd_single_memcg_param
|
||||
|
||||
tst_res TINFO "Start enhanced swap memory.zswapd_single_memcg_param \
|
||||
interface test"
|
||||
echo 0 -100 0 0 > $memcg_100_zsmp
|
||||
ret=$(($ret + $?))
|
||||
echo 0 0 -100 0 > $memcg_100_zsmp
|
||||
ret=$(($ret + $?))
|
||||
echo 0 -100 -100 0 > $memcg_100_zsmp
|
||||
ret=$(($ret + $?))
|
||||
echo 0 101 101 0 > $memcg_100_zsmp
|
||||
ret=$(($ret + $?))
|
||||
|
||||
echo 0 -100 0 0 > $memcg_zsmp
|
||||
ret=$(($ret + $?))
|
||||
echo 0 0 -100 0 > $memcg_zsmp
|
||||
ret=$(($ret + $?))
|
||||
echo 0 -100 -100 0 > $memcg_zsmp
|
||||
ret=$(($ret + $?))
|
||||
echo 0 101 101 0 > $memcg_zsmp
|
||||
ret=$(($ret + $?))
|
||||
|
||||
if [ $ret -ne 8 ]; then
|
||||
res=$(($res + 1))
|
||||
fi
|
||||
|
||||
if [ $res -eq 0 ]; then
|
||||
tst_res TPASS "enhanced swap memory.zswapd_single_memcg_param \
|
||||
interface test pass."
|
||||
else
|
||||
tst_res TFAIL "enhanced swap memory.zswapd_single_memcg_param \
|
||||
interface test failed!"
|
||||
fi
|
||||
}
|
||||
|
||||
do_clean()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
do_setup
|
||||
do_test
|
||||
do_clean
|
||||
tst_exit
|
||||
@@ -0,0 +1,65 @@
|
||||
#!/bin/sh
|
||||
################################################################################
|
||||
#
|
||||
# Copyright (C) 2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
################################################################################
|
||||
# File: enhancedswap03.sh
|
||||
#
|
||||
# Description: enhanced swap /dev/memcg/memory.zram_wm_ratio interface test
|
||||
#
|
||||
# Authors: Ma Feng - mafeng.ma@huawei.com
|
||||
#
|
||||
# History: Mar 24 2022 - init scripts
|
||||
#
|
||||
################################################################################
|
||||
source tst_oh.sh
|
||||
|
||||
do_setup()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
do_test()
|
||||
{
|
||||
local ret=0
|
||||
local res=0
|
||||
local zram_wm_ratio=/dev/memcg/memory.zram_wm_ratio
|
||||
|
||||
tst_res TINFO "Start enhanced swap $zram_wm_ratio interface test"
|
||||
echo -1 > $zram_wm_ratio
|
||||
ret=$(($ret + $?))
|
||||
echo 101 > $zram_wm_ratio
|
||||
ret=$(($ret + $?))
|
||||
|
||||
if [ $ret -ne 2 ]; then
|
||||
res=$(($res + 1))
|
||||
fi
|
||||
|
||||
if [ $res -eq 0 ]; then
|
||||
tst_res TPASS "enhanced swap $zram_wm_ratio interface test pass."
|
||||
else
|
||||
tst_res TFAIL "enhanced swap $zram_wm_ratio interface test failed!"
|
||||
fi
|
||||
}
|
||||
|
||||
do_clean()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
do_setup
|
||||
do_test
|
||||
do_clean
|
||||
tst_exit
|
||||
@@ -0,0 +1,86 @@
|
||||
#!/bin/sh
|
||||
################################################################################
|
||||
#
|
||||
# Copyright (C) 2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
################################################################################
|
||||
# File: enhancedswap04.sh
|
||||
#
|
||||
# Description: anon memory to zram test
|
||||
#
|
||||
# Authors: Ma Feng - mafeng.ma@huawei.com
|
||||
#
|
||||
# History: Mar 24 2022 - init scripts
|
||||
#
|
||||
################################################################################
|
||||
source tst_oh.sh
|
||||
|
||||
do_setup()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
do_test()
|
||||
{
|
||||
local ret=0
|
||||
local memcg_100_stat=/dev/memcg/100/memory.stat
|
||||
local memcg_stat=/dev/memcg/memory.stat
|
||||
local avail_buffers=/dev/memcg/memory.avail_buffers
|
||||
local zswapd_s=/dev/memcg/memory.zswapd_pressure_show
|
||||
|
||||
tst_res TINFO "Start anon to zram test"
|
||||
|
||||
# get init zram values
|
||||
zram_100_b=`cat ${memcg_100_stat} | grep 'zram' | awk -F ' ' '{print$2}'`
|
||||
zram_b=`cat ${memcg_stat} | grep 'zram' | awk -F ' ' '{print$2}'`
|
||||
|
||||
# get buffer_size
|
||||
buffer_size=`cat $zswapd_s | grep 'buffer_size' | awk -F ':' '{print$2}'`
|
||||
|
||||
# set avail_buffers > buffer_size to swap out to zram
|
||||
echo 0 $(( $buffer_size + 50 )) $(( $buffer_size + 100 )) 0 > $avail_buffers
|
||||
|
||||
sleep 3
|
||||
|
||||
# get new zram values after swap-out to zram
|
||||
zram_100_a=`cat ${memcg_100_stat} | grep 'zram' | awk -F ' ' '{print$2}'`
|
||||
zram_a=`cat ${memcg_stat} | grep 'zram' | awk -F ' ' '{print$2}'`
|
||||
|
||||
tst_res TINFO "root zram: $zram_b --> $zram_a"
|
||||
tst_res TINFO "100 zram: $zram_100_b --> $zram_100_a"
|
||||
|
||||
# zram change
|
||||
if [[ $zram_b -ne $zram_a || $zram_100_b -ne $zram_100_a ]]; then
|
||||
tst_res TINFO "anon memory compressed to zram, Eswap hold."
|
||||
else
|
||||
tst_res TINFO "no anon memory compressed to zram!"
|
||||
ret=$(( $ret + 1 ))
|
||||
fi
|
||||
|
||||
if [ $ret -eq 0 ];then
|
||||
tst_res TPASS "anon memory to zram test pass."
|
||||
else
|
||||
tst_res TFAIL "anon memory to zram test failed!"
|
||||
fi
|
||||
}
|
||||
|
||||
do_clean()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
do_setup
|
||||
do_test
|
||||
do_clean
|
||||
tst_exit
|
||||
@@ -0,0 +1,88 @@
|
||||
#!/bin/sh
|
||||
################################################################################
|
||||
#
|
||||
# Copyright (C) 2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
################################################################################
|
||||
# File: enhancedswap05.sh
|
||||
#
|
||||
# Description: zram to Eswap test
|
||||
#
|
||||
# Authors: Ma Feng - mafeng.ma@huawei.com
|
||||
#
|
||||
# History: Mar 24 2022 - init scripts
|
||||
#
|
||||
################################################################################
|
||||
source tst_oh.sh
|
||||
|
||||
do_setup()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
do_test()
|
||||
{
|
||||
local ret=0
|
||||
local memcg_100_stat=/dev/memcg/100/memory.stat
|
||||
local memcg_stat=/dev/memcg/memory.stat
|
||||
local avail_buffers=/dev/memcg/memory.avail_buffers
|
||||
local zswapd_s=/dev/memcg/memory.zswapd_pressure_show
|
||||
|
||||
tst_res TINFO "Start zram to Eswap test"
|
||||
# get init Eswap values
|
||||
eswap_100_b=`cat ${memcg_100_stat} | grep 'Eswap' | awk -F ' ' '{print$2}'`
|
||||
eswap_b=`cat ${memcg_stat} | grep 'Eswap' | awk -F ' ' '{print$2}'`
|
||||
|
||||
# turn on enhanced swap out
|
||||
echo 1 > /dev/memcg/memory.zram_wm_ratio
|
||||
|
||||
# get buffer_size
|
||||
buffer_size=`cat $zswapd_s | grep 'buffer_size' | awk -F ':' '{print$2}'`
|
||||
|
||||
# set avail_buffers > buffer_size to swap out to Eswap
|
||||
echo 0 $(( $buffer_size + 50 )) $(( $buffer_size + 100 )) 0 > $avail_buffers
|
||||
|
||||
sleep 3
|
||||
|
||||
# get new Eswap values after swap-out to Eswap
|
||||
eswap_100_a=`cat ${memcg_100_stat} | grep 'Eswap' | awk -F ' ' '{print$2}'`
|
||||
eswap_a=`cat ${memcg_stat} | grep 'Eswap' | awk -F ' ' '{print$2}'`
|
||||
|
||||
tst_res TINFO "root Eswap: $eswap_b --> $eswap_a"
|
||||
tst_res TINFO "100 Eswap: $eswap_100_b --> $eswap_100_a"
|
||||
|
||||
# Eswap change
|
||||
if [[ $eswap_b -ne $eswap_a || $eswap_100_b -ne $eswap_100_a ]]; then
|
||||
tst_res TINFO "zram to Eswap."
|
||||
else
|
||||
tst_res TINFO "no zram to Eswap."
|
||||
ret=$(( $ret + 1 ))
|
||||
fi
|
||||
|
||||
if [ $ret -eq 0 ];then
|
||||
tst_res TPASS "zram to Eswap test pass."
|
||||
else
|
||||
tst_res TFAIL "zram to Eswap test failed!"
|
||||
fi
|
||||
}
|
||||
|
||||
do_clean()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
do_setup
|
||||
do_test
|
||||
do_clean
|
||||
tst_exit
|
||||
@@ -0,0 +1,78 @@
|
||||
#!/bin/sh
|
||||
################################################################################
|
||||
#
|
||||
# Copyright (C) 2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
################################################################################
|
||||
# File: enhancedswap_t_init.sh
|
||||
#
|
||||
# Description: enhancedswap_t testsuite init script
|
||||
#
|
||||
# Authors: Ma Feng - mafeng.ma@huawei.com
|
||||
#
|
||||
# History: Mar 24 2022 - init scripts
|
||||
#
|
||||
################################################################################
|
||||
|
||||
pre_condition()
|
||||
{
|
||||
TCBIN=$LTPROOT/testcases/bin
|
||||
export PATH=$TCBIN:$PATH
|
||||
export TMPDIR=/data/local/tmp
|
||||
export LD_LIBRARY_PATH=$LTPROOT/lib
|
||||
export BUSYBOX=/system/bin/busybox-armv7l
|
||||
}
|
||||
|
||||
hp_init()
|
||||
{
|
||||
dd if=/dev/random of=/data/hpdisk bs=4096 count=131072
|
||||
losetup /dev/block/loop6 /data/hpdisk
|
||||
hyperhold_device=`cat /proc/sys/kernel/hyperhold/device`
|
||||
echo /dev/block/loop6 > /proc/sys/kernel/hyperhold/device
|
||||
}
|
||||
|
||||
hp_enable()
|
||||
{
|
||||
hyperhold_enable=`cat /proc/sys/kernel/hyperhold/enable`
|
||||
echo enable > /proc/sys/kernel/hyperhold/enable
|
||||
}
|
||||
|
||||
zram_init()
|
||||
{
|
||||
zram0_group=`cat /sys/block/zram0/group`
|
||||
zram0_disksize=`cat /sys/block/zram0/disksize`
|
||||
echo readwrite > /sys/block/zram0/group
|
||||
echo 512M > /sys/block/zram0/disksize
|
||||
}
|
||||
|
||||
zram_enable()
|
||||
{
|
||||
mkswap /dev/block/zram0
|
||||
swapon /dev/block/zram0
|
||||
aa start -b com.ohos.settings -a com.ohos.settings.MainAbility
|
||||
aa start -b ohos.samples.airquality -a ohos.samples.airquality.default
|
||||
aa start -b ohos.samples.ecg -a ohos.samples.ecg.default
|
||||
aa start -b ohos.samples.flashlight -a ohos.samples.flashlight.default
|
||||
aa start -b ohos.samples.clock -a ohos.samples.clock.default
|
||||
|
||||
}
|
||||
|
||||
echo "***************************ESWAP INIT START***************************"
|
||||
free -m
|
||||
pre_condition
|
||||
hp_init
|
||||
hp_enable
|
||||
zram_init
|
||||
zram_enable
|
||||
echo "***************************ESWAP INIT END***************************"
|
||||
@@ -0,0 +1,43 @@
|
||||
#!/bin/sh
|
||||
################################################################################
|
||||
#
|
||||
# Copyright (C) 2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
################################################################################
|
||||
# File: enhancedswap_t_uninit.sh
|
||||
#
|
||||
# Description: enhancedswap_t testsuite uninit script
|
||||
#
|
||||
# Authors: Ma Feng - mafeng.ma@huawei.com
|
||||
#
|
||||
# History: Mar 24 2022 - init scripts
|
||||
#
|
||||
################################################################################
|
||||
|
||||
uninit_platform()
|
||||
{
|
||||
losetup -d /dev/block/loop6
|
||||
echo ${hyperhold_device} > /proc/sys/kernel/hyperhold/device
|
||||
echo ${hyperhold_enable} > /proc/sys/kernel/hyperhold/enable
|
||||
echo ${zram0_group} > /sys/block/zram0/group
|
||||
echo ${zram0_disksize} > /sys/block/zram0/disksize
|
||||
rm -rf /data/hpdisk
|
||||
swapoff /dev/block/zram0
|
||||
echo 1 > /sys/block/zram0/reset
|
||||
}
|
||||
|
||||
echo "***************************ESWAP UNINIT START***************************"
|
||||
free -m
|
||||
uninit_platform
|
||||
echo "***************************ESWAP UNINIT END***************************"
|
||||
@@ -24,3 +24,4 @@
|
||||
#
|
||||
################################################################################
|
||||
cpusetdecouple_cpuhotplug_t
|
||||
enhancedswap_t
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
################################################################################
|
||||
#
|
||||
# Copyright (C) 2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
################################################################################
|
||||
# File: enhancedswap_t
|
||||
#
|
||||
# Description: enhanced swap testcase list
|
||||
#
|
||||
# Authors: Ma Feng - mafeng.ma@huawei.com
|
||||
#
|
||||
# History: Mar 24 2022 - init scripts
|
||||
#
|
||||
################################################################################
|
||||
enhancedswap01 enhancedswap01.sh
|
||||
enhancedswap02 enhancedswap02.sh
|
||||
enhancedswap03 enhancedswap03.sh
|
||||
enhancedswap04 enhancedswap04.sh
|
||||
enhancedswap05 enhancedswap05.sh
|
||||
Reference in New Issue
Block a user