aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/fs/test_append.c24
-rw-r--r--tests/test_core.py5
2 files changed, 29 insertions, 0 deletions
diff --git a/tests/fs/test_append.c b/tests/fs/test_append.c
new file mode 100644
index 00000000..27909ba3
--- /dev/null
+++ b/tests/fs/test_append.c
@@ -0,0 +1,24 @@
+#include<assert.h>
+#include<stdio.h>
+
+int main (int argc, char *argv[])
+{
+ FILE *fp;
+ int res;
+ long len;
+
+ fp = fopen("testappend", "wb+");
+ res = fwrite("1234567890", 10, 1, fp);
+ fclose(fp);
+
+ fp = fopen("testappend", "ab+");
+ res = fwrite("1234567890", 10, 1, fp);
+
+ fseek(fp, -7, SEEK_END);
+ len = ftell(fp);
+ assert(len == 13);
+ fclose(fp);
+
+ puts("success");
+ return 0;
+}
diff --git a/tests/test_core.py b/tests/test_core.py
index 13b6c0f3..08e3594e 100644
--- a/tests/test_core.py
+++ b/tests/test_core.py
@@ -4348,6 +4348,11 @@ def process(filename):
out = path_from_root('tests', 'fs', 'test_writeFile.out')
self.do_run_from_file(src, out)
+ def test_fs_append(self):
+ if self.emcc_args is None: return self.skip('requires emcc')
+ src = open(path_from_root('tests', 'fs', 'test_append.c'), 'r').read()
+ self.do_run(src, 'success', force_c=True)
+
def test_unistd_access(self):
self.clear()
if not self.is_emscripten_abi(): return self.skip('asmjs-unknown-emscripten needed for inline js')