Add DETERMINISTIC to avoid line number/source dependent binaries

This will make it easier to detect changes without semantic impact.
pull/11871/head
Pieter Wuille 10 years ago
parent a5f7483d3e
commit f49b2ef840

@ -6,7 +6,7 @@ install:
- if [ "$FIELD" = "64bit_asm" ]; then sudo apt-get install -qq yasm; fi - if [ "$FIELD" = "64bit_asm" ]; then sudo apt-get install -qq yasm; fi
env: env:
global: global:
- FIELD=auto BIGNUM=auto SCALAR=auto ENDOMORPHISM=no BUILD=check - FIELD=auto BIGNUM=auto SCALAR=auto ENDOMORPHISM=no BUILD=check EXTRAFLAGS=
matrix: matrix:
- SCALAR=32bit - SCALAR=32bit
- SCALAR=64bit - SCALAR=64bit
@ -19,6 +19,7 @@ env:
- FIELD=32bit - FIELD=32bit
- FIELD=32bit ENDOMORPHISM=yes - FIELD=32bit ENDOMORPHISM=yes
- BUILD=distcheck - BUILD=distcheck
- EXTRAFLAGS=CFLAGS=-DDETERMINISTIC
before_script: ./autogen.sh before_script: ./autogen.sh
script: ./configure --enable-endomorphism=$ENDOMORPHISM --with-field=$FIELD --with-bignum=$BIGNUM --with-scalar=$SCALAR && make -j2 $BUILD script: ./configure --enable-endomorphism=$ENDOMORPHISM --with-field=$FIELD --with-bignum=$BIGNUM --with-scalar=$SCALAR $EXTRAFLAGS && make -j2 $BUILD
os: linux os: linux

@ -15,10 +15,17 @@
#include <stdint.h> #include <stdint.h>
#include <stdio.h> #include <stdio.h>
#ifdef DETERMINISTIC
#define TEST_FAILURE(msg) do { \
fprintf(stderr, "%s\n", msg); \
abort(); \
} while(0);
#else
#define TEST_FAILURE(msg) do { \ #define TEST_FAILURE(msg) do { \
fprintf(stderr, "%s:%d: %s\n", __FILE__, __LINE__, msg); \ fprintf(stderr, "%s:%d: %s\n", __FILE__, __LINE__, msg); \
abort(); \ abort(); \
} while(0) } while(0)
#endif
#ifndef HAVE_BUILTIN_EXPECT #ifndef HAVE_BUILTIN_EXPECT
#define EXPECT(x,c) __builtin_expect((x),(c)) #define EXPECT(x,c) __builtin_expect((x),(c))
@ -26,11 +33,19 @@
#define EXPECT(x,c) (x) #define EXPECT(x,c) (x)
#endif #endif
#ifdef DETERMINISTIC
#define CHECK(cond) do { \
if (EXPECT(!(cond), 0)) { \
TEST_FAILURE("test condition failed"); \
} \
} while(0)
#else
#define CHECK(cond) do { \ #define CHECK(cond) do { \
if (EXPECT(!(cond), 0)) { \ if (EXPECT(!(cond), 0)) { \
TEST_FAILURE("test condition failed: " #cond); \ TEST_FAILURE("test condition failed: " #cond); \
} \ } \
} while(0) } while(0)
#endif
/* Like assert(), but safe to use on expressions with side effects. */ /* Like assert(), but safe to use on expressions with side effects. */
#ifndef NDEBUG #ifndef NDEBUG

Loading…
Cancel
Save