1 /* SPDX-License-Identifier: GPL-2.0-only 2 * Copyright (C) 2011 Red Hat, Inc. 3 * Copyright (C) 2021 Xie Ziyao <[email protected]> 4 */ 5 6 #ifndef LTP_GETRUSAGE03_H 7 #define LTP_GETRUSAGE03_H 8 9 #include "tst_test.h" 10 11 #define DELTA_MAX 20480 12 consume_mb(int consume_nr)13static void consume_mb(int consume_nr) 14 { 15 void *ptr; 16 size_t size; 17 unsigned long vmswap_size; 18 19 mlockall(MCL_CURRENT|MCL_FUTURE); 20 21 size = consume_nr * 1024 * 1024; 22 ptr = SAFE_MALLOC(size); 23 memset(ptr, 0, size); 24 25 SAFE_FILE_LINES_SCANF("/proc/self/status", "VmSwap: %lu", &vmswap_size); 26 if (vmswap_size > 0) 27 tst_brk(TBROK, "VmSwap is not zero"); 28 } 29 is_in_delta(long value)30static int is_in_delta(long value) 31 { 32 return (value >= -DELTA_MAX && value <= DELTA_MAX); 33 } 34 35 #endif //LTP_GETRUSAGE03_H 36