From: Li Wang <liwang@redhat.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH 6/6] syscalls/madvise06: Convert to new test API
Date: Thu, 12 May 2016 16:49:53 +0800 [thread overview]
Message-ID: <1463042993-398-6-git-send-email-liwang@redhat.com> (raw)
In-Reply-To: <1463042993-398-5-git-send-email-liwang@redhat.com>
Signed-off-by: Li Wang <liwang@redhat.com>
---
testcases/kernel/syscalls/madvise/madvise06.c | 64 +++++++++------------------
1 file changed, 21 insertions(+), 43 deletions(-)
diff --git a/testcases/kernel/syscalls/madvise/madvise06.c b/testcases/kernel/syscalls/madvise/madvise06.c
index 366827c..6b081fd 100644
--- a/testcases/kernel/syscalls/madvise/madvise06.c
+++ b/testcases/kernel/syscalls/madvise/madvise06.c
@@ -33,39 +33,15 @@
* mm: madvise: fix MADV_WILLNEED on shmem swapouts
*/
-#include <stdio.h>
#include <errno.h>
#include <sys/sysinfo.h>
-
-#include "test.h"
-#include "safe_macros.h"
-
-char *TCID = "madvise06";
-int TST_TOTAL = 1;
+#include "tst_test.h"
#define GB_SZ (1024*1024*1024)
static long dst_max;
static int pg_sz;
-static void setup(void);
-static int get_page_fault_num(void);
-static void test_advice_willneed(void);
-
-int main(int argc, char *argv[])
-{
- int lc;
-
- tst_parse_opts(argc, argv, NULL, NULL);
-
- setup();
-
- for (lc = 0; TEST_LOOPING(lc); lc++)
- test_advice_willneed();
-
- tst_exit();
-}
-
static void setup(void)
{
struct sysinfo sys_buf;
@@ -73,25 +49,21 @@ static void setup(void)
sysinfo(&sys_buf);
if (sys_buf.totalram < 2L * GB_SZ)
- tst_brkm(TCONF, NULL, "Test requires more than 2GB of RAM");
+ tst_brk(TCONF, "Test requires more than 2GB of RAM");
if (sys_buf.totalram > 100L * GB_SZ)
- tst_brkm(TCONF, NULL, "System RAM is too large, skip test");
+ tst_brk(TCONF, "System RAM is too large, skip test");
dst_max = sys_buf.totalram / GB_SZ;
- tst_resm(TINFO, "dst_max = %ld", dst_max);
+ tst_res(TINFO, "dst_max = %ld", dst_max);
pg_sz = getpagesize();
-
- tst_sig(NOFORK, DEF_HANDLER, NULL);
-
- TEST_PAUSE;
}
static int get_page_fault_num(void)
{
int pg;
- SAFE_FILE_SCANF(NULL, "/proc/self/stat",
+ SAFE_FILE_SCANF("/proc/self/stat",
"%*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %d",
&pg);
@@ -107,13 +79,13 @@ static void test_advice_willneed(void)
int page_fault_num_2;
/* allocate source memory (1GB only) */
- src = SAFE_MMAP(NULL, NULL, 1 * GB_SZ, PROT_READ | PROT_WRITE,
+ src = SAFE_MMAP(NULL, 1 * GB_SZ, PROT_READ | PROT_WRITE,
MAP_SHARED | MAP_ANONYMOUS,
-1, 0);
/* allocate destination memory (array) */
for (i = 0; i < dst_max; ++i)
- dst[i] = SAFE_MMAP(NULL, NULL, 1 * GB_SZ,
+ dst[i] = SAFE_MMAP(NULL, 1 * GB_SZ,
PROT_READ | PROT_WRITE,
MAP_SHARED | MAP_ANONYMOUS,
-1, 0);
@@ -122,28 +94,34 @@ static void test_advice_willneed(void)
for (i = 0; i < dst_max; ++i)
memmove(dst[i], src, 1 * GB_SZ);
- tst_resm(TINFO, "PageFault(no madvice): %d", get_page_fault_num());
+ tst_res(TINFO, "PageFault(no madvice): %d", get_page_fault_num());
/* Do madvice() to dst[0] */
TEST(madvise(dst[0], pg_sz, MADV_WILLNEED));
if (TEST_RETURN == -1)
- tst_brkm(TBROK | TERRNO, NULL, "madvise failed");
+ tst_brk(TBROK | TERRNO, "madvise failed");
page_fault_num_1 = get_page_fault_num();
- tst_resm(TINFO, "PageFault(madvice / no mem access): %d",
+ tst_res(TINFO, "PageFault(madvice / no mem access): %d",
page_fault_num_1);
*dst[0] = 'a';
page_fault_num_2 = get_page_fault_num();
- tst_resm(TINFO, "PageFault(madvice / mem access): %d",
+ tst_res(TINFO, "PageFault(madvice / mem access): %d",
page_fault_num_2);
if (page_fault_num_1 != page_fault_num_2)
- tst_resm(TFAIL, "Bug has been reproduced");
+ tst_res(TFAIL, "Bug has been reproduced");
else
- tst_resm(TPASS, "Regression test pass");
+ tst_res(TPASS, "Regression test pass");
- SAFE_MUNMAP(NULL, src, 1 * GB_SZ);
+ SAFE_MUNMAP(src, 1 * GB_SZ);
for (i = 0; i < dst_max; ++i)
- SAFE_MUNMAP(NULL, dst[i], 1 * GB_SZ);
+ SAFE_MUNMAP(dst[i], 1 * GB_SZ);
}
+
+static struct tst_test test = {
+ .tid = "madvice06",
+ .test_all = test_advice_willneed,
+ .setup = setup,
+};
--
1.8.3.1
next prev parent 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 ` [LTP] [PATCH 5/6] syscalls/madvise05: " Li Wang
2016-05-12 8:49 ` Li Wang [this message]
2016-05-17 17:43 ` 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-6-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