Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
qgymib committed Aug 22, 2024
1 parent f2e14a8 commit 09c1ee8
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion test/cases/fs_mmap_offset.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ TEST_FIXTURE_TEARDOWN(fs)
ev_fs_remove(NULL, NULL, s_file_path, 0, NULL);
}

TEST_F(fs, mmap_offset_half)
TEST_F(fs, mmap_offset_half_size_0)
{
ev_file_t* file = ev_malloc(sizeof(ev_file_t));
ASSERT_EQ_INT(ev_file_open(NULL, file, NULL, s_file_path, EV_FS_O_RDONLY, 0, NULL), 0);
Expand All @@ -47,3 +47,21 @@ TEST_F(fs, mmap_offset_half)
ev_file_munmap(view);
ev_free(view);
}

TEST_F(fs, mmap_offset_half_size_half)
{
ev_file_t* file = ev_malloc(sizeof(ev_file_t));
ASSERT_EQ_INT(ev_file_open(NULL, file, NULL, s_file_path, EV_FS_O_RDONLY, 0, NULL), 0);

ev_file_map_t* view = ev_malloc(sizeof(ev_file_map_t));
ASSERT_EQ_INT(ev_file_mmap(view, file, s_mmap_offset_granularity, s_mmap_offset_granularity, EV_FS_S_IRUSR), 0);

const char* data = view->addr;
ASSERT_EQ_INT(memcmp(data, s_file_data + s_mmap_offset_granularity, s_mmap_offset_granularity), 0);

ev_file_close(file, NULL);
ev_free(file);

ev_file_munmap(view);
ev_free(view);
}

0 comments on commit 09c1ee8

Please sign in to comment.