Optionally compile the examples in autotools, compile+run in travis

This commit is contained in:
Elichai Turkel 2020-04-30 14:34:24 +03:00
parent 422a7cc86a
commit 517644eab1
No known key found for this signature in database
GPG Key ID: 9383CDE9E8E66A7F
5 changed files with 56 additions and 0 deletions

View File

@ -23,6 +23,8 @@ env:
BENCH: yes BENCH: yes
SECP256K1_BENCH_ITERS: 2 SECP256K1_BENCH_ITERS: 2
CTIMETEST: yes CTIMETEST: yes
# Compile and run the tests
EXAMPLES: yes
cat_logs_snippet: &CAT_LOGS cat_logs_snippet: &CAT_LOGS
always: always:

5
.gitignore vendored
View File

@ -6,11 +6,16 @@ exhaustive_tests
precompute_ecmult_gen precompute_ecmult_gen
precompute_ecmult precompute_ecmult
valgrind_ctime_test valgrind_ctime_test
ecdh_example
ecdsa_example
schnorr_example
*.exe *.exe
*.so *.so
*.a *.a
*.csv *.csv
!.gitignore !.gitignore
*.log
*.trs
Makefile Makefile
configure configure

View File

@ -63,6 +63,7 @@ noinst_HEADERS += contrib/lax_der_parsing.h
noinst_HEADERS += contrib/lax_der_parsing.c noinst_HEADERS += contrib/lax_der_parsing.c
noinst_HEADERS += contrib/lax_der_privatekey_parsing.h noinst_HEADERS += contrib/lax_der_privatekey_parsing.h
noinst_HEADERS += contrib/lax_der_privatekey_parsing.c noinst_HEADERS += contrib/lax_der_privatekey_parsing.c
noinst_HEADERS += examples/random.h
PRECOMPUTED_LIB = libsecp256k1_precomputed.la PRECOMPUTED_LIB = libsecp256k1_precomputed.la
noinst_LTLIBRARIES = $(PRECOMPUTED_LIB) noinst_LTLIBRARIES = $(PRECOMPUTED_LIB)
@ -139,6 +140,40 @@ exhaustive_tests_LDFLAGS = -static
TESTS += exhaustive_tests TESTS += exhaustive_tests
endif endif
if USE_EXAMPLES
noinst_PROGRAMS += ecdsa_example
ecdsa_example_SOURCES = examples/ecdsa.c
ecdsa_example_CPPFLAGS = -I$(top_srcdir)/include
ecdsa_example_LDADD = libsecp256k1.la
ecdsa_example_LDFLAGS = -static
if BUILD_WINDOWS
ecdsa_example_LDFLAGS += -lbcrypt
endif
TESTS += ecdsa_example
if ENABLE_MODULE_ECDH
noinst_PROGRAMS += ecdh_example
ecdh_example_SOURCES = examples/ecdh.c
ecdh_example_CPPFLAGS = -I$(top_srcdir)/include
ecdh_example_LDADD = libsecp256k1.la
ecdh_example_LDFLAGS = -static
if BUILD_WINDOWS
ecdh_example_LDFLAGS += -lbcrypt
endif
TESTS += ecdh_example
endif
if ENABLE_MODULE_SCHNORRSIG
noinst_PROGRAMS += schnorr_example
schnorr_example_SOURCES = examples/schnorr.c
schnorr_example_CPPFLAGS = -I$(top_srcdir)/include
schnorr_example_LDADD = libsecp256k1.la
schnorr_example_LDFLAGS = -static
if BUILD_WINDOWS
schnorr_example_LDFLAGS += -lbcrypt
endif
TESTS += schnorr_example
endif
endif
### Precomputed tables ### Precomputed tables
EXTRA_PROGRAMS = precompute_ecmult precompute_ecmult_gen EXTRA_PROGRAMS = precompute_ecmult precompute_ecmult_gen
CLEANFILES = $(EXTRA_PROGRAMS) CLEANFILES = $(EXTRA_PROGRAMS)

View File

@ -19,6 +19,7 @@ valgrind --version || true
--with-ecmult-gen-precision="$ECMULTGENPRECISION" \ --with-ecmult-gen-precision="$ECMULTGENPRECISION" \
--enable-module-ecdh="$ECDH" --enable-module-recovery="$RECOVERY" \ --enable-module-ecdh="$ECDH" --enable-module-recovery="$RECOVERY" \
--enable-module-schnorrsig="$SCHNORRSIG" \ --enable-module-schnorrsig="$SCHNORRSIG" \
--enable-examples="$EXAMPLES" \
--with-valgrind="$WITH_VALGRIND" \ --with-valgrind="$WITH_VALGRIND" \
--host="$HOST" $EXTRAFLAGS --host="$HOST" $EXTRAFLAGS

View File

