Skip to content

Commit 3a6fd7f

Browse files
committed
Merge dashpay#750: Add macOS to the CI
71757da Explictly pass SECP256K1_BENCH_ITERS to the benchmarks in travis.sh (Elichai Turkel) 99bd661 Replace travis_wait with a loop printing "\a" to stdout every minute (Elichai Turkel) bc818b1 Bump travis Ubuntu from xenial(16.04) to bionic(18.04) (Elichai Turkel) 0c5ff90 Add macOS support to travis (Elichai Turkel) b6807d9 Move travis script into a standalone sh file (Elichai Turkel) Pull request description: ACKs for top commit: real-or-random: ACK 71757da I inspected the diff jonasnick: ACK 71757da Tree-SHA512: e8fab725ef5ed98c795f39d7f26b5d967a6bd730d40eb7d9793986858bf34770b0350c1b7b1d14ae608dfff9375a0750ec67c8e6d0d4b562ab917f5e645aa67b
2 parents f39f99b + 71757da commit 3a6fd7f

File tree

2 files changed

+94
-32
lines changed

2 files changed

+94
-32
lines changed

.travis.yml

+29-32
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
language: c
2-
os: linux
2+
os:
3+
- linux
4+
- osx
5+
6+
dist: bionic
7+
# Valgrind currently supports upto macOS 10.13, the latest xcode of that version is 10.1
8+
osx_image: xcode10.1
39
addons:
410
apt:
511
packages:
@@ -11,7 +17,7 @@ compiler:
1117
- gcc
1218
env:
1319
global:
14-
- FIELD=auto BIGNUM=auto SCALAR=auto ENDOMORPHISM=no STATICPRECOMPUTATION=yes ECMULTGENPRECISION=auto ASM=no BUILD=check EXTRAFLAGS= HOST= ECDH=no RECOVERY=no EXPERIMENTAL=no CTIMETEST=yes BENCH=yes SECP256K1_BENCH_ITERS=2
20+
- FIELD=auto BIGNUM=auto SCALAR=auto ENDOMORPHISM=no STATICPRECOMPUTATION=yes ECMULTGENPRECISION=auto ASM=no BUILD=check EXTRAFLAGS= HOST= ECDH=no RECOVERY=no EXPERIMENTAL=no CTIMETEST=yes BENCH=yes ITERS=2
1521
matrix:
1622
- SCALAR=32bit RECOVERY=yes
1723
- SCALAR=32bit FIELD=32bit ECDH=yes EXPERIMENTAL=yes
@@ -26,14 +32,17 @@ env:
2632
- BIGNUM=no ENDOMORPHISM=yes RECOVERY=yes EXPERIMENTAL=yes
2733
- BIGNUM=no STATICPRECOMPUTATION=no
2834
- BUILD=distcheck CTIMETEST= BENCH=
29-
- EXTRAFLAGS=CPPFLAGS=-DDETERMINISTIC
30-
- EXTRAFLAGS=CFLAGS=-O0
35+
- CPPFLAGS=-DDETERMINISTIC
36+
- CFLAGS=-O0 CTIMETEST=
3137
- ECMULTGENPRECISION=2
3238
- ECMULTGENPRECISION=8
39+
- VALGRIND=yes ENDOMORPHISM=yes BIGNUM=no ASM=x86_64 EXPERIMENTAL=yes ECDH=yes RECOVERY=yes EXTRAFLAGS="--disable-openssl-tests" CPPFLAGS=-DVALGRIND BUILD=
40+
- VALGRIND=yes BIGNUM=no ASM=x86_64 EXPERIMENTAL=yes ECDH=yes RECOVERY=yes EXTRAFLAGS="--disable-openssl-tests" CPPFLAGS=-DVALGRIND BUILD=
3341
matrix:
3442
fast_finish: true
3543
include:
3644
- compiler: clang
45+
os: linux
3746
env: HOST=i686-linux-gnu ENDOMORPHISM=yes
3847
addons:
3948
apt:
@@ -45,6 +54,7 @@ matrix:
4554
- libc6-dbg:i386
4655
- compiler: clang
4756
env: HOST=i686-linux-gnu
57+
os: linux
4858
addons:
4959
apt:
5060
packages:
@@ -54,6 +64,7 @@ matrix:
5464
- libc6-dbg:i386
5565
- compiler: gcc
5666
env: HOST=i686-linux-gnu ENDOMORPHISM=yes
67+
os: linux
5768
addons:
5869
apt:
5970
packages:
@@ -62,6 +73,7 @@ matrix:
6273
- libtool-bin
6374
- libc6-dbg:i386
6475
- compiler: gcc
76+
os: linux
6577
env: HOST=i686-linux-gnu
6678
addons:
6779
apt:
@@ -71,41 +83,26 @@ matrix:
7183
- valgrind
7284
- libtool-bin
7385
- libc6-dbg:i386
74-
- compiler: gcc
75-
env:
76-
- BIGNUM=no ENDOMORPHISM=yes ASM=x86_64 EXPERIMENTAL=yes ECDH=yes RECOVERY=yes
77-
- VALGRIND=yes EXTRAFLAGS="--disable-openssl-tests CPPFLAGS=-DVALGRIND" BUILD=
78-
- compiler: gcc
79-
env: # The same as above but without endomorphism.
80-
- BIGNUM=no ENDOMORPHISM=no ASM=x86_64 EXPERIMENTAL=yes ECDH=yes RECOVERY=yes
81-
- VALGRIND=yes EXTRAFLAGS="--disable-openssl-tests CPPFLAGS=-DVALGRIND" BUILD=
86+
87+
# We use this to install macOS dependencies instead of the built in `homebrew` plugin,
88+
# because in xcode earlier than 11 they have a bug requiring updating the system which overall takes ~8 minutes.
89+
# https://travis-ci.community/t/macos-build-fails-because-of-homebrew-bundle-unknown-command/7296
90+
before_install:
91+
- if [ "${TRAVIS_OS_NAME}" = "osx" ]; then HOMEBREW_NO_AUTO_UPDATE=1 brew install gmp valgrind gcc@9; fi
8292

