diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/cmake/target_js/CMakeLists.txt | 26 | ||||
-rw-r--r-- | tests/cmake/target_js/jslibrary.js | 7 | ||||
-rw-r--r-- | tests/cmake/target_js/jslibrary2.js | 7 | ||||
-rw-r--r-- | tests/cmake/target_js/main.cpp | 10 | ||||
-rw-r--r-- | tests/cmake/target_js/out.txt | 4 | ||||
-rw-r--r-- | tests/cmake/target_js/postjs.js | 1 | ||||
-rw-r--r-- | tests/cmake/target_js/prejs.js | 1 | ||||
-rw-r--r-- | tests/test_browser.py | 4 | ||||
-rw-r--r-- | tests/test_core.py | 32 | ||||
-rw-r--r-- | tests/test_other.py | 4 | ||||
-rw-r--r-- | tests/unistd/io.c | 6 | ||||
-rw-r--r-- | tests/unistd/io.out | 4 |
12 files changed, 97 insertions, 9 deletions
diff --git a/tests/cmake/target_js/CMakeLists.txt b/tests/cmake/target_js/CMakeLists.txt index cee5fc42..244cc70a 100644 --- a/tests/cmake/target_js/CMakeLists.txt +++ b/tests/cmake/target_js/CMakeLists.txt @@ -1,11 +1,15 @@ cmake_minimum_required(VERSION 2.8) -project(hello_world) +project(test_cmake) -file(GLOB sourceFiles ../../hello_world.cpp) +file(GLOB sourceFiles main.cpp) + +file(GLOB preJsFiles pre*.js) +file(GLOB postJsFiles post*.js) +file(GLOB libraryJsFiles jslibrary*.js) if (CMAKE_BUILD_TYPE STREQUAL Debug) - SET(linkFlags "") + SET(linkFlags "-g4") else() # Either MinSizeRel, RelWithDebInfo or Release, all which run with optimizations enabled. SET(linkFlags "-O2") endif() @@ -28,5 +32,17 @@ if (NOT CMAKE_C_SIZEOF_DATA_PTR) message(FATAL_ERROR "CMAKE_C_SIZEOF_DATA_PTR was not defined!") endif() -add_executable(hello_world ${sourceFiles}) -set_target_properties(hello_world PROPERTIES LINK_FLAGS "${linkFlags}") +add_executable(test_cmake ${sourceFiles}) + +# GOTCHA: If your project has custom link flags, these must be set *before* calling any of the em_link_xxx functions! +set_target_properties(test_cmake PROPERTIES LINK_FLAGS "${linkFlags}") + +message(STATUS "js libs '${libraryJsFiles}'") +# To link .js files using the --js-library flag, use the following helper function. +em_link_js_library(test_cmake ${libraryJsFiles}) + +# To link .js files using the --pre-js flag, use the following helper function. +em_link_pre_js(test_cmake ${preJsFiles}) + +# To link .js files using the --post-js flag, use the following helper function. +em_link_post_js(test_cmake ${postJsFiles}) diff --git a/tests/cmake/target_js/jslibrary.js b/tests/cmake/target_js/jslibrary.js new file mode 100644 index 00000000..63375d8f --- /dev/null +++ b/tests/cmake/target_js/jslibrary.js @@ -0,0 +1,7 @@ +var mylib = {}; + +mylib.lib_function = function() { + console.log('lib_function'); +} + +mergeInto(LibraryManager.library, mylib); diff --git a/tests/cmake/target_js/jslibrary2.js b/tests/cmake/target_js/jslibrary2.js new file mode 100644 index 00000000..5d322e2d --- /dev/null +++ b/tests/cmake/target_js/jslibrary2.js @@ -0,0 +1,7 @@ +var mylib = {}; + +mylib.lib_function2 = function() { + console.log('lib_function2'); +} + +mergeInto(LibraryManager.library, mylib); diff --git a/tests/cmake/target_js/main.cpp b/tests/cmake/target_js/main.cpp new file mode 100644 index 00000000..4b61dbf7 --- /dev/null +++ b/tests/cmake/target_js/main.cpp @@ -0,0 +1,10 @@ +extern "C" { + void lib_function(); + void lib_function2(); +} + +int main() +{ + lib_function(); + lib_function2(); +} diff --git a/tests/cmake/target_js/out.txt b/tests/cmake/target_js/out.txt new file mode 100644 index 00000000..76135df7 --- /dev/null +++ b/tests/cmake/target_js/out.txt @@ -0,0 +1,4 @@ +prejs executed +lib_function +lib_function2 +postjs executed
\ No newline at end of file diff --git a/tests/cmake/target_js/postjs.js b/tests/cmake/target_js/postjs.js new file mode 100644 index 00000000..5a1b44ce --- /dev/null +++ b/tests/cmake/target_js/postjs.js @@ -0,0 +1 @@ +console.log('postjs executed'); diff --git a/tests/cmake/target_js/prejs.js b/tests/cmake/target_js/prejs.js new file mode 100644 index 00000000..87beb770 --- /dev/null +++ b/tests/cmake/target_js/prejs.js @@ -0,0 +1 @@ +console.log('prejs executed'); diff --git a/tests/test_browser.py b/tests/test_browser.py index 6a23b41c..a3b9a1c3 100644 --- a/tests/test_browser.py +++ b/tests/test_browser.py @@ -1477,7 +1477,9 @@ keydown(100);keyup(100); // trigger the end }, 2000); }; ''') - self.btest('pre_run_deps.cpp', expected='10', args=['--pre-js', 'pre.js']) + + for mem in [0, 1]: + self.btest('pre_run_deps.cpp', expected='10', args=['--pre-js', 'pre.js', '--memory-init-file', str(mem)]) def test_worker_api(self): Popen([PYTHON, EMCC, path_from_root('tests', 'worker_api_worker.cpp'), '-o', 'worker.js', '-s', 'BUILD_AS_WORKER=1', '-s', 'EXPORTED_FUNCTIONS=["_one"]']).communicate() diff --git a/tests/test_core.py b/tests/test_core.py index dd3b7c44..a882ab59 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -6908,6 +6908,29 @@ at function.:blag printf("%i\n", a); } + char buf1[100], buf2[100], buf3[100], buf4[100]; + + int numItems = sscanf("level=4:ref=3", "%255[^:=]=%255[^:]:%255[^=]=%255c", buf1, buf2, buf3, buf4); + printf("%d, %s, %s, %s, %s\n", numItems, buf1, buf2, buf3, buf4); + + numItems = sscanf("def|456", "%[a-z]|%[0-9]", buf1, buf2); + printf("%d, %s, %s\n", numItems, buf1, buf2); + + numItems = sscanf("3-4,-ab", "%[-0-9],%[ab-z-]", buf1, buf2); + printf("%d, %s, %s\n", numItems, buf1, buf2); + + numItems = sscanf("Hello,World", "%[A-Za-z],%[^0-9]", buf1, buf2); + printf("%d, %s, %s\n", numItems, buf1, buf2); + + numItems = sscanf("Hello4711", "%[^0-9],%[^0-9]", buf1, buf2); + printf("%d, %s\n", numItems, buf1); + + numItems = sscanf("JavaScript", "%4[A-Za-z]", buf1); + printf("%d, %s\n", numItems, buf1); + + numItems = sscanf("[]", "%1[[]%1[]]", buf1, buf2); + printf("%d, %s, %s\n", numItems, buf1, buf2); + return 0; } ''' @@ -6915,7 +6938,14 @@ at function.:blag '1\n1499\n' + '5\n87,0.481565,0.059481,0,1\n' + '3\n-123,4294966531,-34\n' + - '1\n') + '1\n' + + '4, level, 4, ref, 3\n' + + '2, def, 456\n' + + '2, 3-4, -ab\n' + + '2, Hello, World\n' + + '1, Hello\n' + + '1, Java\n' + + '2, [, ]') def test_sscanf_2(self): # doubles diff --git a/tests/test_other.py b/tests/test_other.py index b11f22e5..56c13650 100644 --- a/tests/test_other.py +++ b/tests/test_other.py @@ -295,7 +295,7 @@ f.close() make = make_commands[generator] cmake_cases = ['target_js', 'target_html'] - cmake_outputs = ['hello_world.js', 'hello_world_gles.html'] + cmake_outputs = ['test_cmake.js', 'hello_world_gles.html'] for i in range(0, 2): for configuration in ['Debug', 'Release']: # CMake can be invoked in two ways, using 'emconfigure cmake', or by directly running 'cmake'. @@ -342,7 +342,7 @@ f.close() # Run through node, if CMake produced a .js file. if cmake_outputs[i].endswith('.js'): ret = Popen(listify(NODE_JS) + [tempdirname + '/' + cmake_outputs[i]], stdout=PIPE).communicate()[0] - assert 'hello, world!' in ret, 'Running cmake-based .js application failed!' + self.assertTextDataIdentical(open(cmakelistsdir + '/out.txt', 'r').read().strip(), ret.strip()) finally: os.chdir(path_from_root('tests')) # Move away from the directory we are about to remove. shutil.rmtree(tempdirname) diff --git a/tests/unistd/io.c b/tests/unistd/io.c index 0ff5f4fb..6bf22593 100644 --- a/tests/unistd/io.c +++ b/tests/unistd/io.c @@ -104,6 +104,12 @@ int main() { printf("errno: %d\n\n", errno); errno = 0; + printf("pread past end of file: %d\n", pread(f, readBuffer, sizeof readBuffer, 99999999999)); + printf("data: %s\n", readBuffer); + memset(readBuffer, 0, sizeof readBuffer); + printf("errno: %d\n\n", errno); + errno = 0; + printf("seek: %d\n", lseek(f, 3, SEEK_SET)); printf("errno: %d\n\n", errno); printf("partial read from file: %d\n", read(f, readBuffer, 3)); diff --git a/tests/unistd/io.out b/tests/unistd/io.out index 037d0c34..c979557e 100644 --- a/tests/unistd/io.out +++ b/tests/unistd/io.out @@ -31,6 +31,10 @@ read from file: 10 data: 1234567890 errno: 0 +pread past end of file: 0 +data: +errno: 0 + seek: 3 errno: 0 |