aboutsummaryrefslogtreecommitdiff
path: root/tests/runner.py
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-07-23 16:47:02 -0700
committerAlon Zakai <alonzakai@gmail.com>2012-07-23 16:47:02 -0700
commit80a58685b5b3c1b9eac75615fcfde3169ed79eb2 (patch)
tree8be6daabb222e508d9358f898fabf981e463973a /tests/runner.py
parent463a7b1af8320da72c2b32289c911f25ccf54330 (diff)
always look for main in .a files
Diffstat (limited to 'tests/runner.py')
-rwxr-xr-xtests/runner.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/runner.py b/tests/runner.py
index af910b2a..26110b59 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -7046,6 +7046,34 @@ f.close()
err = Popen(['python', EMCC, os.path.join(self.get_dir(), 'main.cpp'), os.path.join(self.get_dir(), 'side.cpp'), '--remove-duplicates'], stderr=PIPE).communicate()[1]
self.assertContained('bye bye', run_js(os.path.join(self.get_dir(), 'a.out.js')))
+ def test_main_a(self):
+ # if main() is in a .a, we need to pull in that .a
+
+ main_name = os.path.join(self.get_dir(), 'main.c')
+ open(main_name, 'w').write(r'''
+ #include <stdio.h>
+ extern int f();
+ int main() {
+ printf("result: %d.\n", f());
+ return 0;
+ }
+ ''')
+
+ other_name = os.path.join(self.get_dir(), 'other.c')
+ open(other_name, 'w').write(r'''
+ #include <stdio.h>
+ int f() { return 12346; }
+ ''')
+
+ Popen(['python', EMCC, main_name, '-c', '-o', main_name+'.bc']).communicate()
+ Popen(['python', EMCC, other_name, '-c', '-o', other_name+'.bc']).communicate()
+
+ Popen(['python', EMAR, 'cr', main_name+'.a', main_name+'.bc']).communicate()
+
+ Popen(['python', EMCC, other_name+'.bc', main_name+'.a']).communicate()
+
+ self.assertContained('result: 12346.', run_js(os.path.join(self.get_dir(), 'a.out.js')))
+
def test_embed_file(self):
open(os.path.join(self.get_dir(), 'somefile.txt'), 'w').write('''hello from a file with lots of data and stuff in it thank you very much''')
open(os.path.join(self.get_dir(), 'main.cpp'), 'w').write(r'''