8393
before_script: ./autogen.sh
8494

95+
# travis auto terminates jobs that go for 10 minutes without printing to stdout, but travis_wait doesn't work well with forking programs like valgrind (https://docs.travis-ci.com/user/common-build-problems/#build-times-out-because-no-output-was-received https://github.com/bitcoin-core/secp256k1/pull/750#issuecomment-623476860)
8596
script:
86-
- if [ -n "$HOST" ]; then export USE_HOST="--host=$HOST"; fi
87-
- if [ "x$HOST" = "xi686-linux-gnu" ]; then export CC="$CC -m32"; fi
88-
- ./configure --enable-experimental=$EXPERIMENTAL --enable-endomorphism=$ENDOMORPHISM --with-field=$FIELD --with-bignum=$BIGNUM --with-asm=$ASM --with-scalar=$SCALAR --enable-ecmult-static-precomputation=$STATICPRECOMPUTATION --with-ecmult-gen-precision=$ECMULTGENPRECISION --enable-module-ecdh=$ECDH --enable-module-recovery=$RECOVERY $EXTRAFLAGS $USE_HOST
89-
- if [ -n "$BUILD" ]; then make -j2 $BUILD; fi
90-
- # travis_wait extends the 10 minutes without output allowed (https://docs.travis-ci.com/user/common-build-problems/#build-times-out-because-no-output-was-received)
91-
- # the `--error-exitcode` is required to make the test fail if valgrind found errors, otherwise it'll return 0 (http://valgrind.org/docs/manual/manual-core.html)
92-
- if [ -n "$VALGRIND" ]; then
93-
make -j2 &&
94-
travis_wait 30 valgrind --error-exitcode=42 ./tests 16 &&
95-
travis_wait 30 valgrind --error-exitcode=42 ./exhaustive_tests;
96-
fi
97-
- if [ -n "$BENCH" ]; then
98-
if [ -n "$VALGRIND" ]; then EXEC='libtool --mode=execute valgrind --error-exitcode=42'; else EXEC= ; fi &&
99-
$EXEC ./bench_ecmult &>> bench.log && $EXEC ./bench_internal &>> bench.log && $EXEC ./bench_sign &>> bench.log && $EXEC ./bench_verify &>> bench.log &&
100-
if [ "$RECOVERY" == "yes" ]; then $EXEC ./bench_recover &>> bench.log; fi &&
101-
if [ "$ECDH" == "yes" ]; then $EXEC ./bench_ecdh &>> bench.log; fi;
102-
fi
103-
- if [ -n "$CTIMETEST" ]; then
104-
libtool --mode=execute valgrind ./valgrind_ctime_test &> valgrind_ctime_test.log;
105-
fi
97+
- function keep_alive() { while true; do echo -en "\a"; sleep 60; done }
98+
- keep_alive &
99+
- ./contrib/travis.sh
100+
- kill %keep_alive
106101

