aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/hello_libcxx_mod2.cpp10
-rw-r--r--tests/hello_libcxx_mod2a.cpp11
-rwxr-xr-xtests/runner.py27
3 files changed, 47 insertions, 1 deletions
diff --git a/tests/hello_libcxx_mod2.cpp b/tests/hello_libcxx_mod2.cpp
new file mode 100644
index 00000000..b18a523a
--- /dev/null
+++ b/tests/hello_libcxx_mod2.cpp
@@ -0,0 +1,10 @@
+#include <iostream>
+#include <emscripten.h>
+
+int main()
+{
+ std::cout << "hello, world!" << std::endl;
+ emscripten_jcache_printf("waka %d waka\n", 5);
+ return 0;
+}
+
diff --git a/tests/hello_libcxx_mod2a.cpp b/tests/hello_libcxx_mod2a.cpp
new file mode 100644
index 00000000..f48ad4fe
--- /dev/null
+++ b/tests/hello_libcxx_mod2a.cpp
@@ -0,0 +1,11 @@
+#include <iostream>
+#include <emscripten.h>
+
+int main()
+{
+ std::cout << "hello, world!" << std::endl;
+ emscripten_jcache_printf("waka %d waka\n", 5);
+ emscripten_jcache_printf("yet another printf %.2f %d\n", 5.5, 66);
+ return 0;
+}
+
diff --git a/tests/runner.py b/tests/runner.py
index 120a965d..29c15950 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -9749,6 +9749,23 @@ seeked= file.
if optimize_normally: del os.environ['EMCC_OPTIMIZE_NORMALLY']
del os.environ['EMCC_DEBUG']
+ def test_jcache_printf(self):
+ open(self.in_dir('src.cpp'), 'w').write(r'''
+ #include <stdio.h>
+ #include <stdint.h>
+ #include <emscripten.h>
+ int main() {
+ emscripten_jcache_printf("hello world\n");
+ emscripten_jcache_printf("hello %d world\n", 5);
+ emscripten_jcache_printf("hello %.3f world\n", 123.456789123);
+ emscripten_jcache_printf("hello %llx world\n", 0x1234567811223344ULL);
+ return 0;
+ }
+ ''')
+ Popen([PYTHON, EMCC, self.in_dir('src.cpp')]).communicate()
+ output = run_js('a.out.js')
+ self.assertIdentical('hello world\nhello 5 world\nhello 123.457 world\nhello 1234567811223300 world\n', output)
+
def test_conftest_s_flag_passing(self):
open(os.path.join(self.get_dir(), 'conftest.c'), 'w').write(r'''
int main() {
@@ -11992,9 +12009,17 @@ fi
# finally, build a file close to the previous, to see that some chunks are found in the cache and some not
(['--jcache'], 'hello_libcxx_mod1.cpp', False, True, True, True, True, True, []), # win on pre, mix on funcs, mix on jsfuncs
(['--jcache'], 'hello_libcxx_mod1.cpp', False, True, False, True, False, True, []),
+ (None, None, None, None, None, None, None, None, None), # clear
+ (['--jcache'], 'hello_libcxx_mod2.cpp', True, False, True, False, True, False, []), # load into cache
+ (['--jcache'], 'hello_libcxx_mod2a.cpp', False, True, True, True, True, True, []) # add a printf, do not lose everything
]:
- print >> sys.stderr, args, input_file, expect_pre_save, expect_pre_load, expect_funcs_save, expect_funcs_load, expect_jsfuncs_save, expect_jsfuncs_load, expected
self.clear()
+ if args is None:
+ Cache.erase()
+ continue
+
+ print >> sys.stderr, args, input_file, expect_pre_save, expect_pre_load, expect_funcs_save, expect_funcs_load, expect_jsfuncs_save, expect_jsfuncs_load, expected
+
out, err = Popen([PYTHON, EMCC, '-O2', path_from_root('tests', input_file)] + args, stdout=PIPE, stderr=PIPE).communicate()
errtail = err.split('emcc invocation')[-1]
self.assertContained('hello, world!', run_js('a.out.js'), errtail)