diff --git a/.travis.yml b/.travis.yml index e11c5ced23..4f93e4e677 100644 --- a/.travis.yml +++ b/.travis.yml @@ -61,6 +61,17 @@ matrix: packages: - gcc-multilib - libgmp-dev:i386 + # clang with memory sanitizer + - compiler: clang + # --disable-openssl-tests because openssl uses uninitialized memory. ASM + # and BIGNUM are disabled because clang memory sanitizer does not work + # with inline assembly (https://clang.llvm.org/docs/MemorySanitizer.html). + # The memory sanitizer is instructed to exit with a different exit code + # using MSAN_OPTIONS. This is because the default exit code is 77 - the + # same exit code that autotools make check interprets as a test that is + # supposed to be skipped. + env: EXTRAFLAGS="--disable-openssl-tests CFLAGS=-fsanitize=memory" ASM=no BIGNUM=no EXPERIMENTAL=yes ENDOMORPHISM=yes RECOVERY=yes ECDH=yes MSAN_OPTIONS=exitcode=42 + before_install: mkdir -p `dirname $GUAVA_JAR` install: if [ ! -f $GUAVA_JAR ]; then wget $GUAVA_URL -O $GUAVA_JAR; fi before_script: ./autogen.sh @@ -68,3 +79,6 @@ script: - if [ -n "$HOST" ]; then export USE_HOST="--host=$HOST"; fi - if [ "x$HOST" = "xi686-linux-gnu" ]; then export CC="$CC -m32"; fi - ./configure --enable-experimental=$EXPERIMENTAL --enable-endomorphism=$ENDOMORPHISM --with-field=$FIELD --with-bignum=$BIGNUM --with-scalar=$SCALAR --enable-ecmult-static-precomputation=$STATICPRECOMPUTATION --with-ecmult-gen-precision=$ECMULTGENPRECISION --enable-module-ecdh=$ECDH --enable-module-recovery=$RECOVERY --enable-jni=$JNI $EXTRAFLAGS $USE_HOST && make -j2 $BUILD +after_script: + - cat ./tests.log + - cat ./exhaustive_tests.log diff --git a/src/tests.c b/src/tests.c index d408a5c30a..56779185cc 100644 --- a/src/tests.c +++ b/src/tests.c @@ -5167,8 +5167,16 @@ void run_ecdsa_openssl(void) { #endif int main(int argc, char **argv) { + unsigned char dummy1[16]; + unsigned char dummy2[16]; unsigned char seed16[16] = {0}; unsigned char run32[32] = {0}; + + /* Disable buffering for stdout to improve reliability of getting + * diagnostic information. Happens right at the start of main because + * setbuf must be used before any other operation on the stream. */ + setbuf(stdout, NULL); + /* find iteration count */ if (argc > 1) { count = strtol(argv[1], NULL, 0); @@ -5211,6 +5219,8 @@ int main(int argc, char **argv) { printf("test count = %i\n", count); printf("random seed = %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x\n", seed16[0], seed16[1], seed16[2], seed16[3], seed16[4], seed16[5], seed16[6], seed16[7], seed16[8], seed16[9], seed16[10], seed16[11], seed16[12], seed16[13], seed16[14], seed16[15]); + CHECK(memcmp(dummy1, dummy2, sizeof(dummy2)) == 0); + /* initialize */ run_context_tests(0); run_context_tests(1);