diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/files.cpp | 18 | ||||
-rwxr-xr-x | tests/runner.py | 2 |
2 files changed, 19 insertions, 1 deletions
diff --git a/tests/files.cpp b/tests/files.cpp index e1a38421..04baa151 100644 --- a/tests/files.cpp +++ b/tests/files.cpp @@ -1,6 +1,7 @@ #include <assert.h> #include <stdio.h> #include <stdlib.h> +#include <string.h> int main() { @@ -103,6 +104,23 @@ int main() fclose(inf); printf("fscanfed: %d - %s\n", number, text); + // temp files + const char *tname = "file_XXXXXX.txt"; + char tname1[100]; + char tname2[100]; + strcpy(tname1, tname); + strcpy(tname2, tname); + assert(!strcmp(tname1, tname2)); // equal + int f1 = mkstemp(tname1); + int f2 = mkstemp(tname2); + assert(f1 != f2); + //printf("%d,%d,%s,%s\n", f1, f2, tname1, tname2); + assert(strcmp(tname1, tname2)); // not equal + assert(fopen(tname1, "r")); + assert(fopen(tname2, "r")); + assert(!fopen(tname2+1, "r")); // sanity check that we can't open just anything + printf("ok.\n"); + return 0; } diff --git a/tests/runner.py b/tests/runner.py index 97ec3b94..1ab5c7af 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -5021,7 +5021,7 @@ def process(filename): other.close() src = open(path_from_root('tests', 'files.cpp'), 'r').read() - self.do_run(src, 'size: 7\ndata: 100,-56,50,25,10,77,123\nloop: 100 -56 50 25 10 77 123 \ninput:hi there!\ntexto\ntexte\n$\n5 : 10,30,20,11,88\nother=some data.\nseeked=me da.\nseeked=ata.\nseeked=ta.\nfscanfed: 10 - hello\n', + self.do_run(src, 'size: 7\ndata: 100,-56,50,25,10,77,123\nloop: 100 -56 50 25 10 77 123 \ninput:hi there!\ntexto\ntexte\n$\n5 : 10,30,20,11,88\nother=some data.\nseeked=me da.\nseeked=ata.\nseeked=ta.\nfscanfed: 10 - hello\nok.\n', post_build=post, extra_emscripten_args=['-H', 'libc/fcntl.h']) def test_files_m(self): |