Skip to content

Commit ae3e6a1

Browse files
committed
Optionally compile the examples in autotools, compile+run in travis
1 parent 17af4a8 commit ae3e6a1

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
SECP256K1_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
@@ -6,11 +6,16 @@ exhaustive_tests
66
precompute_ecmult_gen
77
precompute_ecmult
88
valgrind_ctime_test
9+
ecdh_example
10+
ecdsa_example
11+
schnorr_example
912
*.exe
1013
*.so
1114
*.a
1215
*.csv
1316
!.gitignore
17+
*.log
18+
*.trs
1419

1520
Makefile
1621
configure

Makefile.am

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ noinst_HEADERS += contrib/lax_der_parsing.h
6363
noinst_HEADERS += contrib/lax_der_parsing.c
6464
noinst_HEADERS += contrib/lax_der_privatekey_parsing.h
6565
noinst_HEADERS += contrib/lax_der_privatekey_parsing.c
66+
noinst_HEADERS += examples/random.h
6667

6768
PRECOMPUTED_LIB = libsecp256k1_precomputed.la
6869
noinst_LTLIBRARIES = $(PRECOMPUTED_LIB)
@@ -139,6 +140,31 @@ exhaustive_tests_LDFLAGS = -static
139140
TESTS += exhaustive_tests
140141
endif
141142

143+
if USE_EXAMPLES
144+
noinst_PROGRAMS += ecdsa_example
145+
ecdsa_example_SOURCES = examples/ecdsa.c
146+
ecdsa_example_CPPFLAGS = -I$(top_srcdir)/include
147+
ecdsa_example_LDADD = libsecp256k1.la
148+
ecdsa_example_LDFLAGS = -static
149+
TESTS += ecdsa_example
150+
if ENABLE_MODULE_ECDH
151+
noinst_PROGRAMS += ecdh_example
152+
ecdh_example_SOURCES = examples/ecdh.c
153+
ecdh_example_CPPFLAGS = -I$(top_srcdir)/include
154+
ecdh_example_LDADD = libsecp256k1.la
155+
ecdh_example_LDFLAGS = -static
156+
TESTS += ecdh_example
157+
endif
158+
if ENABLE_MODULE_SCHNORRSIG
159+
noinst_PROGRAMS += schnorr_example
160+
schnorr_example_SOURCES = examples/schnorr.c
161+
schnorr_example_CPPFLAGS = -I$(top_srcdir)/include
162+
schnorr_example_LDADD = libsecp256k1.la
163+
schnorr_example_LDFLAGS = -static
164+
TESTS += schnorr_example
165+
endif
166+
endif
167+
142168
### Precomputed tables
143169
EXTRA_PROGRAMS = precompute_ecmult precompute_ecmult_gen
144170
CLEANFILES = $(EXTRA_PROGRAMS)

ci/cirrus.sh

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

configure.ac

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

138+
AC_ARG_ENABLE(examples,
139+
AS_HELP_STRING([--enable-examples],[compile the examples [default=no]]),
140+
[use_examples=$enableval],
141+
[use_examples=no])
142+
138143
AC_ARG_ENABLE(module_ecdh,
139144
AS_HELP_STRING([--enable-module-ecdh],[enable ECDH shared secret computation]),
140145
[enable_module_ecdh=$enableval],
@@ -393,6 +398,7 @@ AC_SUBST(SECP_CFLAGS)
393398
AM_CONDITIONAL([ENABLE_COVERAGE], [test x"$enable_coverage" = x"yes"])
394399
AM_CONDITIONAL([USE_TESTS], [test x"$use_tests" != x"no"])
395400
AM_CONDITIONAL([USE_EXHAUSTIVE_TESTS], [test x"$use_exhaustive_tests" != x"no"])
401+
AM_CONDITIONAL([USE_EXAMPLES], [test x"$use_examples" != x"no"])
396402
AM_CONDITIONAL([USE_BENCHMARK], [test x"$use_benchmark" = x"yes"])
397403
AM_CONDITIONAL([ENABLE_MODULE_ECDH], [test x"$enable_module_ecdh" = x"yes"])
398404
AM_CONDITIONAL([ENABLE_MODULE_RECOVERY], [test x"$enable_module_recovery" = x"yes"])
@@ -417,6 +423,7 @@ echo " with external callbacks = $use_external_default_callbacks"
417423
echo " with benchmarks = $use_benchmark"
418424
echo " with tests = $use_tests"
419425
echo " with coverage = $enable_coverage"
426+
echo " with examples = $use_examples"
420427
echo " module ecdh = $enable_module_ecdh"
421428
echo " module recovery = $enable_module_recovery"
422429
echo " module extrakeys = $enable_module_extrakeys"

0 commit comments

Comments
 (0)