mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-29 13:28:27 +00:00
test/zdtm/static/maps02: add MAP_DROPPABLE testcase
Signed-off-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>
This commit is contained in:
parent
ae9d0d0557
commit
27653caa4c
@ -6,6 +6,10 @@
|
|||||||
#define MAP_HUGETLB 0x40000
|
#define MAP_HUGETLB 0x40000
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef MAP_DROPPABLE
|
||||||
|
#define MAP_DROPPABLE 0x08
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef MADV_HUGEPAGE
|
#ifndef MADV_HUGEPAGE
|
||||||
#define MADV_HUGEPAGE 14
|
#define MADV_HUGEPAGE 14
|
||||||
#endif
|
#endif
|
||||||
@ -45,6 +49,8 @@ static void parse_vmflags(char *buf, unsigned long *flags, unsigned long *madv)
|
|||||||
*flags |= MAP_NORESERVE;
|
*flags |= MAP_NORESERVE;
|
||||||
else if (_vmflag_match(tok, "ht"))
|
else if (_vmflag_match(tok, "ht"))
|
||||||
*flags |= MAP_HUGETLB;
|
*flags |= MAP_HUGETLB;
|
||||||
|
else if (_vmflag_match(tok, "dp"))
|
||||||
|
*flags |= MAP_DROPPABLE;
|
||||||
|
|
||||||
/* madvise() block */
|
/* madvise() block */
|
||||||
if (_vmflag_match(tok, "sr"))
|
if (_vmflag_match(tok, "sr"))
|
||||||
|
@ -2,6 +2,10 @@
|
|||||||
#include "zdtmtst.h"
|
#include "zdtmtst.h"
|
||||||
#include "get_smaps_bits.h"
|
#include "get_smaps_bits.h"
|
||||||
|
|
||||||
|
#ifndef MAP_DROPPABLE
|
||||||
|
#define MAP_DROPPABLE 0x08
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef MADV_DONTDUMP
|
#ifndef MADV_DONTDUMP
|
||||||
#define MADV_DONTDUMP 16
|
#define MADV_DONTDUMP 16
|
||||||
#endif
|
#endif
|
||||||
@ -27,9 +31,15 @@ static int alloc_anon_mmap(struct mmap_data *m, int flags, int adv)
|
|||||||
{
|
{
|
||||||
m->start = mmap(NULL, MEM_SIZE, PROT_READ | PROT_WRITE, flags, -1, 0);
|
m->start = mmap(NULL, MEM_SIZE, PROT_READ | PROT_WRITE, flags, -1, 0);
|
||||||
if (m->start == MAP_FAILED) {
|
if (m->start == MAP_FAILED) {
|
||||||
|
if (errno == EINVAL) {
|
||||||
|
test_msg("mmap failed, no kernel support\n");
|
||||||
|
*m = (struct mmap_data){};
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
pr_perror("mmap failed");
|
pr_perror("mmap failed");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (madvise(m->start, MEM_SIZE, adv)) {
|
if (madvise(m->start, MEM_SIZE, adv)) {
|
||||||
if (errno == EINVAL) {
|
if (errno == EINVAL) {
|
||||||
@ -47,7 +57,7 @@ static int alloc_anon_mmap(struct mmap_data *m, int flags, int adv)
|
|||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
struct mmap_data m[6] = {};
|
struct mmap_data m[7] = {};
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
test_init(argc, argv);
|
test_init(argc, argv);
|
||||||
@ -76,6 +86,10 @@ int main(int argc, char **argv)
|
|||||||
if (alloc_anon_mmap(&m[5], MAP_PRIVATE | MAP_ANONYMOUS, MADV_WIPEONFORK))
|
if (alloc_anon_mmap(&m[5], MAP_PRIVATE | MAP_ANONYMOUS, MADV_WIPEONFORK))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
test_msg("Alloc droppable\n");
|
||||||
|
if (alloc_anon_mmap(&m[6], MAP_DROPPABLE | MAP_ANONYMOUS, MADV_NORMAL))
|
||||||
|
return -1;
|
||||||
|
|
||||||
test_msg("Fetch existing flags/adv\n");
|
test_msg("Fetch existing flags/adv\n");
|
||||||
for (i = 0; i < sizeof(m) / sizeof(m[0]); i++) {
|
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))
|
if (get_smaps_bits((unsigned long)m[i].start, &m[i].orig_flags, &m[i].orig_madv))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user