diff options
Diffstat (limited to 'tests/unistd/truncate.c')
-rw-r--r-- | tests/unistd/truncate.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/tests/unistd/truncate.c b/tests/unistd/truncate.c index b1d9fc96..e63a4c13 100644 --- a/tests/unistd/truncate.c +++ b/tests/unistd/truncate.c @@ -8,14 +8,19 @@ int main() { EM_ASM( - FS.writeFile('/towrite', 'abcdef'); - FS.writeFile('/toread', 'abcdef'); - FS.chmod('/toread', 0444); + FS.mkdir('working'); +#if NODEFS + FS.mount(NODEFS, { root: '.' }, 'working'); +#endif + FS.chdir('working'); + FS.writeFile('towrite', 'abcdef'); + FS.writeFile('toread', 'abcdef'); + FS.chmod('toread', 0444); ); struct stat s; - int f = open("/towrite", O_WRONLY); - int f2 = open("/toread", O_RDONLY); + int f = open("towrite", O_WRONLY); + int f2 = open("toread", O_RDONLY); printf("f2: %d\n", f2); fstat(f, &s); @@ -48,17 +53,17 @@ int main() { errno = 0; printf("\n"); - printf("truncate(2): %d\n", truncate("/towrite", 2)); + printf("truncate(2): %d\n", truncate("towrite", 2)); printf("errno: %d\n", errno); - stat("/towrite", &s); + stat("towrite", &s); printf("st_size: %d\n", s.st_size); memset(&s, 0, sizeof s); errno = 0; printf("\n"); - printf("truncate(readonly, 2): %d\n", truncate("/toread", 2)); + printf("truncate(readonly, 2): %d\n", truncate("toread", 2)); printf("errno: %d\n", errno); - stat("/toread", &s); + stat("toread", &s); printf("st_size: %d\n", s.st_size); memset(&s, 0, sizeof s); errno = 0; |