aboutsummaryrefslogtreecommitdiff
path: root/tests/runner.py
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-11-05 11:07:54 -0800
committerAlon Zakai <alonzakai@gmail.com>2012-11-05 11:07:54 -0800
commit897604ccb031e9cf1bb9138a71b661d1a0528426 (patch)
treee7fb43af3ac38850fc7b520a107e3ea021fa37ac /tests/runner.py
parent27015b9841be5653b164306168935de94de2eef2 (diff)
fix fread/fwrite returns values on error; fixes #675
Diffstat (limited to 'tests/runner.py')
-rwxr-xr-xtests/runner.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/runner.py b/tests/runner.py
index 1e5841a4..da37583d 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -4498,6 +4498,30 @@ def process(filename):
'''
self.do_run(src, 'isatty? 0,0,1\ngot: 35\ngot: 45\ngot: 25\ngot: 15\n', post_build=post)
+ def test_fwrite_0(self):
+ src = r'''
+ #include <stdio.h>
+ #include <stdlib.h>
+
+ int main ()
+ {
+ FILE *fh;
+
+ fh = fopen("a.txt", "wb");
+ if (!fh) exit(1);
+ fclose(fh);
+
+ fh = fopen("a.txt", "rb");
+ if (!fh) exit(1);
+
+ char data[] = "foobar";
+ size_t written = fwrite(data, 1, sizeof(data), fh);
+
+ printf("written=%zu\n", written);
+ }
+ '''
+ self.do_run(src, 'written=0')
+
def test_fgetc_unsigned(self):
if self.emcc_args is None: return self.skip('requires emcc')
src = r'''