From e29d9fabbefaf5dfc23af7acf0171d7192c525bb Mon Sep 17 00:00:00 2001 From: wulisai Date: Sat, 19 Nov 2022 09:26:48 +0800 Subject: [PATCH] add mm/memcg_control.c testcase Signed-off-by: Ke Liu --- .../testcases/bin/memory_control01.sh | 51 ++++++++++++++++++ .../testcases/bin/memory_control02.sh | 52 +++++++++++++++++++ .../testcases/bin/memory_control03.sh | 52 +++++++++++++++++++ test/moduletest/runtest/conf/OH_RK3568_config | 1 + test/moduletest/runtest/tests/memorycontrol_t | 26 ++++++++++ 5 files changed, 182 insertions(+) create mode 100644 test/moduletest/runtest/bin/memorycontrol_t/testcases/bin/memory_control01.sh create mode 100644 test/moduletest/runtest/bin/memorycontrol_t/testcases/bin/memory_control02.sh create mode 100644 test/moduletest/runtest/bin/memorycontrol_t/testcases/bin/memory_control03.sh create mode 100644 test/moduletest/runtest/tests/memorycontrol_t diff --git a/test/moduletest/runtest/bin/memorycontrol_t/testcases/bin/memory_control01.sh b/test/moduletest/runtest/bin/memorycontrol_t/testcases/bin/memory_control01.sh new file mode 100644 index 0000000..f2614fc --- /dev/null +++ b/test/moduletest/runtest/bin/memorycontrol_t/testcases/bin/memory_control01.sh @@ -0,0 +1,51 @@ +#!/bin/sh +################################################################################ +# +# 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: memory_control01.sh +# +# Description: Verify /dev/memcg/memory.app_score +# +# Authors: Wu Lisai - wulisai@huawei-partners.com +# +# History: Nov 18 2022 - init scripts +# +################################################################################ +source tst_oh.sh + +do_setup() +{ + zcat /proc/config.gz | grep CONFIG_HYPERHOLD_MEMCG=y || tst_res TCONF "CONFIG_HYPERHOLD_MEMCG=y not satisfied!" +} + +do_test() +{ + tst_res TINFO "Start to verify mem ." + + mem=$(cat /dev/memcg/memory.app_score) + echo $mem + if [ "$mem"x = "300"x ]; then + tst_res TPASS "memory.app_score value correct." + else + tst_res TFAIL "memory.app_score value incorrect." + fi +} + +do_clean() +{ + +} + +do_setup +do_test +do_clean +tst_exit diff --git a/test/moduletest/runtest/bin/memorycontrol_t/testcases/bin/memory_control02.sh b/test/moduletest/runtest/bin/memorycontrol_t/testcases/bin/memory_control02.sh new file mode 100644 index 0000000..95ae4fa --- /dev/null +++ b/test/moduletest/runtest/bin/memorycontrol_t/testcases/bin/memory_control02.sh @@ -0,0 +1,52 @@ +#!/bin/sh +################################################################################ +# +# 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: memory_control02.sh +# +# Description: Verify /dev/memcg/memory.ub_ufs2zram_ratio +# +# Authors: Wu Lisai - wulisai@huawei-partners.com +# +# History: Nov 18 2022 - init scripts +# +################################################################################ +source tst_oh.sh + +do_setup() +{ + zcat /proc/config.gz | grep CONFIG_HYPERHOLD_MEMCG=y || tst_res TCONF "CONFIG_HYPERHOLD_MEMCG=y not satisfied!" +} + +do_test() +{ + tst_res TINFO "Start to verify mem ." + + mem=$(cat /dev/memcg/memory.ub_ufs2zram_ratio) + + if [ "$mem"x = "0"x ]; then + tst_res TPASS "memory_control default value correct." + else + tst_res TFAIL "memory_control default value incorrect." + fi + +} + +do_clean() +{ + +} + +do_setup +do_test +do_clean +tst_exit diff --git a/test/moduletest/runtest/bin/memorycontrol_t/testcases/bin/memory_control03.sh b/test/moduletest/runtest/bin/memorycontrol_t/testcases/bin/memory_control03.sh new file mode 100644 index 0000000..41b14b1 --- /dev/null +++ b/test/moduletest/runtest/bin/memorycontrol_t/testcases/bin/memory_control03.sh @@ -0,0 +1,52 @@ +#!/bin/sh +################################################################################ +# +# 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: memory_control03.sh +# +# Description: Verify /dev/memcg/memory.name +# +# Authors: Wu Lisai - wulisai@huawei-partners.com +# +# History: Nov 18 2022 - init scripts +# +################################################################################ +source tst_oh.sh + +do_setup() +{ + zcat /proc/config.gz | grep CONFIG_HYPERHOLD_MEMCG=y || tst_res TCONF "CONFIG_HYPERHOLD_MEMCG=y not satisfied!" +} + +do_test() +{ + tst_res TINFO "Start to verify mem ." + + echo "test_cgroup" > /dev/memcg/memory.name + mem=$(cat /dev/memcg/memory.name) + echo $mem + if [ "$mem"x = "test_cgroup"x ]; then + tst_res TPASS "memory_control default value correct." + else + tst_res TFAIL "memory_control default value incorrect." + fi +} + +do_clean() +{ + +} + +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 8d0d143..6daf876 100644 --- a/test/moduletest/runtest/conf/OH_RK3568_config +++ b/test/moduletest/runtest/conf/OH_RK3568_config @@ -31,3 +31,4 @@ enhancedf2fs_t mem_debug_t rss_monitor_t purgeable_t +memorycontrol_t diff --git a/test/moduletest/runtest/tests/memorycontrol_t b/test/moduletest/runtest/tests/memorycontrol_t new file mode 100644 index 0000000..a810a9b --- /dev/null +++ b/test/moduletest/runtest/tests/memorycontrol_t @@ -0,0 +1,26 @@ +################################################################################ +# +# 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: memorycontrol_t +# +# Description: memorycontrol_t testcase list +# +# Authors: Wu Lisai - wulisai@huawei-partners.com +# +# History: Nov 18 2022 - init scripts +# +################################################################################ + +memory_control01 memory_control01.sh +memory_control02 memory_control02.sh +memory_control03 memory_control03.sh + -- Gitee