@ -45,6 +45,8 @@ if test x"$ac_cv_prog_cc_c89" = x"no"; then
fi fi
AM_PROG_AS AM_PROG_AS
build_windows=no
case $host_os in case $host_os in
*darwin*) *darwin*)
if test x$cross_compiling != xyes; then if test x$cross_compiling != xyes; then
@ -68,6 +70,9 @@ case $host_os in
fi fi
fi fi
;; ;;
cygwin*|mingw*)
build_windows=yes
;;
esac esac
# Try if some desirable compiler flags are supported and append them to SECP_CFLAGS. # Try if some desirable compiler flags are supported and append them to SECP_CFLAGS.
@ -135,6 +140,11 @@ AC_ARG_ENABLE(exhaustive_tests,
[use_exhaustive_tests=$enableval], [use_exhaustive_tests=$enableval],
[use_exhaustive_tests=yes]) [use_exhaustive_tests=yes])
AC_ARG_ENABLE(examples,
AS_HELP_STRING([--enable-examples],[compile the examples [default=no]]),
[use_examples=$enableval],
[use_examples=no])
AC_ARG_ENABLE(module_ecdh, AC_ARG_ENABLE(module_ecdh,
AS_HELP_STRING([--enable-module-ecdh],[enable ECDH shared secret computation]), AS_HELP_STRING([--enable-module-ecdh],[enable ECDH shared secret computation]),
[enable_module_ecdh=$enableval], [enable_module_ecdh=$enableval],
@ -393,6 +403,7 @@ AC_SUBST(SECP_CFLAGS)
AM_CONDITIONAL([ENABLE_COVERAGE], [test x"$enable_coverage" = x"yes"]) AM_CONDITIONAL([ENABLE_COVERAGE], [test x"$enable_coverage" = x"yes"])
AM_CONDITIONAL([USE_TESTS], [test x"$use_tests" != x"no"]) AM_CONDITIONAL([USE_TESTS], [test x"$use_tests" != x"no"])
AM_CONDITIONAL([USE_EXHAUSTIVE_TESTS], [test x"$use_exhaustive_tests" != x"no"]) AM_CONDITIONAL([USE_EXHAUSTIVE_TESTS], [test x"$use_exhaustive_tests" != x"no"])
AM_CONDITIONAL([USE_EXAMPLES], [test x"$use_examples" != x"no"])
AM_CONDITIONAL([USE_BENCHMARK], [test x"$use_benchmark" = x"yes"]) AM_CONDITIONAL([USE_BENCHMARK], [test x"$use_benchmark" = x"yes"])
AM_CONDITIONAL([ENABLE_MODULE_ECDH], [test x"$enable_module_ecdh" = x"yes"]) AM_CONDITIONAL([ENABLE_MODULE_ECDH], [test x"$enable_module_ecdh" = x"yes"])
AM_CONDITIONAL([ENABLE_MODULE_RECOVERY], [test x"$enable_module_recovery" = x"yes"]) AM_CONDITIONAL([ENABLE_MODULE_RECOVERY], [test x"$enable_module_recovery" = x"yes"])
@ -400,6 +411,7 @@ AM_CONDITIONAL([ENABLE_MODULE_EXTRAKEYS], [test x"$enable_module_extrakeys" = x"
AM_CONDITIONAL([ENABLE_MODULE_SCHNORRSIG], [test x"$enable_module_schnorrsig" = x"yes"]) AM_CONDITIONAL([ENABLE_MODULE_SCHNORRSIG], [test x"$enable_module_schnorrsig" = x"yes"])
AM_CONDITIONAL([USE_EXTERNAL_ASM], [test x"$use_external_asm" = x"yes"]) AM_CONDITIONAL([USE_EXTERNAL_ASM], [test x"$use_external_asm" = x"yes"])
AM_CONDITIONAL([USE_ASM_ARM], [test x"$set_asm" = x"arm"]) AM_CONDITIONAL([USE_ASM_ARM], [test x"$set_asm" = x"arm"])
AM_CONDITIONAL([BUILD_WINDOWS], [test "$build_windows" = "yes"])
AC_SUBST(LIB_VERSION_CURRENT, _LIB_VERSION_CURRENT) AC_SUBST(LIB_VERSION_CURRENT, _LIB_VERSION_CURRENT)
AC_SUBST(LIB_VERSION_REVISION, _LIB_VERSION_REVISION) AC_SUBST(LIB_VERSION_REVISION, _LIB_VERSION_REVISION)
AC_SUBST(LIB_VERSION_AGE, _LIB_VERSION_AGE) AC_SUBST(LIB_VERSION_AGE, _LIB_VERSION_AGE)
@ -417,6 +429,7 @@ echo " with external callbacks = $use_external_default_callbacks"
echo " with benchmarks = $use_benchmark" echo " with benchmarks = $use_benchmark"
echo " with tests = $use_tests" echo " with tests = $use_tests"
echo " with coverage = $enable_coverage" echo " with coverage = $enable_coverage"
echo " with examples = $use_examples"
echo " module ecdh = $enable_module_ecdh" echo " module ecdh = $enable_module_ecdh"
echo " module recovery = $enable_module_recovery" echo " module recovery = $enable_module_recovery"
echo " module extrakeys = $enable_module_extrakeys" echo " module extrakeys = $enable_module_extrakeys"