From 61620d7e42e4cddebd5534750aea65af5facb147 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Tue, 25 Nov 2014 09:51:39 -0800 Subject: [PATCH] Make 'make check' actually run the tests on Emscripten. --- configure.ac | 2 +- dist-build/emscripten.sh | 22 ++++++++++++++++++---- test/default/Makefile.am | 1 + test/default/{pre.js => pre.js.inc} | 0 4 files changed, 20 insertions(+), 5 deletions(-) rename test/default/{pre.js => pre.js.inc} (100%) mode change 100644 => 100755 diff --git a/configure.ac b/configure.ac index 59befcca..a5d693a8 100644 --- a/configure.ac +++ b/configure.ac @@ -416,7 +416,7 @@ AC_SUBST([LIBTOOL_EXTRA_FLAGS]) TEST_LDFLAGS='' AS_IF([test "x$EMSCRIPTEN" != "x"],[ EXEEXT=.js - TEST_LDFLAGS='--pre-js pre.js' + TEST_LDFLAGS='--pre-js pre.js.inc' ]) AC_SUBST(TEST_LDFLAGS) diff --git a/dist-build/emscripten.sh b/dist-build/emscripten.sh index 49790bfd..3d89835c 100755 --- a/dist-build/emscripten.sh +++ b/dist-build/emscripten.sh @@ -1,5 +1,6 @@ #! /bin/sh +export MAKE_FLAGS='-j4' export PREFIX="$(pwd)/libsodium-js" export EXPORTED_FUNCTIONS='["_crypto_aead_chacha20poly1305_abytes","_crypto_aead_chacha20poly1305_decrypt","_crypto_aead_chacha20poly1305_encrypt","_crypto_aead_chacha20poly1305_keybytes","_crypto_aead_chacha20poly1305_npubbytes","_crypto_aead_chacha20poly1305_nsecbytes","_crypto_auth","_crypto_auth_bytes","_crypto_auth_keybytes","_crypto_auth_verify","_crypto_box","_crypto_box_detached","_crypto_box_easy","_crypto_box_keypair","_crypto_box_macbytes","_crypto_box_noncebytes","_crypto_box_open","_crypto_box_open_detached","_crypto_box_open_easy","_crypto_box_publickeybytes","_crypto_box_secretkeybytes","_crypto_box_seed_keypair","_crypto_box_seedbytes","_crypto_generichash","_crypto_generichash_bytes","_crypto_generichash_bytes_max","_crypto_generichash_bytes_min","_crypto_generichash_final","_crypto_generichash_init","_crypto_generichash_keybytes","_crypto_generichash_keybytes_max","_crypto_generichash_keybytes_min","_crypto_generichash_update","_crypto_hash","_crypto_hash_bytes","_crypto_scalarmult","_crypto_scalarmult_base","_crypto_scalarmult_bytes","_crypto_scalarmult_scalarbytes","_crypto_secretbox","_crypto_secretbox_detached","_crypto_secretbox_easy","_crypto_secretbox_keybytes","_crypto_secretbox_macbytes","_crypto_secretbox_noncebytes","_crypto_secretbox_open","_crypto_secretbox_open_detached","_crypto_secretbox_open_easy","_crypto_shorthash","_crypto_shorthash_bytes","_crypto_shorthash_keybytes","_crypto_sign","_crypto_sign_bytes","_crypto_sign_detached","_crypto_sign_ed25519_pk_to_curve25519","_crypto_sign_ed25519_sk_to_curve25519","_crypto_sign_keypair","_crypto_sign_open","_crypto_sign_publickeybytes","_crypto_sign_secretkeybytes","_crypto_sign_seed_keypair","_crypto_sign_seedbytes","_crypto_sign_verify_detached","_randombytes","_randombytes_buf","_randombytes_close","_randombytes_random","_randombytes_set_implementation","_randombytes_stir","_randombytes_sysrandom","_randombytes_sysrandom_buf","_randombytes_sysrandom_close","_randombytes_sysrandom_stir","_randombytes_sysrandom_uniform","_randombytes_uniform","_sodium_bin2hex","_sodium_hex2bin","_sodium_init","_sodium_library_version_major","_sodium_library_version_minor","_sodium_memcmp","_sodium_memzero","_sodium_version_string"]' export TOTAL_MEMORY=33554432 @@ -8,8 +9,21 @@ export LDFLAGS="-s TOTAL_MEMORY=${TOTAL_MEMORY}" emconfigure ./configure --enable-minimal --disable-shared --prefix="$PREFIX" \ CFLAGS="-O3" && \ -emmake make clean && -emmake make -j2 install V=1 && +emmake make clean && \ +emmake make $MAKE_FLAGS install V=1 && \ emcc -O3 --closure 1 --llvm-lto 1 $LDFLAGS $JS_EXPORTS_FLAGS \ - "${PREFIX}/lib/libsodium.a" -o "${PREFIX}/lib/libsodium.js" && -emmake make -j2 check V=1 + "${PREFIX}/lib/libsodium.a" -o "${PREFIX}/lib/libsodium.js" && \ +echo 'Compiling the test suite...' && \ +emmake make $MAKE_FLAGS check > /dev/null 2>&1 + +echo 'Running the test suite:' && \ +( + cd test/default && \ + for file in *.js; do + echo "#! /usr/bin/env node" > "${file}.tmp" + fgrep -v '#! /usr/bin/env node' "$file" >> "${file}.tmp" + chmod +x "${file}.tmp" + mv -f "${file}.tmp" "$file" + done +) +make $MAKE_FLAGS check && echo 'Done.' diff --git a/test/default/Makefile.am b/test/default/Makefile.am index 9434ac39..7608bb71 100644 --- a/test/default/Makefile.am +++ b/test/default/Makefile.am @@ -2,6 +2,7 @@ EXTRA_DIST = \ cmptest.h \ wintest.bat \ + pre.js.inc \ aead_chacha20poly1305.exp \ auth.exp \ auth2.exp \ diff --git a/test/default/pre.js b/test/default/pre.js.inc old mode 100644 new mode 100755 similarity index 100% rename from test/default/pre.js rename to test/default/pre.js.inc