1#!/bin/sh 2# SPDX-License-Identifier: GPL-2.0-or-later 3# Copyright (c) 2009 FUJITSU LIMITED 4# Copyright (c) 2016 Cyril Hrubis <chrubis@suse.cz> 5# Copyright (c) 2021 Joerg Vehlow <joerg.vehlow@aox-tech.de> 6# 7# Author: Li Zefan <lizf@cn.fujitsu.com> 8# Restructure for LTP: Shi Weihua <shiwh@cn.fujitsu.com> 9# Added memcg enable/disable functionality: Rishikesh K Rajak <risrajak@linux.vnet.ibm.com> 10 11MEMCG_TESTFUNC=test 12TST_CNT=6 13 14. memcg_lib.sh 15 16# Test memory.force_empty 17test1() 18{ 19 start_memcg_process --mmap-anon -s $PAGESIZE 20 echo $MEMCG_PROCESS_PID > tasks 21 signal_memcg_process $PAGESIZE 22 echo $MEMCG_PROCESS_PID > ../tasks 23 24 # This expects that there is swap configured 25 EXPECT_PASS echo 1 \> memory.force_empty 26 27 stop_memcg_process $pid 28} 29 30test2() 31{ 32 EXPECT_PASS echo 0 \> memory.force_empty 33} 34 35test3() 36{ 37 EXPECT_PASS echo 1.0 \> memory.force_empty 38} 39 40test4() 41{ 42 EXPECT_PASS echo 1xx \> memory.force_empty 43} 44 45test5() 46{ 47 EXPECT_PASS echo xx \> memory.force_empty 48} 49 50test6() 51{ 52 # writing to non-empty top mem cgroup's force_empty 53 # should return failure 54 EXPECT_FAIL echo 1 \> /dev/memcg/memory.force_empty 55} 56 57tst_run 58