aboutsummaryrefslogtreecommitdiff
path: root/tests/test_core.py
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-08-31 20:53:39 -0700
committerAlon Zakai <alonzakai@gmail.com>2013-09-03 14:41:31 -0700
commitf55d0566d4bcbe83edbeedbc1dca30817d7da9ce (patch)
tree7f814d70b835cff988074d907a889c6329252c33 /tests/test_core.py
parentaa77d85a532f573672176fd8a2fb42b406e0e711 (diff)
wip test_dlfcn_mallocs
Diffstat (limited to 'tests/test_core.py')
-rw-r--r--tests/test_core.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/test_core.py b/tests/test_core.py
index f98d3624..d7e60345 100644
--- a/tests/test_core.py
+++ b/tests/test_core.py
@@ -6198,6 +6198,40 @@ int 1 9000
ok
''', force_c=True, post_build=self.dlfcn_post_build)
+ def test_dlfcn_mallocs(self):
+ if not self.can_dlfcn(): return
+
+ Settings.TOTAL_MEMORY = 64*1024*1024 # will be exhausted without functional malloc/free
+
+ self.prep_dlfcn_lib()
+ lib_src = r'''
+ #include <assert.h>
+ #include <stdio.h>
+ #include <string.h>
+ #include <stdlib.h>
+
+ void *mallocproxy(int n) { return malloc(n); }
+ void freeproxy(void *p) { free(p); }
+ '''
+ Settings.EXPORTED_FUNCTIONS = ['_mallocproxy', '_freeproxy']
+ dirname = self.get_dir()
+ filename = os.path.join(dirname, 'liblib.c')
+ self.build(lib_src, dirname, filename)
+ shutil.move(filename + '.o.js', os.path.join(dirname, 'liblib.so'))
+
+ self.prep_dlfcn_main()
+ src = open(path_from_root('tests', 'dlmalloc_proxy.c')).read()
+ Settings.EXPORTED_FUNCTIONS = ['_main', '_malloc', '_free']
+ self.do_run(src, '''go
+main.
+main 201
+void 0
+void 1
+int 0 54
+int 1 9000
+ok
+''', force_c=True, post_build=self.dlfcn_post_build)
+
def test_rand(self):
return self.skip('rand() is now random') # FIXME