• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0
2  * Copyright (C) 2011  Red Hat, Inc.
3  * Copyright (C) 2021 Xie Ziyao <xieziyao@huawei.com>
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)13 static void consume_mb(int consume_nr)
14 {
15 	void *ptr;
16 	size_t size;
17 	unsigned long vmswap_size;
18 
19 	size = consume_nr * 1024 * 1024;
20 	ptr = SAFE_MALLOC(size);
21 	memset(ptr, 0, size);
22 
23 	SAFE_FILE_LINES_SCANF("/proc/self/status", "VmSwap: %lu", &vmswap_size);
24 	if (vmswap_size > 0)
25 		tst_brk(TBROK, "VmSwap is not zero");
26 }
27 
is_in_delta(long value)28 static int is_in_delta(long value)
29 {
30 	return (value >= -DELTA_MAX && value <= DELTA_MAX);
31 }
32 
33 #endif //LTP_GETRUSAGE03_H
34