From 4dc37bf81b55b9a3ffcf09f7a212436d25844710 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Sat, 17 Apr 2021 10:57:16 -0700 Subject: [PATCH 1/2] Add mingw32-w64/wine CI build --- .cirrus.yml | 21 +++++++++++++++++++++ ci/cirrus.sh | 12 +++++++++++- ci/linux-debian.Dockerfile | 6 +++++- 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index 506a86033..ffae165bb 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -196,3 +196,24 @@ task: - rm /etc/ld.so.cache - ./ci/cirrus.sh << : *CAT_LOGS + +task: + name: "x86_64 (mingw32-w64): Windows (Debian stable, Wine)" + container: + dockerfile: ci/linux-debian.Dockerfile + cpu: 1 + memory: 1G + env: + WINE_CMD: wine64-stable + HOST: x86_64-w64-mingw32 + BUILD: + WITH_VALGRIND: no + ECDH: yes + RECOVERY: yes + EXPERIMENTAL: yes + SCHNORRSIG: yes + CTIMETEST: no + << : *MERGE_BASE + test_script: + - ./ci/cirrus.sh + << : *CAT_LOGS diff --git a/ci/cirrus.sh b/ci/cirrus.sh index f26ca98d1..dafab8ae3 100755 --- a/ci/cirrus.sh +++ b/ci/cirrus.sh @@ -25,7 +25,7 @@ valgrind --version || true make # Print information about binaries so that we can see that the architecture is correct -file *tests || true +file *tests* || true file bench_* || true file .libs/* || true @@ -47,6 +47,12 @@ then $QEMU_CMD ./exhaustive_tests fi +if [ -n "$WINE_CMD" ] +then + $WINE_CMD ./tests 16 + $WINE_CMD ./exhaustive_tests +fi + if [ "$BENCH" = "yes" ] then # Using the local `libtool` because on macOS the system's libtool has nothing to do with GNU libtool @@ -59,6 +65,10 @@ then then EXEC="$EXEC valgrind --error-exitcode=42" fi + if [ -n "$WINE_CMD" ] + then + EXEC="$WINE_CMD" + fi # This limits the iterations in the benchmarks below to ITER iterations. export SECP256K1_BENCH_ITERS="$ITERS" { diff --git a/ci/linux-debian.Dockerfile b/ci/linux-debian.Dockerfile index 5967cf8b3..ef2518ff0 100644 --- a/ci/linux-debian.Dockerfile +++ b/ci/linux-debian.Dockerfile @@ -10,4 +10,8 @@ RUN apt-get install --no-install-recommends --no-upgrade -y \ make automake libtool pkg-config dpkg-dev valgrind qemu-user \ gcc clang libc6-dbg \ gcc-i686-linux-gnu libc6-dev-i386-cross libc6-dbg:i386 \ - gcc-s390x-linux-gnu libc6-dev-s390x-cross libc6-dbg:s390x + gcc-s390x-linux-gnu libc6-dev-s390x-cross libc6-dbg:s390x \ + wine gcc-mingw-w64-x86-64 + +# Run a dummy command in wine to make it set up configuration +RUN wine64-stable xcopy || true From ed5a199bed65bf084f34ce18d35807d31a1c75bb Mon Sep 17 00:00:00 2001 From: Tim Ruffing Date: Sat, 1 May 2021 13:06:55 +0200 Subject: [PATCH 2/2] tests: fopen /dev/urandom in binary mode This makes a difference with mingw builds on Wine, where the subsequent fread() may abort early in the default text mode. The Microsoft C docs say: "In text mode, CTRL+Z is interpreted as an EOF character on input." --- src/testrand_impl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/testrand_impl.h b/src/testrand_impl.h index e643778f3..c8d30ef6a 100644 --- a/src/testrand_impl.h +++ b/src/testrand_impl.h @@ -127,7 +127,7 @@ static void secp256k1_testrand_init(const char* hexseed) { pos++; } } else { - FILE *frand = fopen("/dev/urandom", "r"); + FILE *frand = fopen("/dev/urandom", "rb"); if ((frand == NULL) || fread(&seed16, 1, sizeof(seed16), frand) != sizeof(seed16)) { uint64_t t = time(NULL) * (uint64_t)1337; fprintf(stderr, "WARNING: could not read 16 bytes from /dev/urandom; falling back to insecure PRNG\n");