summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYossi Gottlieb <yossigo@gmail.com>2021-02-23 12:57:45 +0200
committerOran Agra <oran@redislabs.com>2021-03-02 08:13:08 +0200
commitd0762100b073887179dd8c92e3b852a36192d4c8 (patch)
treec9a6e76133d52f0df0741be39bf3488c43c41aad
parent40ec7a27961d3aa73c69345600afd37712a30364 (diff)
downloadredis-d0762100b073887179dd8c92e3b852a36192d4c8.tar.gz
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. (cherry picked from commit 95ea74549cc454d6d6a7462b366462589cd96712)
-rw-r--r--.github/workflows/daily.yml2
-rw-r--r--src/config.h17
-rw-r--r--src/fmacros.h5
-rw-r--r--src/setproctitle.c2
-rw-r--r--tests/integration/logging.tcl15
5 files changed, 24 insertions, 17 deletions
diff --git a/.github/workflows/daily.yml b/.github/workflows/daily.yml
index f799239fe..a3817af33 100644
--- a/.github/workflows/daily.yml
+++ b/.github/workflows/daily.yml
@@ -189,6 +189,7 @@ jobs:
test-alpine-jemalloc:
runs-on: ubuntu-latest
+ if: github.repository == 'redis/redis'
container: alpine:latest
steps:
- uses: actions/checkout@v2
@@ -209,6 +210,7 @@ jobs:
test-alpine-libc-malloc:
runs-on: ubuntu-latest
+ if: github.repository == 'redis/redis'
container: alpine:latest
steps:
- uses: actions/checkout@v2
diff --git a/src/config.h b/src/config.h
index b9c68f38b..67f46de48 100644
--- a/src/config.h
+++ b/src/config.h
@@ -35,7 +35,6 @@
#endif
#ifdef __linux__
-#include <linux/version.h>
#include <features.h>
#endif
@@ -99,19 +98,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)
@@ -128,7 +115,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 6e56c759d..a97d21a47 100644
--- a/src/fmacros.h
+++ b/src/fmacros.h
@@ -58,4 +58,9 @@
#define _LARGEFILE_SOURCE
#define _FILE_OFFSET_BITS 64
+#ifdef __linux__
+/* features.h uses the defines above to set feature specific defines. */
+#include <features.h>
+#endif
+
#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 c1f4854d4..a52ed86c0 100644
--- a/tests/integration/logging.tcl
+++ b/tests/integration/logging.tcl
@@ -1,7 +1,20 @@
set server_path [tmpdir server.log]
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" {
r config set watchdog-period 200