summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVasilis Kalintiris <ehostunreach@gmail.com>2013-12-07 12:07:36 +0200
committerVasilis Kalintiris <ehostunreach@gmail.com>2013-12-07 19:35:55 +0200
commit3c464bae721f6e2012062ea88852b66c5897409f (patch)
tree2cf68775e31a9d75b3fb1b8b068beb4bce670578
parent45243528c0cefc663314a412b3c34b3469587bdd (diff)
Use do_run_from_file() for test_alloca_stack
-rw-r--r--tests/core/test_alloca_stack.in19
-rw-r--r--tests/core/test_alloca_stack.out1
-rw-r--r--tests/test_core.py22
3 files changed, 23 insertions, 19 deletions
diff --git a/tests/core/test_alloca_stack.in b/tests/core/test_alloca_stack.in
new file mode 100644
index 00000000..ab7c7306
--- /dev/null
+++ b/tests/core/test_alloca_stack.in
@@ -0,0 +1,19 @@
+
+// We should not blow up the stack with numerous allocas
+ #include <stdio.h>
+ #include <stdlib.h>
+
+ func(int i) {
+ char *pc = (char *)alloca(100);
+ *pc = i;
+ (*pc)++;
+ return (*pc) % 10;
+ }
+ int main() {
+ int total = 0;
+ for (int i = 0; i < 1024*1024; i++)
+ total += func(i);
+ printf("ok:%d*\n", total);
+ return 0;
+ }
+
diff --git a/tests/core/test_alloca_stack.out b/tests/core/test_alloca_stack.out
new file mode 100644
index 00000000..d6a90d4e
--- /dev/null
+++ b/tests/core/test_alloca_stack.out
@@ -0,0 +1 @@
+ok:-32768* \ No newline at end of file
diff --git a/tests/test_core.py b/tests/test_core.py
index 0092a27d..4b4ad6b4 100644
--- a/tests/test_core.py
+++ b/tests/test_core.py
@@ -1564,26 +1564,10 @@ class T(RunnerCore): # Short name, to make it more fun to use manually on the co
def test_alloca_stack(self):
if self.emcc_args is None: return # too slow in other modes
- # We should not blow up the stack with numerous allocas
- src = '''
- #include <stdio.h>
- #include <stdlib.h>
+ test_path = path_from_root('tests', 'core', 'test_alloca_stack')
+ src, output = (test_path + s for s in ('.in', '.out'))
- func(int i) {
- char *pc = (char *)alloca(100);
- *pc = i;
- (*pc)++;
- return (*pc) % 10;
- }
- int main() {
- int total = 0;
- for (int i = 0; i < 1024*1024; i++)
- total += func(i);
- printf("ok:%d*\\n", total);
- return 0;
- }
- '''
- self.do_run(src, 'ok:-32768*', force_c=True)
+ self.do_run_from_file(src, output, force_c=True)
def test_stack_byval(self):
if self.emcc_args is None: return # too slow in other modes