aboutsummaryrefslogtreecommitdiff
path: root/tests/unistd/truncate.c
diff options
context:
space:
mode:
authorAnthony Pesch <inolen@gmail.com>2013-09-02 13:58:39 -0700
committerAnthony Pesch <inolen@gmail.com>2013-09-27 00:46:17 -0700
commit9eaadf56f58b35376469e9a89373632fd34cf08c (patch)
tree1604648b4e270f5af03c6efc75dc287b2199d649 /tests/unistd/truncate.c
parentc354b8316cefef8fde6402cf0139f7a64f9b3103 (diff)
- updated several unistd tests to test against NODEFS
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;