mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-01-23 02:14:37 +00:00
test/zdtm/static/maps02: add MADV_WIPEONFORK testcase
In addition to that I did small non-functional corrections. Signed-off-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>
This commit is contained in:
parent
af5412a433
commit
6476488a51
2 changed files with 18 additions and 4 deletions
|
|
@ -18,6 +18,10 @@
|
|||
#define MADV_DONTDUMP 16
|
||||
#endif
|
||||
|
||||
#ifndef MADV_WIPEONFORK
|
||||
#define MADV_WIPEONFORK 18
|
||||
#endif
|
||||
|
||||
static void parse_vmflags(char *buf, unsigned long *flags, unsigned long *madv)
|
||||
{
|
||||
char *tok;
|
||||
|
|
@ -57,6 +61,8 @@ static void parse_vmflags(char *buf, unsigned long *flags, unsigned long *madv)
|
|||
*madv |= (1ul << MADV_HUGEPAGE);
|
||||
else if (_vmflag_match(tok, "nh"))
|
||||
*madv |= (1ul << MADV_NOHUGEPAGE);
|
||||
else if (_vmflag_match(tok, "wf"))
|
||||
*madv |= (1ul << MADV_WIPEONFORK);
|
||||
|
||||
/*
|
||||
* Anything else is just ignored.
|
||||
|
|
|
|||
|
|
@ -6,7 +6,11 @@
|
|||
#define MADV_DONTDUMP 16
|
||||
#endif
|
||||
|
||||
const char *test_doc = "Test shared memory with advises";
|
||||
#ifndef MADV_WIPEONFORK
|
||||
#define MADV_WIPEONFORK 18
|
||||
#endif
|
||||
|
||||
const char *test_doc = "Test private memory with advises";
|
||||
const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org>";
|
||||
|
||||
struct mmap_data {
|
||||
|
|
@ -43,12 +47,12 @@ static int alloc_anon_mmap(struct mmap_data *m, int flags, int adv)
|
|||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
struct mmap_data m[5] = {};
|
||||
struct mmap_data m[6] = {};
|
||||
size_t i;
|
||||
|
||||
test_init(argc, argv);
|
||||
|
||||
test_msg("Alloc growsdown\n");
|
||||
test_msg("Alloc dontfork\n");
|
||||
if (alloc_anon_mmap(&m[0], MAP_PRIVATE | MAP_ANONYMOUS, MADV_DONTFORK))
|
||||
return -1;
|
||||
|
||||
|
|
@ -64,10 +68,14 @@ int main(int argc, char **argv)
|
|||
if (alloc_anon_mmap(&m[3], MAP_PRIVATE | MAP_ANONYMOUS, MADV_HUGEPAGE))
|
||||
return -1;
|
||||
|
||||
test_msg("Alloc dontfork/random|mergeable\n");
|
||||
test_msg("Alloc mergeable\n");
|
||||
if (alloc_anon_mmap(&m[4], MAP_PRIVATE | MAP_ANONYMOUS, MADV_MERGEABLE))
|
||||
return -1;
|
||||
|
||||
test_msg("Alloc wipeonfork\n");
|
||||
if (alloc_anon_mmap(&m[5], MAP_PRIVATE | MAP_ANONYMOUS, MADV_WIPEONFORK))
|
||||
return -1;
|
||||
|
||||
test_msg("Fetch existing flags/adv\n");
|
||||
for (i = 0; i < sizeof(m) / sizeof(m[0]); i++) {
|
||||
if (get_smaps_bits((unsigned long)m[i].start, &m[i].orig_flags, &m[i].orig_madv))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue