summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2015-12-14 20:12:13 -0800
committerAlon Zakai <alonzakai@gmail.com>2015-12-14 20:18:36 -0800
commit03e1465919fe68416fc4b4e19a14f96456578002 (patch)
tree48701512810034e5ea3c3981832b32d947810fb3
parent7314f30d61b4850b2b4c7850901725ea287fd715 (diff)
downloadbinaryen-03e1465919fe68416fc4b4e19a14f96456578002.tar.gz
binaryen-03e1465919fe68416fc4b4e19a14f96456578002.tar.bz2
binaryen-03e1465919fe68416fc4b4e19a14f96456578002.zip
add first WASM_BACKEND output testcase
-rwxr-xr-xcheck.py19
-rw-r--r--test/wasm_backend/hello_world.cpp8
-rw-r--r--test/wasm_backend/hello_world.txt1
3 files changed, 27 insertions, 1 deletions
diff --git a/check.py b/check.py
index bb21c9dfc..78dbb1751 100755
--- a/check.py
+++ b/check.py
@@ -241,6 +241,7 @@ if actual != expected:
fail(actual, expected)
if has_emcc:
+
print '\n[ checking wasm.js methods... ]\n'
for method in [None, 'asm2wasm', 'wasm-s-parser', 'just-asm']:
@@ -282,7 +283,23 @@ if has_emcc:
assert proc.returncode != 0
assert 'hello, world!' not in out
- print '\n[ checking wasm.js testcases... (need emcc in your path) ]\n'
+ print '\n[ checking emcc WASM_BACKEND testcases... ]\n'
+
+ for c in ['hello_world.cpp']:
+ print '..', c
+ base = c.replace('.cpp', '').replace('.c', '')
+ expected = open(os.path.join('test', 'wasm_backend', base + '.txt')).read()
+ command = ['emcc', '-o', 'a.wasm.js', '-s', 'BINARYEN="' + os.getcwd() + '"', os.path.join('test', 'wasm_backend', c), '-O1', '-s', 'WASM_BACKEND=1', '-s', 'ONLY_MY_CODE=1']
+ print '....' + ' '.join(command)
+ subprocess.check_call(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ if has_node:
+ proc = subprocess.Popen(['nodejs', 'a.wasm.js'], stdout=subprocess.PIPE)
+ out, err = proc.communicate()
+ assert proc.returncode == 0
+ if out.strip() != expected.strip():
+ fail(out, expected)
+
+ print '\n[ checking wasm.js testcases... ]\n'
for c in tests:
if c.endswith(('.c', '.cpp')):
diff --git a/test/wasm_backend/hello_world.cpp b/test/wasm_backend/hello_world.cpp
new file mode 100644
index 000000000..a4a6a025d
--- /dev/null
+++ b/test/wasm_backend/hello_world.cpp
@@ -0,0 +1,8 @@
+#include <emscripten.h>
+
+int main() {
+ EM_ASM({
+ Module.print("hello, world!");
+ });
+}
+
diff --git a/test/wasm_backend/hello_world.txt b/test/wasm_backend/hello_world.txt
new file mode 100644
index 000000000..270c611ee
--- /dev/null
+++ b/test/wasm_backend/hello_world.txt
@@ -0,0 +1 @@
+hello, world!