[PATCH] syscalls/madvise: Make use of .min_swap_avail and .min_mem_avail

Cyril Hrubis <[email protected]>
Newsgroups gmane.linux.ltp
Message-ID <[email protected]>
Move the runtime checks for minimal amount of memory or swap from the
test setup to the tst_test structure.

Signed-off-by: Cyril Hrubis <[email protected]>
---
 testcases/kernel/syscalls/madvise/madvise06.c | 16 ++--------------
 testcases/kernel/syscalls/madvise/madvise09.c |  7 +------
 2 files changed, 3 insertions(+), 20 deletions(-)

diff --git a/testcases/kernel/syscalls/madvise/madvise06.c b/testcases/kernel/syscalls/madvise/madvise06.c
index 799e5398a..15ef863a8 100644
--- a/testcases/kernel/syscalls/madvise/madvise06.c
+++ b/testcases/kernel/syscalls/madvise/madvise06.c
@@ -95,20 +95,6 @@ static void setup(void)
 	sync();
 	SAFE_FILE_PRINTF(drop_caches_fname, "3");
 
-	long long avail_mem = tst_available_mem();
-	long long avail_swap = tst_available_swap();
-	long long chunk_kb = 2 * CHUNK_SZ / 1024;
-
-	if (avail_mem < chunk_kb) {
-		tst_brk(TCONF, "System RAM is too small %llikB (%llikB needed)",
-			avail_mem, chunk_kb);
-	}
-
-	if (avail_swap < chunk_kb) {
-		tst_brk(TCONF, "System swap is too small %llikB (%llikB needed)",
-			avail_swap, chunk_kb);
-	}
-
 	check_path("/proc/self/oom_score_adj");
 	SAFE_FILE_PRINTF("/proc/self/oom_score_adj", "%d", -1000);
 
@@ -243,6 +229,8 @@ static struct tst_test test = {
 			TST_SR_SKIP_MISSING | TST_SR_TCONF_RO},
 		{}
 	},
+	.min_mem_avail = 2 * CHUNK_SZ / TST_MB,
+	.min_swap_avail = 2 * CHUNK_SZ / TST_MB,
 	.needs_cgroup_ctrls = (const char *const []){ "memory", NULL },
 	.tags = (const struct tst_tag[]) {
 		{"linux-git", "55231e5c898c"},
diff --git a/testcases/kernel/syscalls/madvise/madvise09.c b/testcases/kernel/syscalls/madvise/madvise09.c
index 87fe096fb..182387919 100644
--- a/testcases/kernel/syscalls/madvise/madvise09.c
+++ b/testcases/kernel/syscalls/madvise/madvise09.c
@@ -269,17 +269,11 @@ retry:
 
 static void setup(void)
 {
-	long swap_total;
-
 	if (SAFE_CG_HAS(tst_cg, "memory.swap.max"))
 		swap_accounting_enabled = 1;
 	else
 		tst_res(TINFO, "Swap accounting is disabled");
 
-	SAFE_FILE_LINES_SCANF("/proc/meminfo", "SwapTotal: %ld", &swap_total);
-	if (swap_total <= 0)
-		tst_brk(TCONF, "MADV_FREE does not work without swap");
-
 	page_size = getpagesize();
 }
 
@@ -288,5 +282,6 @@ static struct tst_test test = {
 	.test_all = run,
 	.needs_root = 1,
 	.forks_child = 1,
+	.min_swap_avail = SWAP_LIMIT / TST_MB,
 	.needs_cgroup_ctrls = (const char *const []){ "memory", NULL },
 };
-- 
2.53.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.