diff --git a/testcases/kernel/syscalls/getrusage/getrusage03.h b/testcases/kernel/syscalls/getrusage/getrusage03.h index 8bee0b9e5d7..58a98b43062 100644 --- a/testcases/kernel/syscalls/getrusage/getrusage03.h +++ b/testcases/kernel/syscalls/getrusage/getrusage03.h @@ -6,10 +6,19 @@ #ifndef LTP_GETRUSAGE03_H #define LTP_GETRUSAGE03_H +#include #include "tst_test.h" #define DELTA_MAX 20480 +static void force_context_switches(int iterations) +{ + tst_res(TINFO, "Forcing context switch %d times", iterations); + + for (int i = 0; i < iterations; i++) + sched_yield(); +} + static void consume_mb(int consume_nr) { void *ptr; @@ -22,6 +31,8 @@ static void consume_mb(int consume_nr) ptr = SAFE_MALLOC(size); memset(ptr, 0, size); + force_context_switches(10); + SAFE_FILE_LINES_SCANF("/proc/self/status", "VmSwap: %lu", &vmswap_size); if (vmswap_size > 0) tst_brk(TBROK, "VmSwap is not zero");