From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH V3 3/3] syscalls/madvise02: reconstruct and convert to new API
Date: Mon, 6 Jun 2016 15:03:07 +0200 [thread overview]
Message-ID: <20160606130307.GB20756@rei> (raw)
In-Reply-To: <1464157779-6883-3-git-send-email-liwang@redhat.com>
Hi!
> -#if defined(MADV_MERGEABLE)
> -static void test_mergeable_einval(void)
> -{
> - char *file;
> -
> - if (access(KSM_SYS_DIR, F_OK) >= 0) {
> - tst_resm(TCONF, "kernel configured with CONFIG_KSM, "
> - "skip EINVAL test for MADV_MERGEABLE.");
> - return;
> + enable = 1;
> + file = tmp_file;
> +
> + switch (i) {
> + case 0:
> + /* Test for addr EINVAL */
> + file = tmp_file + 100;
> + break;
> +
> + case 1:
> + /* Test for advice EINVAL */
> + break;
> +
> + case 2:
> + enable = 0;
> + /* Test for lock EINVAL */
> + #if !defined(UCLINUX)
> + if (mlock(file, st.st_size) < 0)
> + tst_brk(TBROK | TERRNO, "mlock failed");
> + enable = 1;
> + #endif /* if !defined(UCLINUX) */
> + break;
> +
> + case 3:
> + case 4:
> + /* Test for MADV_MERGEABLE EINVAL */
> + if ((tst_kvercmp(2, 6, 32)) < 0)
> + enable = 0;
> +
> + if (access(KSM_SYS_DIR, F_OK) == 0)
> + /* kernel configured with CONFIG_KSM,
> + * skip EINVAL test for MADV_MERGEABLE. */
> + enable = 0;
> + break;
> +
> + case 5:
> + /* Test for MADV_WILLNEED EBADF */
> + ptr_addr = SAFE_MALLOC(st.st_size);
> + /* Take temporary pointer for later use, freeing up the
> + * original one. */
> + tmp_addr = ptr_addr;
> + tmp_addr =
> + (char *)(((unsigned long)tmp_addr + pagesize - 1) & ~(pagesize - 1));
> + file = tmp_addr;
> +
> + /* In kernel commit 1998cc0, madvise(MADV_WILLNEED) to
> + * anon mem doesn't return -EBADF now, as now we support
> + * swap prefretch. */
> + if ((tst_kvercmp(3, 9, 0)) > 0)
> + enable = 0;
> + break;
> +
> + case 6:
> + /* Test for MADV_NORMAL ENOMEM */
> + SAFE_MUNMAP(file + st.st_size - pagesize, pagesize);
> + break;
If you need to do the testcase filter, you should:
1) Do the switch() over tc->advice
2) Call it once in the setup() and set tc->skipp flag rather
than doing this on each iteration.
--
Cyril Hrubis
chrubis@suse.cz
next prev parent reply other threads:[~2016-06-06 13:03 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-25 6:29 [LTP] [PATCH V3 1/3] ltp/lapi: add some madvices definition Li Wang
2016-05-25 6:29 ` [LTP] [PATCH V3 2/3] syscalls/madvise01: reconstruct and convert to new API Li Wang
2016-05-25 6:29 ` [LTP] [PATCH V3 3/3] syscalls/madvise02: " Li Wang
2016-06-06 13:03 ` Cyril Hrubis [this message]
2016-06-01 14:24 ` [LTP] [PATCH V3 2/3] syscalls/madvise01: " Cyril Hrubis
2016-06-01 14:22 ` [LTP] [PATCH V3 1/3] ltp/lapi: add some madvices definition 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=20160606130307.GB20756@rei \
--to=chrubis@suse.cz \
--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