aboutsummaryrefslogtreecommitdiff
path: root/tests/runner.py
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-03-15 14:53:48 -0700
committerAlon Zakai <alonzakai@gmail.com>2012-03-15 14:58:22 -0700
commit36afa3f0eb2b3d63bcab798bc8ee1caceae08e2b (patch)
treeae238638f8be1166eab80b38bb9744e63ae95827 /tests/runner.py
parent38821ffb775f923179c0607e03329be58cc2f86d (diff)
support files in directories in --embed-file and --preload-file
Diffstat (limited to 'tests/runner.py')
-rwxr-xr-xtests/runner.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/runner.py b/tests/runner.py
index 0208720b..4121bb6c 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -6243,6 +6243,44 @@ f.close()
Popen([EMCC, os.path.join(self.get_dir(), 'main.cpp'), '--preload-file', 'somefile.txt', '-o', 'page.html']).communicate()
self.run_browser('page.html', 'You should see |load me right before|.', '/report_result?1')
+ def test_emcc_multifile(self):
+ # a few files inside a directory
+ if not os.path.exists(os.path.join(self.get_dir(), 'subdirr')):
+ os.makedirs(os.path.join(self.get_dir(), 'subdirr'));
+ open(os.path.join(self.get_dir(), 'subdirr', 'data1.txt'), 'w').write('''1214141516171819''')
+ open(os.path.join(self.get_dir(), 'subdirr', 'data2.txt'), 'w').write('''3.14159265358979''')
+ open(os.path.join(self.get_dir(), 'main.cpp'), 'w').write(self.with_report_result(r'''
+ #include <stdio.h>
+ #include <string.h>
+ #include <emscripten.h>
+ int main() {
+ char buf[17];
+
+ FILE *f = fopen("subdirr/data1.txt", "r");
+ fread(buf, 1, 16, f);
+ buf[16] = 0;
+ fclose(f);
+ printf("|%s|\n", buf);
+ int result = !strcmp("1214141516171819", buf);
+
+ FILE *f2 = fopen("subdirr/data2.txt", "r");
+ fread(buf, 1, 16, f2);
+ buf[16] = 0;
+ fclose(f2);
+ printf("|%s|\n", buf);
+ result = result && !strcmp("3.14159265358979", buf);
+
+ REPORT_RESULT();
+ return 0;
+ }
+ '''))
+
+ Popen([EMCC, os.path.join(self.get_dir(), 'main.cpp'), '--preload-file', 'subdirr/data1.txt', '--preload-file', 'subdirr/data2.txt', '-o', 'page.html']).communicate()
+ self.run_browser('page.html', 'You should see two cool numbers', '/report_result?1')
+
+ def test_emcc_sdl_image(self):
+ pass # load an image file, say jpg, get pixel data
+
def test_emcc_worker(self):
# Test running in a web worker
output = Popen([EMCC, path_from_root('tests', 'hello_world_worker.cpp'), '-o', 'worker.js'], stdout=PIPE, stderr=PIPE).communicate()