add testcases for #732 #1065 #1102

This commit is contained in:
Ken Sato
2018-06-07 10:11:23 +09:00
parent 139123dc12
commit 9bb48186e6
35 changed files with 1653 additions and 0 deletions

View File

@ -0,0 +1,46 @@
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <sys/mman.h>
#define FILE_SIZE 1024
#define CMD_SIZE 128
int main(int argc, char* argv[])
{
int fd;
void *file_map;
long page_size, file_map_size;
char command[CMD_SIZE];
if (argc < 2) {
printf("Error: too few arguments\n");
return -1;
}
fd = open(argv[1], O_RDWR);
if (fd < 0) {
printf("Error: open %s\n", argv[1]);
return -1;
}
page_size = sysconf(_SC_PAGESIZE);
file_map_size = (FILE_SIZE / page_size + 1) * page_size;
file_map = mmap(0, file_map_size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
if (file_map == MAP_FAILED) {
printf("Error: mmap file\n");
return -1;
}
sprintf(command, "cat /proc/%d/maps", getpid());
system(command);
close(fd);
munmap(file_map, file_map_size);
return 0;
}