aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/cases/switch64_ta2.ll55
-rw-r--r--tests/cmake/target_html/CMakeLists.txt5
-rw-r--r--tests/enet/unix.c2
-rw-r--r--tests/python/readme.md59
-rw-r--r--tests/python/readme.txt46
-rw-r--r--tests/sockets/test_gethostbyname.c9
-rw-r--r--tests/test_core.py70
-rw-r--r--tests/test_other.py2
-rw-r--r--tests/test_sanity.py2
-rw-r--r--tests/unistd/login.out2
-rw-r--r--tests/unistd/misc.out8
11 files changed, 181 insertions, 79 deletions
diff --git a/tests/cases/switch64_ta2.ll b/tests/cases/switch64_ta2.ll
new file mode 100644
index 00000000..e56ccfba
--- /dev/null
+++ b/tests/cases/switch64_ta2.ll
@@ -0,0 +1,55 @@
+@.str = private constant [15 x i8] c"hello, world!\0A\00", align 1 ; [#uses=1]
+
+define linkonce_odr i32 @main() align 2 {
+ %333 = call i32 @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0)) ; [#uses=0]
+ %444 = zext i32 %333 to i64
+ %199 = trunc i8 1 to i1 ; [#uses=1]
+ switch i64 %444, label %label999 [
+ i64 1000, label %label9950
+ i64 1001, label %label9951
+ i64 1002, label %label9952
+ i64 1003, label %label9953
+ i64 1004, label %label9954
+ i64 1005, label %label9955
+ i64 1006, label %label9956
+ i64 1007, label %label9957
+ i64 1008, label %label9958
+ i64 1009, label %label9959
+ ] ; switch should ignore all code after it in the block
+ ; No predecessors!
+ %a472 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
+ cleanup
+ %a473 = extractvalue { i8*, i32 } %a472, 0
+ %a474 = extractvalue { i8*, i32 } %a472, 1
+ br label %label999
+
+label9950:
+ %333b = call i32 @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0)) ; [#uses=0]
+ br label %label999
+
+label9951:
+ br label %label999
+label9952:
+ br label %label999
+label9953:
+ br label %label999
+label9954:
+ br label %label999
+label9955:
+ br label %label999
+label9956:
+ br label %label999
+label9957:
+ br label %label999
+label9958:
+ br label %label999
+label9959:
+ br label %label999
+
+label999: ; preds = %555
+ ret i32 0
+}
+
+declare i32 @printf(i8*)
+declare i32 @__gxx_personality_v0(...)
+
diff --git a/tests/cmake/target_html/CMakeLists.txt b/tests/cmake/target_html/CMakeLists.txt
index 8b0528eb..b5c69417 100644
--- a/tests/cmake/target_html/CMakeLists.txt
+++ b/tests/cmake/target_html/CMakeLists.txt
@@ -14,3 +14,8 @@ SET(CMAKE_EXECUTABLE_SUFFIX ".html")
add_executable(hello_world_gles ${sourceFiles})
set_target_properties(hello_world_gles PROPERTIES LINK_FLAGS "${linkFlags}")
+
+# Validating asm.js requires SpiderMonkey JS VM - detect its presence via the SPIDERMONKEY environment variable.
+if (DEFINED ENV{SPIDERMONKEY} AND CMAKE_BUILD_TYPE STREQUAL Release)
+ em_validate_asmjs_after_build(hello_world_gles)
+endif()
diff --git a/tests/enet/unix.c b/tests/enet/unix.c
index a225b57d..67d4a8b8 100644
--- a/tests/enet/unix.c
+++ b/tests/enet/unix.c
@@ -80,7 +80,7 @@ enet_address_set_host (ENetAddress * address, const char * name)
char buffer [2048];
int errnum;
-#if defined(linux) || defined(__linux) || defined(__linux__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+#if defined(linux) || defined(__linux) || defined(__linux__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__EMSCRIPTEN__)
gethostbyname_r (name, & hostData, buffer, sizeof (buffer), & hostEntry, & errnum);
#else
hostEntry = gethostbyname_r (name, & hostData, buffer, sizeof (buffer), & errnum);
diff --git a/tests/python/readme.md b/tests/python/readme.md
new file mode 100644
index 00000000..e728dce3
--- /dev/null
+++ b/tests/python/readme.md
@@ -0,0 +1,59 @@
+Building Python with Emscripten
+===============================
+
+These directions should work for Python 2.7.x (last tested with 2.7.5).
+
+First, uncompress Python into two separate directories, one for native
+and one for JavaScript.
+
+In the JavaScript directory, do:
+
+````
+ EMCONFIGURE_JS=1 emconfigure ./configure --without-threads --without-pymalloc --enable-shared --disable-ipv6
+````
+
+If you are on Mac OS X, you will also want ``disable-toolbox-glue``.
+If you are on an older version of Python (such as 2.7.2), you may
+not need the ``--disable-ipv6`` option.
+
+If you are on Python 2.7.4 or later, you will need to edit the
+``Makefile`` generated and remove the ``MULTIARCH=`` line(s).
+You will also need to edit ``pyconfig.h`` and remove defines
+for ``DOUBLE_IS_BIG_ENDIAN_IEEE754``, ``DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754``,
+and ``HAVE_GCC_ASM_FOR_X87``.
+
+On Python 2.7.2, you will need to edit ``pyconfig.h`` and remove
+``HAVE_GCC_ASM_FOR_X87``, ``HAVE_SIG*`` except for ``SIGNAL_H``
+and *add* ``#define PY_NO_SHORT_FLOAT_REPR``.
+
+Now, you can run ``make``. It will fail trying to run ``pgen``.
+
+At this point, go to your native directory and run:
+
+````
+./configure --without-threads --without-pymalloc --enable-shared --disable-ipv6
+````
+
+Now, run ``make`` in the native directory and then copy the generated ``Parser/pgen``
+to your JavaScript directory. Back in your JavaScript directory, be sure to flag
+the ``pgen`` executable as executable:
+
+````
+chmod +x Parser/pgen
+````
+
+Now, run ``make`` again.
+
+You will get an error about trying to run ``python`` or ``python.exe``. This
+can be ignored.
+
+Now, you can link the bitcode file that you need:
+
+````
+llvm-link libpython2.7.so Modules/python.o -o python.bc
+````
+
+If you are on Mac OS X, you will want to look for ``libpython2.7.dylib``
+instead of ``libpython2.7.so``.
+
+Thanks to rasjidw and everyone else who has helped with this!
diff --git a/tests/python/readme.txt b/tests/python/readme.txt
deleted file mode 100644
index 31b0ff45..00000000
--- a/tests/python/readme.txt
+++ /dev/null
@@ -1,46 +0,0 @@
-Updates to Python 2.7.4 and emscripten of Arp 29 2013 with le32
-
-Go to js dir, run EMCONFIGURE_JS=1 ~/Dev/emscripten/emconfigure ./configure --without-threads --without-pymalloc --enable-shared --disable-ipv6
-clean out MULTIARCH= in Makefile
-make, until error on pgen
-Go to native, run ./configure --without-threads --without-pymalloc --enable-shared --disable-ipv6
-cp Parser/pgen ../JS_DIR/Parser
-return to JS
-chmod +x Parser/pgen
-remove #defines of DOUBLE_IS_BIG_ENDIAN_IEEE754 and DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754 and HAVE_GCC_ASM_FOR_X87 in pyconfig.h
-make
-link libpython2.7.so with Modules/python.o to get the bitcode file you want
-
-=========================
-
-
-This is Python 2.7.2, compiled to .bc as follows:
-
-Uncompress Python into two separate directories, one for native and one for JS.
-
-In the JS one, do
- emconfigure ./configure --without-threads --without-pymalloc --enable-shared
- EDIT pyconfig.h, remove
- HAVE_GCC_ASM_FOR_X87
- HAVE_SIG* except SIGNAL_H
- and *add*
- #define PY_NO_SHORT_FLOAT_REPR
- make
-It will fail on lack of permissions to run Parser/pgen.
-
-Go to the native one, do
- ./configure --without-threads --without-pymalloc
- make
- (Note: you don't need to let it complete, just enough for Parse/pgen is sufficient.)
- cp Parser/pgen ../YOUR_JS_DIR/Parser/
-
-Return to the JS one, do
- chmod +x Parser/pgen
- make
-You will get an error on lack of permissions to run ./python. Ignore that, and do
- llvm-link libpython2.7.so python -o python.bc
-
-That's it!
-
-Thanks to rasjidw for helping with this!
-
diff --git a/tests/sockets/test_gethostbyname.c b/tests/sockets/test_gethostbyname.c
index de7da706..459c6b98 100644
--- a/tests/sockets/test_gethostbyname.c
+++ b/tests/sockets/test_gethostbyname.c
@@ -13,12 +13,17 @@
int main() {
char str[INET_ADDRSTRLEN];
+ struct hostent *host = NULL;
+ struct hostent hostData;
struct in_addr addr;
const char *res;
+ char buffer[2048];
int err;
- // resolve the hostname ot an actual address
- struct hostent *host = gethostbyname("slashdot.org");
+ // gethostbyname_r calls the same stuff as gethostbyname, so we'll test the
+ // more complicated one.
+ // resolve the hostname to an actual address
+ gethostbyname_r("slashdot.org", &hostData, buffer, sizeof(buffer), &host, &err);
assert(host->h_addrtype == AF_INET);
assert(host->h_length == sizeof(uint32_t));
diff --git a/tests/test_core.py b/tests/test_core.py
index 54fbdcd1..dd3b7c44 100644
--- a/tests/test_core.py
+++ b/tests/test_core.py
@@ -1431,6 +1431,7 @@ Succeeded!
self.do_run(src, 'BUG?\nDisplay: Vu=465.100000 Vv=465.200000 Wu=160.300000 Wv=111.400000')
def test_math(self):
+ if Settings.USE_TYPED_ARRAYS != 2: return self.skip('requires ta2')
src = '''
#include <stdio.h>
#include <stdlib.h>
@@ -3756,11 +3757,18 @@ def process(filename):
int main() {
asm("Module.print('Inline JS is very cool')");
printf("%.2f\n", get());
+
+ // Test that passing multiple input and output variables works.
+ int src1 = 1, src2 = 2, src3 = 3;
+ int dst1 = 0, dst2 = 0, dst3 = 0;
+ // TODO asm("Module.print(%3); Module.print(%4); Module.print(%5); %0 = %3; %1 = %4; %2 = %5;" : "=r"(dst1),"=r"(dst2),"=r"(dst3): "r"(src1),"r"(src2),"r"(src3));
+ // TODO printf("%d\n%d\n%d\n", dst1, dst2, dst3);
+
return 0;
}
'''
- self.do_run(src, 'Inline JS is very cool\n3.64\n')
+ self.do_run(src, 'Inline JS is very cool\n3.64\n') # TODO 1\n2\n3\n1\n2\n3\n')
def test_inlinejs2(self):
if Settings.ASM_JS: Settings.ASM_JS = 2 # skip validation, asm does not support random code
@@ -7555,6 +7563,7 @@ def process(filename):
def test_utf32(self):
if self.emcc_args is None: return self.skip('need libc for wcslen()')
+ if not self.is_le32(): return self.skip('this test uses inline js, which requires le32')
self.do_run(open(path_from_root('tests', 'utf32.cpp')).read(), 'OK.')
self.do_run(open(path_from_root('tests', 'utf32.cpp')).read(), 'OK.', args=['-fshort-wchar'])
@@ -8640,29 +8649,44 @@ def process(filename):
Settings.SAFE_HEAP_LINES = ['btVoronoiSimplexSolver.h:40', 'btVoronoiSimplexSolver.h:41',
'btVoronoiSimplexSolver.h:42', 'btVoronoiSimplexSolver.h:43']
- def test():
- self.do_run(open(path_from_root('tests', 'bullet', 'Demos', 'HelloWorld', 'HelloWorld.cpp'), 'r').read(),
- [open(path_from_root('tests', 'bullet', 'output.txt'), 'r').read(), # different roundings
- open(path_from_root('tests', 'bullet', 'output2.txt'), 'r').read(),
- open(path_from_root('tests', 'bullet', 'output3.txt'), 'r').read()],
- libraries=self.get_library('bullet', [os.path.join('src', '.libs', 'libBulletDynamics.a'),
- os.path.join('src', '.libs', 'libBulletCollision.a'),
- os.path.join('src', '.libs', 'libLinearMath.a')],
- configure_args=['--disable-demos','--disable-dependency-tracking']),
- includes=[path_from_root('tests', 'bullet', 'src')])
- test()
-
- assert 'asm2g' in test_modes
- if self.run_name == 'asm2g':
- # Test forced alignment
- print >> sys.stderr, 'testing FORCE_ALIGNED_MEMORY'
- old = open('src.cpp.o.js').read()
- Settings.FORCE_ALIGNED_MEMORY = 1
+ configure_commands = [['sh', './configure'], ['cmake', '.']]
+ configure_args = [['--disable-demos','--disable-dependency-tracking'], ['-DBUILD_DEMOS=OFF', '-DBUILD_EXTRAS=OFF']]
+ for c in range(0,2):
+ configure = configure_commands[c]
+ # Windows cannot run configure sh scripts.
+ if WINDOWS and configure[0] == 'sh':
+ continue
+
+ # Depending on whether 'configure' or 'cmake' is used to build, Bullet places output files in different directory structures.
+ if configure[0] == 'sh':
+ generated_libs = [os.path.join('src', '.libs', 'libBulletDynamics.a'),
+ os.path.join('src', '.libs', 'libBulletCollision.a'),
+ os.path.join('src', '.libs', 'libLinearMath.a')]
+ else:
+ generated_libs = [os.path.join('src', 'BulletDynamics', 'libBulletDynamics.a'),
+ os.path.join('src', 'BulletCollision', 'libBulletCollision.a'),
+ os.path.join('src', 'LinearMath', 'libLinearMath.a')]
+
+ def test():
+ self.do_run(open(path_from_root('tests', 'bullet', 'Demos', 'HelloWorld', 'HelloWorld.cpp'), 'r').read(),
+ [open(path_from_root('tests', 'bullet', 'output.txt'), 'r').read(), # different roundings
+ open(path_from_root('tests', 'bullet', 'output2.txt'), 'r').read(),
+ open(path_from_root('tests', 'bullet', 'output3.txt'), 'r').read()],
+ libraries=self.get_library('bullet', generated_libs, configure=configure, configure_args=configure_args[c], cache_name_extra=configure[0]),
+ includes=[path_from_root('tests', 'bullet', 'src')])
test()
- new = open('src.cpp.o.js').read()
- print len(old), len(new), old.count('tempBigInt'), new.count('tempBigInt')
- assert len(old) > len(new)
- assert old.count('tempBigInt') > new.count('tempBigInt')
+
+ assert 'asm2g' in test_modes
+ if self.run_name == 'asm2g' and configure[0] == 'sh':
+ # Test forced alignment
+ print >> sys.stderr, 'testing FORCE_ALIGNED_MEMORY'
+ old = open('src.cpp.o.js').read()
+ Settings.FORCE_ALIGNED_MEMORY = 1
+ test()
+ new = open('src.cpp.o.js').read()
+ print len(old), len(new), old.count('tempBigInt'), new.count('tempBigInt')
+ assert len(old) > len(new)
+ assert old.count('tempBigInt') > new.count('tempBigInt')
def test_poppler(self):
if self.emcc_args is None: return self.skip('very slow, we only do this in emcc runs')
diff --git a/tests/test_other.py b/tests/test_other.py
index 64be60fa..b11f22e5 100644
--- a/tests/test_other.py
+++ b/tests/test_other.py
@@ -1755,7 +1755,7 @@ $
other=ay file...
seeked= file.
''', output[0])
- self.assertIdentical('texte\n', output[1])
+ self.assertContained('texte\n', output[1])
def test_emconfig(self):
output = Popen([PYTHON, EMCONFIG, 'LLVM_ROOT'], stdout=PIPE, stderr=PIPE).communicate()[0].strip()
diff --git a/tests/test_sanity.py b/tests/test_sanity.py
index 4188afff..6fdf5ddd 100644
--- a/tests/test_sanity.py
+++ b/tests/test_sanity.py
@@ -478,7 +478,7 @@ fi
(['--jcache'], 'hello_malloc.cpp', False, True, False, True, False, True, []),
([], 'hello_malloc.cpp', False, False, False, False, False, False, []),
# new, huge file
- ([], 'hello_libcxx.cpp', False, False, False, False, False, False, ('3 chunks',)),
+ ([], 'hello_libcxx.cpp', False, False, False, False, False, False, ('4 chunks',)),
(['--jcache'], 'hello_libcxx.cpp', True, False, True, False, True, False, []),
(['--jcache'], 'hello_libcxx.cpp', False, True, False, True, False, True, []),
([], 'hello_libcxx.cpp', False, False, False, False, False, False, []),
diff --git a/tests/unistd/login.out b/tests/unistd/login.out
index 50e850ae..c1919c3c 100644
--- a/tests/unistd/login.out
+++ b/tests/unistd/login.out
@@ -3,7 +3,7 @@ errno: 0
gethostname/2 ret: -1
gethostname/2: em------------------------
-errno: 91
+errno: 36
gethostname/256 ret: 0
gethostname/256: emscripten
diff --git a/tests/unistd/misc.out b/tests/unistd/misc.out
index 8f03f688..ae641d57 100644
--- a/tests/unistd/misc.out
+++ b/tests/unistd/misc.out
@@ -11,8 +11,8 @@ lockf(good): 0, errno: 0
lockf(bad): -1, errno: 9
nice: 0, errno: 1
pause: -1, errno: 4
-pipe(good): -1, errno: 88
-pipe(bad): -1, errno: 88
+pipe(good): -1, errno: 38
+pipe(bad): -1, errno: 38
execl: -1, errno: 8
execle: -1, errno: 8
execlp: -1, errno: 8
@@ -29,8 +29,8 @@ alarm: 0, errno: 0
ualarm: 0, errno: 0
fork: -1, errno: 11
vfork: -1, errno: 11
-crypt: (null), errno: 88
-encrypt, errno: 88
+crypt: (null), errno: 38
+encrypt, errno: 38
getgid: 0, errno: 0
getegid: 0, errno: 0
getuid: 0, errno: 0