1f08c3bdfSopenharmony_ci#!/bin/sh 2f08c3bdfSopenharmony_ci# SPDX-License-Identifier: GPL-2.0-or-later 3f08c3bdfSopenharmony_ci# Copyright (c) 2009 FUJITSU LIMITED 4f08c3bdfSopenharmony_ci# Copyright (c) 2016 Cyril Hrubis <chrubis@suse.cz> 5f08c3bdfSopenharmony_ci# Copyright (c) 2021 Joerg Vehlow <joerg.vehlow@aox-tech.de> 6f08c3bdfSopenharmony_ci# 7f08c3bdfSopenharmony_ci# Author: Li Zefan <lizf@cn.fujitsu.com> 8f08c3bdfSopenharmony_ci# Restructure for LTP: Shi Weihua <shiwh@cn.fujitsu.com> 9f08c3bdfSopenharmony_ci# Added memcg enable/disable functionality: Rishikesh K Rajak <risrajak@linux.vnet.ibm.com> 10f08c3bdfSopenharmony_ci 11f08c3bdfSopenharmony_ciMEMCG_TESTFUNC=do_test 12f08c3bdfSopenharmony_ciMEMCG_SHMMAX=1 13f08c3bdfSopenharmony_ciTST_TEST_DATA="--mmap-anon --mmap-file --shm" 14f08c3bdfSopenharmony_ci 15f08c3bdfSopenharmony_cido_test() 16f08c3bdfSopenharmony_ci{ 17f08c3bdfSopenharmony_ci ROD echo $MEMORY_LIMIT \> memory.limit_in_bytes 18f08c3bdfSopenharmony_ci 19f08c3bdfSopenharmony_ci start_memcg_process $2 -s ${MEMORY_TO_ALLOCATE} 20f08c3bdfSopenharmony_ci ROD echo $MEMCG_PROCESS_PID \> tasks 21f08c3bdfSopenharmony_ci 22f08c3bdfSopenharmony_ci signal_memcg_process ${MEMORY_TO_ALLOCATE} 23f08c3bdfSopenharmony_ci signal_memcg_process ${MEMORY_TO_ALLOCATE} 24f08c3bdfSopenharmony_ci 25f08c3bdfSopenharmony_ci stop_memcg_process 26f08c3bdfSopenharmony_ci 27f08c3bdfSopenharmony_ci failcnt=$(cat memory.failcnt) 28f08c3bdfSopenharmony_ci if [ $failcnt -gt 0 ]; then 29f08c3bdfSopenharmony_ci tst_res TPASS "memory.failcnt is $failcnt, > 0 as expected" 30f08c3bdfSopenharmony_ci else 31f08c3bdfSopenharmony_ci tst_res TFAIL "memory.failcnt is $failcnt, <= 0 expected" 32f08c3bdfSopenharmony_ci fi 33f08c3bdfSopenharmony_ci} 34f08c3bdfSopenharmony_ci 35f08c3bdfSopenharmony_ci. memcg_lib.sh 36f08c3bdfSopenharmony_ci 37f08c3bdfSopenharmony_ciMEMORY_LIMIT=$PAGESIZE 38f08c3bdfSopenharmony_ciMEMORY_TO_ALLOCATE=$((MEMORY_LIMIT * 2)) 39f08c3bdfSopenharmony_ci 40f08c3bdfSopenharmony_citst_run 41