| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
#include <stdio.h> |
| 20 |
#include <stdlib.h> |
| 21 |
#include <unistd.h> |
| 22 |
#include <sys/mman.h> |
| 23 |
|
| 24 |
#include <hugetlbfs.h> |
| 25 |
|
| 26 |
#include "hugetests.h" |
| 27 |
|
| 28 |
int main(int argc, char *argv[]) |
| 29 |
{ |
| 30 |
long hpage_size; |
| 31 |
int fd; |
| 32 |
void *p; |
| 33 |
int err; |
| 34 |
|
| 35 |
test_init(argc, argv); |
| 36 |
|
| 37 |
hpage_size = check_hugepagesize(); |
| 38 |
|
| 39 |
fd = hugetlbfs_unlinked_fd(); |
| 40 |
if (fd < 0) |
| 41 |
FAIL("hugetlbfs_unlinked_fd()"); |
| 42 |
|
| 43 |
p = mmap(NULL, hpage_size, PROT_READ|PROT_WRITE, MAP_SHARED, |
| 44 |
fd, 0); |
| 45 |
if (p == MAP_FAILED) |
| 46 |
FAIL("mmap(): %s", strerror(errno)); |
| 47 |
|
| 48 |
err = test_addr_huge(p); |
| 49 |
if (err != 1) |
| 50 |
FAIL("Mapped address is not hugepage"); |
| 51 |
|
| 52 |
err = munmap(p, hpage_size); |
| 53 |
if (err != 0) |
| 54 |
FAIL("munmap(): %s", strerror(errno)); |
| 55 |
|
| 56 |
if (close(fd)) |
| 57 |
FAIL("close(): %s", strerror(errno)); |
| 58 |
|
| 59 |
PASS(); |
| 60 |
} |