aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-06-25 21:26:15 -0700
committerAlon Zakai <alonzakai@gmail.com>2013-07-03 15:31:03 -0700
commit0561274642ce8febd8b877927b8750573771ee3b (patch)
tree0726ca2a3a810d106d866b40bc0062037f0dd910
parent5e01920010c51286010e0d59d5b7541aad0678e8 (diff)
fix memory initializer counting and add test for merging of two of them
-rw-r--r--emlink.py3
-rwxr-xr-xtests/runner.py17
2 files changed, 19 insertions, 1 deletions
diff --git a/emlink.py b/emlink.py
index 83fe5d7e..c8bee707 100644
--- a/emlink.py
+++ b/emlink.py
@@ -44,8 +44,9 @@ class AsmModule():
if mem_init:
self.mem_init_full_js = mem_init.group(0)
self.mem_init_js = mem_init.groups(0)[0][:-2]
- self.mem_init_size = self.mem_init_js.count(',') + self.mem_init_js.count('concat') # XXX add testing for large and small ones
+ self.mem_init_size = self.mem_init_js.count(',') + self.mem_init_js.count('concat') + 1 # XXX add testing for large and small ones
pad = 8 - (self.mem_init_size % 8)
+ #print >> sys.stderr, 'pad', self.mem_init_size, pad
if pad < 8:
self.mem_init_js += '.concat([' + ','.join(['0']*pad) + '])'
self.mem_init_size += pad
diff --git a/tests/runner.py b/tests/runner.py
index f875ca3d..97605011 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -10610,6 +10610,8 @@ f.close()
assert not os.path.exists('a.out') and not os.path.exists('a.exe'), 'Must not leave unneeded linker stubs'
def test_static_link(self):
+ print
+
def test(name, main, side, expected, first=True):
print name
#t = main ; main = side ; side = t
@@ -10625,6 +10627,7 @@ f.close()
self.validate_asmjs(out)
if first: test(name + ' (reverse)', side, main, expected, False) # test reverse order
+ # test a simple call from one module to another. only one has a string (and constant memory initialization for it)
test('basics', '''
#include <stdio.h>
extern int sidey();
@@ -10636,6 +10639,20 @@ f.close()
int sidey() { return 11; }
''', 'other says 11.')
+ # memory initialization in both
+ test('multiple memory inits', r'''
+ #include <stdio.h>
+ extern void sidey();
+ int main() {
+ printf("hello from main\n");
+ sidey();
+ return 0;
+ }
+ ''', r'''
+ #include <stdio.h>
+ void sidey() { printf("hello from side\n"); }
+ ''', 'hello from main\nhello from side\n')
+
def test_symlink(self):
if os.name == 'nt':
return self.skip('Windows FS does not need to be tested for symlinks support, since it does not have them.')