Skip to content

Commit 00a321f

Browse files
committed
add test case for checking file append
1 parent fc553d8 commit 00a321f

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

tests/fs/test_append.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include<assert.h>
2+
#include<stdio.h>
3+
4+
int main (int argc, char *argv[])
5+
{
6+
FILE *fp;
7+
int res;
8+
long len;
9+
10+
fp = fopen("testappend", "wb+");
11+
res = fwrite("1234567890", 10, 1, fp);
12+
fclose(fp);
13+
14+
fp = fopen("testappend", "ab+");
15+
res = fwrite("1234567890", 10, 1, fp);
16+
17+
fseek(fp, -7, SEEK_END);
18+
len = ftell(fp);
19+
assert(len == 13);
20+
fclose(fp);
21+
22+
puts("success");
23+
return 0;
24+
}

tests/test_core.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4348,6 +4348,11 @@ def test_fs_writeFile(self):
43484348
out = path_from_root('tests', 'fs', 'test_writeFile.out')
43494349
self.do_run_from_file(src, out)
43504350

4351+
def test_fs_append(self):
4352+
if self.emcc_args is None: return self.skip('requires emcc')
4353+
src = open(path_from_root('tests', 'fs', 'test_append.c'), 'r').read()
4354+
self.do_run(src, 'success', force_c=True)
4355+
43514356
def test_unistd_access(self):
43524357
self.clear()
43534358
if not self.is_emscripten_abi(): return self.skip('asmjs-unknown-emscripten needed for inline js')

0 commit comments

Comments
 (0)