mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-24 09:53:24 +00:00
Fix RamFS readahead
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
c99069981e
commit
179705a3fc
39
test/apps/mmap/mmap_readahead.c
Normal file
39
test/apps/mmap/mmap_readahead.c
Normal file
@ -0,0 +1,39 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
#include <sys/mman.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "../network/test.h"
|
||||
|
||||
#define FILE_NAME "/tmp/mmap_readahead.txt"
|
||||
|
||||
#define PAGE_SIZE 4096
|
||||
#define NR_PAGES 16
|
||||
|
||||
static char *addr;
|
||||
|
||||
FN_SETUP(mmap_readahead)
|
||||
{
|
||||
int fd;
|
||||
|
||||
fd = CHECK(open(FILE_NAME, O_RDWR | O_CREAT));
|
||||
CHECK(unlink(FILE_NAME));
|
||||
|
||||
CHECK(ftruncate(fd, PAGE_SIZE * NR_PAGES));
|
||||
|
||||
addr = mmap(NULL, PAGE_SIZE * NR_PAGES, PROT_READ | PROT_WRITE,
|
||||
MAP_SHARED, fd, 0);
|
||||
CHECK(addr == MAP_FAILED ? -1 : 0);
|
||||
}
|
||||
END_SETUP()
|
||||
|
||||
FN_TEST(mmap_readahead)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < NR_PAGES; ++i) {
|
||||
TEST_RES(addr[i * PAGE_SIZE], _ret == 0);
|
||||
}
|
||||
}
|
||||
END_TEST()
|
@ -22,6 +22,7 @@ itimer/setitimer
|
||||
itimer/timer_create
|
||||
mmap/mmap_and_fork
|
||||
mmap/mmap_shared_filebacked
|
||||
mmap/mmap_readahead
|
||||
pthread/pthread_test
|
||||
pty/open_pty
|
||||
signal_c/parent_death_signal
|
||||
|
Reference in New Issue
Block a user