diff options
author | Alon Zakai <alonzakai@gmail.com> | 2015-10-31 15:48:08 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2015-10-31 15:48:08 -0700 |
commit | 6512f29a40c72979c05e73318b957e425363980e (patch) | |
tree | 7d4127f6d1f61b7de799b4e3ff08f214ed554e1c | |
parent | 547867eb0e78cac6be7f35bbd80c6582224df807 (diff) | |
download | binaryen-6512f29a40c72979c05e73318b957e425363980e.tar.gz binaryen-6512f29a40c72979c05e73318b957e425363980e.tar.bz2 binaryen-6512f29a40c72979c05e73318b957e425363980e.zip |
prepare for polyfill testing
-rw-r--r-- | .gitignore | 2 | ||||
-rwxr-xr-x | check.py | 13 | ||||
-rwxr-xr-x | emcc_to_polyfill.sh | 8 | ||||
-rw-r--r-- | src/templates/normal.js | 4 | ||||
-rw-r--r-- | test/hello_world.c | 7 |
5 files changed, 32 insertions, 2 deletions
diff --git a/.gitignore b/.gitignore index 9e5aa6211..761b8f1fc 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,4 @@ bin/asm2wasm bin/wasm.js *~ *.diff - +a.* @@ -16,7 +16,7 @@ for arg in sys.argv[1:]: if not interpreter: print '[ no wasm interpreter provided, you should pass one as --interpreter=path/to/interpreter ]' -print '[ checking testcases... ]\n' +print '[ checking asm2wasm testcases... ]\n' if len(tests) == 0: tests = sorted(os.listdir('test')) @@ -59,5 +59,16 @@ for asm in tests: raise Exception('wasm interpreter error: ' + err) # failed to pretty-print raise Exception('wasm interpreter error') +print '\n[ checking emcc_to_polyfill testcases... (need both emcc and nodejs in your path) ]\n' + +print '..normal' + +if os.path.exists('a.normal.js'): os.unlink('a.normal.js') +subprocess.check_call(['./emcc_to_polyfill.sh', os.path.join('test', 'hello_world.c')]) +proc = subprocess.Popen(['nodejs', 'a.normal.js'], stdout=subprocess.PIPE) +out, err = proc.communicate() +assert proc.returncode == 0 +assert 'hello, world!' in out, out + print '\n[ success! ]' diff --git a/emcc_to_polyfill.sh b/emcc_to_polyfill.sh new file mode 100755 index 000000000..c808e7ae8 --- /dev/null +++ b/emcc_to_polyfill.sh @@ -0,0 +1,8 @@ +#!/bin/sh +emcc $1 -o a.html --separate-asm +# we now have a.asm.js and a.js, combine them +# a.normal.js: just normal combination of the files. no wasm yet +cat src/templates/normal.js > a.normal.js +cat a.asm.js >> a.normal.js +cat a.js >> a.normal.js + diff --git a/src/templates/normal.js b/src/templates/normal.js new file mode 100644 index 000000000..5893f96a0 --- /dev/null +++ b/src/templates/normal.js @@ -0,0 +1,4 @@ + +var Module = {}; // *.asm.js expects this + + diff --git a/test/hello_world.c b/test/hello_world.c new file mode 100644 index 000000000..eb47ea813 --- /dev/null +++ b/test/hello_world.c @@ -0,0 +1,7 @@ +#include<stdio.h> + +int main() { + printf("hello, world!\n"); + return 0; +} + |