107102
after_script:
108103
- cat ./tests.log
109104
- cat ./exhaustive_tests.log
110105
- cat ./valgrind_ctime_test.log
111106
- cat ./bench.log
107+
- $CC --version
108+
- valgrind --version

contrib/travis.sh

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/bin/sh
2+
3+
set -e
4+
set -x
5+
6+
if [ -n "$HOST" ]
7+
then
8+
export USE_HOST="--host=$HOST"
9+
fi
10+
if [ "$HOST" = "i686-linux-gnu" ]
11+
then
12+
export CC="$CC -m32"
13+
fi
14+
if [ "$TRAVIS_OS_NAME" = "osx" ] && [ "$TRAVIS_COMPILER" = "gcc" ]
15+
then
16+
export CC="gcc-9"
17+
fi
18+
19+
./configure \
20+
--enable-experimental="$EXPERIMENTAL" --enable-endomorphism="$ENDOMORPHISM" \
21+
--with-field="$FIELD" --with-bignum="$BIGNUM" --with-asm="$ASM" --with-scalar="$SCALAR" \
22+
--enable-ecmult-static-precomputation="$STATICPRECOMPUTATION" --with-ecmult-gen-precision="$ECMULTGENPRECISION" \
23+
--enable-module-ecdh="$ECDH" --enable-module-recovery="$RECOVERY" "$EXTRAFLAGS" "$USE_HOST"
24+
25+
if [ -n "$BUILD" ]
26+
then
27+
make -j2 "$BUILD"
28+
fi
29+
if [ -n "$VALGRIND" ]
30+
then
31+
make -j2
32+
# the `--error-exitcode` is required to make the test fail if valgrind found errors, otherwise it'll return 0 (http://valgrind.org/docs/manual/manual-core.html)
33+
valgrind --error-exitcode=42 ./tests 16
34+
valgrind --error-exitcode=42 ./exhaustive_tests
35+
fi
36+
if [ -n "$BENCH" ]
37+
then
38+
if [ -n "$VALGRIND" ]
39+
then
40+
# Using the local `libtool` because on macOS the system's libtool has nothing to do with GNU libtool
41+
EXEC='./libtool --mode=execute valgrind --error-exitcode=42'
42+
else
43+
EXEC=
44+
fi
45+
# This limits the iterations in the benchmarks below to ITER(set in .travis.yml) iterations.
46+
export SECP256K1_BENCH_ITERS="$ITERS"
47+
{
48+
$EXEC ./bench_ecmult
49+
$EXEC ./bench_internal
50+
$EXEC ./bench_sign
51+
$EXEC ./bench_verify
52+
} >> bench.log 2>&1
53+
if [ "$RECOVERY" = "yes" ]
54+
then
55+
$EXEC ./bench_recover >> bench.log 2>&1
56+
fi
57+
if [ "$ECDH" = "yes" ]
58+
then
59+
$EXEC ./bench_ecdh >> bench.log 2>&1
60+
fi
61+
fi
62+
if [ -n "$CTIMETEST" ]
63+
then
64+
./libtool --mode=execute valgrind --error-exitcode=42 ./valgrind_ctime_test > valgrind_ctime_test.log 2>&1
65+
fi

0 commit comments

Comments
 (0)