Skip to content

Commit

Permalink
lkl: add test for large file support
Browse files Browse the repository at this point in the history
Test that large file support is enabled by default, i.e. without passing
O_LARGEFILE to lkl_sys_open.

Signed-off-by: Andreas Gnau <[email protected]>
  • Loading branch information
Rondom committed Feb 27, 2017
1 parent 33ddd64 commit 1fd1f9b
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions tools/lkl/tests/boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,38 @@ int test_fstat(char *str, int len)
return TEST_FAILURE;
}

int test_lfs(char *str, int len)
{
long long fd;
long long ret;
int result = TEST_FAILURE;

ret = lkl_sys_open("/largefile", LKL_O_CREAT | LKL_O_WRONLY, 0);
if (ret < 0) {
snprintf(str, len, "open: %s", lkl_strerror(ret));
return TEST_FAILURE;
}
fd = ret;

lkl_loff_t nearly_3gb = (3 * 1024LL * 1024 * 1024 * 1024) - 1;

ret = lkl_sys_pwrite64(fd, "x", 1, nearly_3gb);
if (ret < 0) {
snprintf(str, len, "pwrite: %s", lkl_strerror(ret));
goto out;
}
snprintf(str, len, "%lld", ret);
result = TEST_SUCCESS;

out:
ret = lkl_sys_close(fd);
if (ret < 0) {
snprintf(str, len, "close: %s", lkl_strerror(ret));
result = TEST_FAILURE;
}
return result;
}

int test_mkdir(char *str, int len)
{
long ret;
Expand Down Expand Up @@ -932,6 +964,7 @@ int main(int argc, char **argv)
TEST(lseek);
TEST(read);
TEST(fstat);
TEST(lfs);
TEST(mkdir);
TEST(stat);
#ifndef __MINGW32__
Expand Down

0 comments on commit 1fd1f9b

Please sign in to comment.