Skip to content

Commit c308577

Browse files
committed
test/zdtm/static/maps02: add MAP_DROPPABLE testcase
Signed-off-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>
1 parent 8c0a412 commit c308577

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

test/zdtm/static/get_smaps_bits.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
#define MAP_HUGETLB 0x40000
77
#endif
88

9+
#ifndef MAP_DROPPABLE
10+
#define MAP_DROPPABLE 0x08
11+
#endif
12+
913
#ifndef MADV_HUGEPAGE
1014
#define MADV_HUGEPAGE 14
1115
#endif
@@ -41,6 +45,8 @@ static void parse_vmflags(char *buf, unsigned long *flags, unsigned long *madv)
4145
*flags |= MAP_NORESERVE;
4246
else if (_vmflag_match(tok, "ht"))
4347
*flags |= MAP_HUGETLB;
48+
else if (_vmflag_match(tok, "dp"))
49+
*flags |= MAP_DROPPABLE;
4450

4551
/* madvise() block */
4652
if (_vmflag_match(tok, "sr"))

test/zdtm/static/maps02.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
#include "zdtmtst.h"
33
#include "get_smaps_bits.h"
44

5+
#ifndef MAP_DROPPABLE
6+
#define MAP_DROPPABLE 0x08
7+
#endif
8+
59
#ifndef MADV_DONTDUMP
610
#define MADV_DONTDUMP 16
711
#endif
@@ -47,7 +51,7 @@ static int alloc_anon_mmap(struct mmap_data *m, int flags, int adv)
4751

4852
int main(int argc, char **argv)
4953
{
50-
struct mmap_data m[6] = {};
54+
struct mmap_data m[7] = {};
5155
size_t i;
5256

5357
test_init(argc, argv);
@@ -76,6 +80,10 @@ int main(int argc, char **argv)
7680
if (alloc_anon_mmap(&m[5], MAP_PRIVATE | MAP_ANONYMOUS, MADV_WIPEONFORK))
7781
return -1;
7882

83+
test_msg("Alloc droppable\n");
84+
if (alloc_anon_mmap(&m[6], MAP_DROPPABLE | MAP_ANONYMOUS, MADV_NORMAL))
85+
return -1;
86+
7987
test_msg("Fetch existing flags/adv\n");
8088
for (i = 0; i < sizeof(m) / sizeof(m[0]); i++) {
8189
if (get_smaps_bits((unsigned long)m[i].start, &m[i].orig_flags, &m[i].orig_madv))

0 commit comments

Comments
 (0)