From cff0168a3caabdb89a87787fdf3aaec9b31ed649 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=91=A3=E6=A3=AE=E6=B5=A9?= <2506549626@qq.com> Date: Wed, 2 Nov 2022 11:19:04 +0800 Subject: [PATCH] add purgeable memory testcase Signed-off-by: Ke Liu --- .../testcases/bin/purgeable_mem01.sh | 65 +++++++++++++++++ .../testcases/bin/purgeable_mem02.sh | 71 +++++++++++++++++++ .../testcases/bin/purgeable_mem03.sh | 71 +++++++++++++++++++ test/moduletest/runtest/conf/OH_RK3568_config | 1 + test/moduletest/runtest/tests/purgeable_t | 24 +++++++ 5 files changed, 232 insertions(+) create mode 100644 test/moduletest/runtest/bin/purgeable_t/testcases/bin/purgeable_mem01.sh create mode 100644 test/moduletest/runtest/bin/purgeable_t/testcases/bin/purgeable_mem02.sh create mode 100644 test/moduletest/runtest/bin/purgeable_t/testcases/bin/purgeable_mem03.sh create mode 100644 test/moduletest/runtest/tests/purgeable_t diff --git a/test/moduletest/runtest/bin/purgeable_t/testcases/bin/purgeable_mem01.sh b/test/moduletest/runtest/bin/purgeable_t/testcases/bin/purgeable_mem01.sh new file mode 100644 index 0000000..376b939 --- /dev/null +++ b/test/moduletest/runtest/bin/purgeable_t/testcases/bin/purgeable_mem01.sh @@ -0,0 +1,65 @@ +#!/bin/sh +################################################################################ +# +# Copyright (C) 2022 Huawei Device Co., Ltd. +# SPDX-License-Identifier: GPL-2.0 +# +# Legacy blkg rwstat helpers enabled by CONFIG_BLK_CGROUP_RWSTAT. +# Do not use in new code. +# +# 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: purgeable_mem01.sh +# +# Description: Static memory reservation query test +# +# Authors: Ke Liu - liuke94@huawei.com +# +# History: Nov 2 2022 - init scripts +# +################################################################################ +source tst_oh.sh + +do_setup() +{ + zcat /proc/config.gz | grep CONFIG_MEM_PURGEABLE=y || tst_res TCONF "CONFIG_MEM_PURGEABLE=y not satisfied!" +} + +do_test() +{ + local testpath=$(find / -name purgeable_cpp_test | grep -v find) + if [ ! $testpath ];then + tst_res TFAIL "can not find purgeable_cpp_test!" + fi + (cd $(echo ${testpath%purgeable_cpp_test});chmod 777 purgeable_cpp_test;./purgeable_cpp_test >mylog.log) + if [ $(grep -c -i "ok\|success\|true" ${testpath%purgeable_cpp_test}/mylog.log) -ne '0' ];then + tst_res TINFO "purgeable_cpp_test executed success." + else + tst_res TFAIL "purgeable_cpp_test executed fail!" + fi + if [ $(grep -c -i "error\|fail\|false" ${testpath%purgeable_cpp_test}/mylog.log) -ne '0' ];then + tst_res TFAIL "purgeable_cpp_test test error!" + else + tst_res TPASS "purgeable_cpp_test test pass." + fi + rm ${testpath%purgeable_cpp_test}/mylog.log + ls ${testpath%purgeable_cpp_test} >log2.log + local lastxml=$(tac log2.log | grep purgeable_cpp_test | grep xml| head -n 1) + rm ${testpath%purgeable_cpp_test}${lastxml} +} + +do_clean() +{ + rm log2.log +} + + +do_setup +do_test +do_clean +tst_exit diff --git a/test/moduletest/runtest/bin/purgeable_t/testcases/bin/purgeable_mem02.sh b/test/moduletest/runtest/bin/purgeable_t/testcases/bin/purgeable_mem02.sh new file mode 100644 index 0000000..cfdcfb1 --- /dev/null +++ b/test/moduletest/runtest/bin/purgeable_t/testcases/bin/purgeable_mem02.sh @@ -0,0 +1,71 @@ +#!/bin/sh +################################################################################ +# +# Copyright (C) 2022 Huawei Device Co., Ltd. +# SPDX-License-Identifier: GPL-2.0 +# +# Legacy blkg rwstat helpers enabled by CONFIG_BLK_CGROUP_RWSTAT. +# Do not use in new code. +# +# 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: purgeable_mem02.sh +# +# Description: Static memory reservation query test +# +# Authors: Ke Liu - liuke94@huawei.com +# +# History: Nov 2 2022 - init scripts +# +################################################################################ +source tst_oh.sh + +do_setup() +{ + zcat /proc/config.gz | grep CONFIG_MEM_PURGEABLE=y || tst_res TCONF "CONFIG_MEM_PURGEABLE=y not satisfied!" +} + +do_test() +{ + local testpath=$(find / -name purgeable_cpp_test | grep -v find) + if [ ! $testpath ];then + tst_res TFAIL "can not find purgeable_cpp_test!" + fi + (cd $(echo ${testpath%purgeable_cpp_test});chmod 777 purgeable_cpp_test;./purgeable_cpp_test &>/dev/null &) + local pid=$(pidof purgeable_cpp_test) + while [ "$pid" -eq '0' ] + do + pid=$(pidof purgeable_cpp_test) + done + while [ "$pid" -ne '0' ] + do + cat /proc/meminfo | grep -i purg | grep -v grep | grep -v Name >>mem.log + pid=$(pidof purgeable_cpp_test) + done + cat mem.log | grep -v '0 kB' >mem1.log + if [ -s mem1.log ];then + tst_res TPASS "Purgeable memory reservation query test pass." + else + tst_res TFAIL "Purgeable memory reservation query test error!" + fi + ls ${testpath%purgeable_cpp_test} >log2.log + local lastxml=$(tac log2.log | grep purgeable_cpp_test | grep xml| head -n 1) + rm ${testpath%purgeable_cpp_test}${lastxml} +} + +do_clean() +{ + rm mem.log + rm mem1.log + rm log2.log +} + +do_setup +do_test +do_clean +tst_exit diff --git a/test/moduletest/runtest/bin/purgeable_t/testcases/bin/purgeable_mem03.sh b/test/moduletest/runtest/bin/purgeable_t/testcases/bin/purgeable_mem03.sh new file mode 100644 index 0000000..3ef4a69 --- /dev/null +++ b/test/moduletest/runtest/bin/purgeable_t/testcases/bin/purgeable_mem03.sh @@ -0,0 +1,71 @@ +#!/bin/sh +################################################################################ +# +# Copyright (C) 2022 Huawei Device Co., Ltd. +# SPDX-License-Identifier: GPL-2.0 +# +# Legacy blkg rwstat helpers enabled by CONFIG_BLK_CGROUP_RWSTAT. +# Do not use in new code. +# +# 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: purgeable_mem03.sh +# +# Description: Static memory reservation query test +# +# Authors: Ke Liu - liuke94@huawei.com +# +# History: Nov 2 2022 - init scripts +# +################################################################################ +source tst_oh.sh + +do_setup() +{ + zcat /proc/config.gz | grep CONFIG_MEM_PURGEABLE=y || tst_res TCONF "CONFIG_MEM_PURGEABLE=y not satisfied!" +} + +do_test() +{ + local testpath=$(find / -name purgeable_cpp_test | grep -v find) + if [ ! $testpath ];then + tst_res TFAIL "can not find purgeable_cpp_test!" + fi + (cd $(echo ${testpath%purgeable_cpp_test});chmod 777 purgeable_cpp_test;./purgeable_cpp_test &>/dev/null &) + local pid= $(pidof purgeable_cpp_test) + while [ "$pid" -eq '0' ] + do + pid=$(pidof purgeable_cpp_test) + done + while [ "$pid" -ne '0' ] + do + cat /proc/${pid}/status | grep -i purg | grep -v grep | grep -v Name >>mem.log + pid=$(pidof purgeable_cpp_test) + done + cat mem.log | grep -v '0 kB' >mem1.log + if [ -s mem1.log ];then + tst_res TPASS "Purgeable memory reservation query test pass." + else + tst_res TFAIL "Purgeable memory reservation query test error!" + fi + ls ${testpath%purgeable_cpp_test} >log2.log + local lastxml=$(tac log2.log | grep purgeable_cpp_test | grep xml| head -n 1) + rm ${testpath%purgeable_cpp_test}${lastxml} +} + +do_clean() +{ + rm mem.log + rm mem1.log + rm log2.log +} + +do_setup +do_test +do_clean +tst_exit diff --git a/test/moduletest/runtest/conf/OH_RK3568_config b/test/moduletest/runtest/conf/OH_RK3568_config index e01c964..8d0d143 100644 --- a/test/moduletest/runtest/conf/OH_RK3568_config +++ b/test/moduletest/runtest/conf/OH_RK3568_config @@ -30,3 +30,4 @@ sched_rtg_t enhancedf2fs_t mem_debug_t rss_monitor_t +purgeable_t diff --git a/test/moduletest/runtest/tests/purgeable_t b/test/moduletest/runtest/tests/purgeable_t new file mode 100644 index 0000000..1d11906 --- /dev/null +++ b/test/moduletest/runtest/tests/purgeable_t @@ -0,0 +1,24 @@ +################################################################################ +## +## Copyright (C) 2022 Huawei Device Co., Ltd. +## SPDX-License-Identifier: GPL-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: purgeable_t +# +# Description: cpuisolation testcase list +# +# Authors: Ke Liu - liuke94@huawei.com +# +# History: Nov 2 2022 - init scripts +# +################################################################################ +purgeable_mem01 purgeable_mem01.sh +purgeable_mem02 purgeable_mem02.sh +purgeable_mem03 purgeable_mem03.sh -- Gitee