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 0000000000000000000000000000000000000000..376b93948e49f0644138681cbcbc2b5220cb9c37 --- /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 0000000000000000000000000000000000000000..cfdcfb1d14a222d6bfa9aadc67d58e82fddc615d --- /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 0000000000000000000000000000000000000000..3ef4a694a085806c2a1e3b8c297d4347179d826c --- /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 e01c96474f60dcafe0354b9db3270bebe9cef9c5..8d0d14382a60c4450db7c9b00130b05b702f76b8 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 0000000000000000000000000000000000000000..1d1190606c21d5f634c66f6319eae61af1db3481 --- /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