From 95ea74549cc454d6d6a7462b366462589cd96712 Mon Sep 17 00:00:00 2001 From: Yossi Gottlieb Date: Tue, 23 Feb 2021 12:57:45 +0200 Subject: Fix failed tests on Linux Alpine and add a CI job. (#8532) * Remove linux/version.h dependency. This introduces unnecessary dependencies, and generally not a good idea as the platform we build on may be different than the platform we run on. To determine if sync_file_range exists we can simply rely on header file hints. * Fix setproctitle() on libmusl. The previous ifdef checks were a bit too strict for no apparent reason. * Fix tests failure on Linux with no backtrace. * Add alpine daily CI job. --- .github/workflows/daily.yml | 20 ++++++++++++++++++++ src/config.h | 17 ++--------------- src/fmacros.h | 1 - src/setproctitle.c | 2 +- tests/integration/logging.tcl | 14 +++++++++++++- 5 files changed, 36 insertions(+), 18 deletions(-) diff --git a/.github/workflows/daily.yml b/.github/workflows/daily.yml index 9d7eb65c9..6aa535c5e 100644 --- a/.github/workflows/daily.yml +++ b/.github/workflows/daily.yml @@ -221,3 +221,23 @@ jobs: MAKE=gmake ./runtest-moduleapi --verbose && ./runtest-sentinel && ./runtest-cluster + + test-alpine: + runs-on: ubuntu-latest + container: alpine:latest + steps: + - uses: actions/checkout@v2 + - name: make + run: | + apk add build-base + make REDIS_CFLAGS='-Werror' + - name: test + run: | + apk add tcl procps + ./runtest --accurate --verbose --dump-logs + - name: module api test + run: ./runtest-moduleapi --verbose + - name: sentinel tests + run: ./runtest-sentinel + - name: cluster tests + run: ./runtest-cluster diff --git a/src/config.h b/src/config.h index 1d4cb5835..56c1ab6ae 100644 --- a/src/config.h +++ b/src/config.h @@ -35,7 +35,6 @@ #endif #ifdef __linux__ -#include #include #endif @@ -114,19 +113,7 @@ /* Define rdb_fsync_range to sync_file_range() on Linux, otherwise we use * the plain fsync() call. */ -#ifdef __linux__ -#if defined(__GLIBC__) && defined(__GLIBC_PREREQ) -#if (LINUX_VERSION_CODE >= 0x020611 && __GLIBC_PREREQ(2, 6)) -#define HAVE_SYNC_FILE_RANGE 1 -#endif -#else -#if (LINUX_VERSION_CODE >= 0x020611) -#define HAVE_SYNC_FILE_RANGE 1 -#endif -#endif -#endif - -#ifdef HAVE_SYNC_FILE_RANGE +#if (defined(__linux__) && defined(SYNC_FILE_RANGE_WAIT_BEFORE)) #define rdb_fsync_range(fd,off,size) sync_file_range(fd,off,size,SYNC_FILE_RANGE_WAIT_BEFORE|SYNC_FILE_RANGE_WRITE) #else #define rdb_fsync_range(fd,off,size) fsync(fd) @@ -143,7 +130,7 @@ #define ESOCKTNOSUPPORT 0 #endif -#if ((defined __linux && defined(__GLIBC__)) || defined __APPLE__) +#if (defined __linux || defined __APPLE__) #define USE_SETPROCTITLE #define INIT_SETPROCTITLE_REPLACEMENT void spt_init(int argc, char *argv[]); diff --git a/src/fmacros.h b/src/fmacros.h index 089dc8de7..a97d21a47 100644 --- a/src/fmacros.h +++ b/src/fmacros.h @@ -60,7 +60,6 @@ #ifdef __linux__ /* features.h uses the defines above to set feature specific defines. */ -#include #include #endif diff --git a/src/setproctitle.c b/src/setproctitle.c index 1c91570eb..019402348 100644 --- a/src/setproctitle.c +++ b/src/setproctitle.c @@ -232,7 +232,7 @@ void spt_init(int argc, char *argv[]) { if (!(SPT.arg0 = strdup(argv[0]))) goto syerr; -#if __GLIBC__ +#if __linux__ if (!(tmp = strdup(program_invocation_name))) goto syerr; diff --git a/tests/integration/logging.tcl b/tests/integration/logging.tcl index fd9034644..fec14ff2b 100644 --- a/tests/integration/logging.tcl +++ b/tests/integration/logging.tcl @@ -1,6 +1,18 @@ set system_name [string tolower [exec uname -s]] +set system_supported 0 -if {$system_name eq {linux} || $system_name eq {darwin}} { +# We only support darwin or Linux with glibc +if {$system_name eq {darwin}} { + set system_supported 1 +} elseif {$system_name eq {linux}} { + # Avoid the test on libmusl, which does not support backtrace + set ldd [exec ldd src/redis-server] + if {![string match {*libc.musl*} $ldd]} { + set system_supported 1 + } +} + +if {$system_supported} { set server_path [tmpdir server.log] start_server [list overrides [list dir $server_path]] { test "Server is able to generate a stack trace on selected systems" { -- cgit v1.2.1