Skip to content

Commit 1b92b3b

Browse files
committed
Optionally compile the examples in autotools, compile+run in travis
1 parent c0c32a6 commit 1b92b3b

File tree

5 files changed

+41
-0
lines changed

5 files changed

+41
-0
lines changed

.cirrus.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ env:
2323
BENCH: yes
2424
BENCH_ITERS: 2
2525
CTIMETEST: yes
26+
# Compile and run the tests
27+
EXAMPLES: yes
2628

2729
cat_logs_snippet: &CAT_LOGS
2830
always:

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,15 @@ tests
1010
exhaustive_tests
1111
gen_context
1212
valgrind_ctime_test
13+
ecdh_example
14+
ecdsa_example
15+
schnorr_example
1316
*.exe
1417
*.so
1518
*.a
1619
!.gitignore
20+
*.log
21+
*.trs
1722

1823
Makefile
1924
configure

Makefile.am

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ noinst_HEADERS += contrib/lax_der_parsing.h
5454
noinst_HEADERS += contrib/lax_der_parsing.c
5555
noinst_HEADERS += contrib/lax_der_privatekey_parsing.h
5656
noinst_HEADERS += contrib/lax_der_privatekey_parsing.c
57+
noinst_HEADERS += examples/random.h
5758

5859
if USE_EXTERNAL_ASM
5960
COMMON_LIB = libsecp256k1_common.la
@@ -127,6 +128,31 @@ exhaustive_tests_LDFLAGS = -static
127128
TESTS += exhaustive_tests
128129
endif
129130

131+
if USE_EXAMPLES
132+
noinst_PROGRAMS += ecdsa_example
133+
ecdsa_example_SOURCES = examples/ecdsa.c
134+
ecdsa_example_CPPFLAGS = -I$(top_srcdir)/include
135+
ecdsa_example_LDADD = libsecp256k1.la
136+
ecdsa_example_LDFLAGS = -static
137+
TESTS += ecdsa_example
138+
if ENABLE_MODULE_ECDH
139+
noinst_PROGRAMS += ecdh_example
140+
ecdh_example_SOURCES = examples/ecdh.c
141+
ecdh_example_CPPFLAGS = -I$(top_srcdir)/include
142+
ecdh_example_LDADD = libsecp256k1.la
143+
ecdh_example_LDFLAGS = -static
144+
TESTS += ecdh_example
145+
endif
146+
if ENABLE_MODULE_SCHNORRSIG
147+
noinst_PROGRAMS += schnorr_example
148+
schnorr_example_SOURCES = examples/schnorr.c
149+
schnorr_example_CPPFLAGS = -I$(top_srcdir)/include
150+
schnorr_example_LDADD = libsecp256k1.la
151+
schnorr_example_LDFLAGS = -static
152+
TESTS += schnorr_example
153+
endif
154+
endif
155+
130156
if USE_ECMULT_STATIC_PRECOMPUTATION
131157
CPPFLAGS_FOR_BUILD +=-I$(top_srcdir) -I$(builddir)/src
132158

ci/cirrus.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ valgrind --version || true
1818
--enable-ecmult-static-precomputation="$STATICPRECOMPUTATION" --with-ecmult-gen-precision="$ECMULTGENPRECISION" \
1919
--enable-module-ecdh="$ECDH" --enable-module-recovery="$RECOVERY" \
2020
--enable-module-schnorrsig="$SCHNORRSIG" \
21+
--enable-examples="$EXAMPLES" \
2122
--with-valgrind="$WITH_VALGRIND" \
2223
--host="$HOST" $EXTRAFLAGS
2324

configure.ac

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,11 @@ AC_ARG_ENABLE(exhaustive_tests,
136136
[use_exhaustive_tests=$enableval],
137137
[use_exhaustive_tests=yes])
138138

139+
AC_ARG_ENABLE(examples,
140+
AS_HELP_STRING([--enable-examples],[compile the examples [default=no]]),
141+
[use_examples=$enableval],
142+
[use_examples=no])
143+
139144
AC_ARG_ENABLE(ecmult_static_precomputation,
140145
AS_HELP_STRING([--enable-ecmult-static-precomputation],[enable precomputed ecmult table for signing [default=auto]]),
141146
[use_ecmult_static_precomputation=$enableval],
@@ -495,6 +500,7 @@ AC_SUBST(SECP_CFLAGS)
495500
AM_CONDITIONAL([ENABLE_COVERAGE], [test x"$enable_coverage" = x"yes"])
496501
AM_CONDITIONAL([USE_TESTS], [test x"$use_tests" != x"no"])
497502
AM_CONDITIONAL([USE_EXHAUSTIVE_TESTS], [test x"$use_exhaustive_tests" != x"no"])
503+
AM_CONDITIONAL([USE_EXAMPLES], [test x"$use_examples" != x"no"])
498504
AM_CONDITIONAL([USE_BENCHMARK], [test x"$use_benchmark" = x"yes"])
499505
AM_CONDITIONAL([USE_ECMULT_STATIC_PRECOMPUTATION], [test x"$set_precomp" = x"yes"])
500506
AM_CONDITIONAL([ENABLE_MODULE_ECDH], [test x"$enable_module_ecdh" = x"yes"])
@@ -519,6 +525,7 @@ echo " with benchmarks = $use_benchmark"
519525
echo " with tests = $use_tests"
520526
echo " with openssl tests = $enable_openssl_tests"
521527
echo " with coverage = $enable_coverage"
528+
echo " with examples = $use_examples"
522529
echo " module ecdh = $enable_module_ecdh"
523530
echo " module recovery = $enable_module_recovery"
524531
echo " module extrakeys = $enable_module_extrakeys"

0 commit comments

Comments
 (0)