public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Li Wang <liwang@redhat.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH 5/6] syscalls/madvise05: Convert to new test API
Date: Thu, 12 May 2016 16:49:52 +0800	[thread overview]
Message-ID: <1463042993-398-5-git-send-email-liwang@redhat.com> (raw)
In-Reply-To: <1463042993-398-4-git-send-email-liwang@redhat.com>

Signed-off-by: Li Wang <liwang@redhat.com>
---
 testcases/kernel/syscalls/madvise/madvise05.c | 64 +++++++++------------------
 1 file changed, 20 insertions(+), 44 deletions(-)

diff --git a/testcases/kernel/syscalls/madvise/madvise05.c b/testcases/kernel/syscalls/madvise/madvise05.c
index cdbc26f..612c967 100644
--- a/testcases/kernel/syscalls/madvise/madvise05.c
+++ b/testcases/kernel/syscalls/madvise/madvise05.c
@@ -26,60 +26,36 @@
 
 #include <sys/mman.h>
 #include <errno.h>
-
-#include "test.h"
-#include "safe_macros.h"
+#include "tst_test.h"
 
 #define ALLOC_SIZE (32 * 1024 * 1024)
 
-static void setup(void);
-static void cleanup(void);
-
-char *TCID = "madvise05";
-int TST_TOTAL = 1;
-
-int main(int argc, char *argv[])
+static void verify_madvise(void)
 {
-	int lc;
 	void *p;
 
-	tst_parse_opts(argc, argv, NULL, NULL);
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		p = SAFE_MMAP(cleanup, NULL, ALLOC_SIZE, PROT_READ,
+	p = SAFE_MMAP(NULL, ALLOC_SIZE, PROT_READ,
 			MAP_PRIVATE | MAP_ANONYMOUS | MAP_POPULATE, -1, 0);
-		TEST(mprotect(p, ALLOC_SIZE, PROT_NONE));
-		if (TEST_RETURN == -1)
-			tst_brkm(TBROK | TTERRNO, cleanup, "mprotect failed");
-		TEST(madvise(p, ALLOC_SIZE, MADV_WILLNEED));
-		SAFE_MUNMAP(cleanup, p, ALLOC_SIZE);
 
-		if (TEST_RETURN == 0)
-			continue;
+	TEST(mprotect(p, ALLOC_SIZE, PROT_NONE));
+	if (TEST_RETURN == -1)
+		tst_brk(TBROK | TTERRNO, "mprotect failed");
+	TEST(madvise(p, ALLOC_SIZE, MADV_WILLNEED));
+	SAFE_MUNMAP(p, ALLOC_SIZE);
 
-		if (TEST_ERRNO == EBADF)
-			tst_brkm(TCONF, cleanup, "CONFIG_SWAP=n");
-		else
-			tst_brkm(TBROK | TTERRNO, cleanup, "madvise failed");
+	if (TEST_RETURN == 0) {
+		tst_res(TPASS, "issue has not been reproduced");
+		return;
 	}
 
-	tst_resm(TPASS, "issue has not been reproduced");
-
-	cleanup();
-	tst_exit();
+	if (TEST_ERRNO == EBADF)
+		tst_brk(TCONF, "CONFIG_SWAP=n");
+	else
+		tst_brk(TBROK | TTERRNO, "madvise failed");
 }
 
-static void setup(void)
-{
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
-	if (tst_kvercmp(3, 9, 0) < 0)
-		tst_brkm(TCONF, NULL, "madvise(MADV_WILLNEED) swap file "
-			"prefetch available only since 3.9");
-	TEST_PAUSE;
-}
-
-static void cleanup(void)
-{
-}
+static struct tst_test test = {
+	.tid = "madvice05",
+	.min_kver = "3.9.0",
+	.test_all = verify_madvise,
+};
-- 
1.8.3.1


  reply	other threads:[~2016-05-12  8:49 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-12  8:49 [LTP] [PATCH 1/6] syscalls/madvise01: Convert to new test API Li Wang
2016-05-12  8:49 ` [LTP] [PATCH 2/6] syscalls/madvise02: " Li Wang
2016-05-12  8:49   ` [LTP] [PATCH 3/6] syscalls/madvise03: " Li Wang
2016-05-12  8:49     ` [LTP] [PATCH 4/6] syscalls/madvise04: " Li Wang
2016-05-12  8:49       ` Li Wang [this message]
2016-05-12  8:49         ` [LTP] [PATCH 6/6] syscalls/madvise06: " Li Wang
2016-05-17 17:43         ` [LTP] [PATCH 5/6] syscalls/madvise05: " Cyril Hrubis
2016-05-17 17:28       ` [LTP] [PATCH 4/6] syscalls/madvise04: " Cyril Hrubis
2016-05-17 16:20     ` [LTP] [PATCH 3/6] syscalls/madvise03: " Cyril Hrubis
2016-05-18  9:04       ` Li Wang
2016-05-19 10:12       ` Li Wang
2016-05-19 10:19         ` Cyril Hrubis
2016-05-17 15:54   ` [LTP] [PATCH 2/6] syscalls/madvise02: " Cyril Hrubis
2016-05-17 15:21 ` [LTP] [PATCH 1/6] syscalls/madvise01: " Cyril Hrubis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1463042993-398-5-git-send-email-liwang@redhat.com \
    --to=liwang@redhat.com \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox