aboutsummaryrefslogtreecommitdiff
path: root/tests/unistd/truncate.c
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-09-29 11:51:22 -0700
committerAlon Zakai <alonzakai@gmail.com>2013-09-29 11:51:22 -0700
commit61221f3dd86360875f1a6ece4aebaa0a20bc025c (patch)
tree7ea64acb419554505a891a2b0b06537077216268 /tests/unistd/truncate.c
parent51256ab4452f9b1aa3774ef2eece26faa652ab22 (diff)
parent4db117910eb13fc93d632dd4e3fb4cf127544538 (diff)
Merge pull request #1601 from inolen/idbfs
NODEFS and IDBFS support
Diffstat (limited to 'tests/unistd/truncate.c')
-rw-r--r--tests/unistd/truncate.c23
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;