aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorVasilis Kalintiris <ehostunreach@gmail.com>2013-12-07 17:36:07 +0200
committerVasilis Kalintiris <ehostunreach@gmail.com>2013-12-07 19:36:02 +0200
commita716a809a7467655a3fe4d47e35848cce37a4f88 (patch)
treece5335d1dd5e5dec343c7dd9e192dcbc88e33f7f /tests
parente01c9f0a85798f35684fa1b7e4473ecd68238535 (diff)
Use do_run_from_file() for test_ccall
Diffstat (limited to 'tests')
-rw-r--r--tests/core/test_ccall.in19
-rw-r--r--tests/core/test_ccall.out23
-rw-r--r--tests/test_core.py25
3 files changed, 46 insertions, 21 deletions
diff --git a/tests/core/test_ccall.in b/tests/core/test_ccall.in
new file mode 100644
index 00000000..6374ebb3
--- /dev/null
+++ b/tests/core/test_ccall.in
@@ -0,0 +1,19 @@
+
+ #include <stdio.h>
+ #include <stdlib.h>
+
+ extern "C" {
+ int get_int() { return 5; }
+ float get_float() { return 3.14; }
+ char * get_string() { return "hello world"; }
+ void print_int(int x) { printf("%d\n", x); }
+ void print_float(float x) { printf("%.2f\n", x); }
+ void print_string(char *x) { printf("%s\n", x); }
+ int multi(int x, float y, int z, char *str) { if (x) puts(str); return (x+y)*z; }
+ int * pointer(int *in) { printf("%d\n", *in); static int ret = 21; return &ret; }
+ }
+
+ int main(int argc, char **argv) {
+ return 0;
+ }
+ \ No newline at end of file
diff --git a/tests/core/test_ccall.out b/tests/core/test_ccall.out
new file mode 100644
index 00000000..526ed80d
--- /dev/null
+++ b/tests/core/test_ccall.out
@@ -0,0 +1,23 @@
+*
+number,5
+number,3.14
+string,hello world
+12
+undefined
+14.56
+undefined
+cheez
+undefined
+arr-ay
+undefined
+more
+number,10
+650
+number,21
+*
+atr
+10
+bret
+53
+*
+stack is ok.
diff --git a/tests/test_core.py b/tests/test_core.py
index abe79230..5d66c6d3 100644
--- a/tests/test_core.py
+++ b/tests/test_core.py
@@ -5132,26 +5132,6 @@ def process(filename):
if self.emcc_args is not None and '-O2' in self.emcc_args:
self.emcc_args += ['--closure', '1'] # Use closure here, to test we export things right
- src = r'''
- #include <stdio.h>
- #include <stdlib.h>
-
- extern "C" {
- int get_int() { return 5; }
- float get_float() { return 3.14; }
- char * get_string() { return "hello world"; }
- void print_int(int x) { printf("%d\n", x); }
- void print_float(float x) { printf("%.2f\n", x); }
- void print_string(char *x) { printf("%s\n", x); }
- int multi(int x, float y, int z, char *str) { if (x) puts(str); return (x+y)*z; }
- int * pointer(int *in) { printf("%d\n", *in); static int ret = 21; return &ret; }
- }
-
- int main(int argc, char **argv) {
- return 0;
- }
- '''
-
post = '''
def process(filename):
src = \'\'\'
@@ -5190,7 +5170,10 @@ def process(filename):
Settings.EXPORTED_FUNCTIONS += ['_get_int', '_get_float', '_get_string', '_print_int', '_print_float', '_print_string', '_multi', '_pointer', '_malloc']
- self.do_run(src, '*\nnumber,5\nnumber,3.14\nstring,hello world\n12\nundefined\n14.56\nundefined\ncheez\nundefined\narr-ay\nundefined\nmore\nnumber,10\n650\nnumber,21\n*\natr\n10\nbret\n53\n*\nstack is ok.\n', post_build=post)
+ test_path = path_from_root('tests', 'core', 'test_ccall')
+ src, output = (test_path + s for s in ('.in', '.out'))
+
+ self.do_run_from_file(src, output, post_build=post)
def test_pgo(self):
if Settings.ASM_JS: return self.skip('PGO does not work in asm mode')