summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjörn Svensson <bjorn.a.svensson@est.tech>2021-10-25 10:13:48 +0200
committerBjörn Svensson <bjorn.a.svensson@est.tech>2021-10-26 09:54:44 +0200
commit648763c36e9f6493b13a77da35eb33ef0652b4e2 (patch)
tree0428b4fdc5b89f1d737b4e267dc279f36c1a9c06
parentc98c6994ded45e774c3459baa2936f06f8a2c331 (diff)
Add build options for enabling async tests
Asynchronous testcases that requires the event library `libevent` can be built and enabled by using the added build flags: - ENABLE_ASYNC_TESTS when using CMake - TEST_ASYNC when using Make The async tests are disabled by default to avoid adding new requirements, but the testcases are built and run in CI.
-rw-r--r--.github/workflows/build.yml18
-rw-r--r--CMakeLists.txt10
-rw-r--r--Makefile6
3 files changed, 22 insertions, 12 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 2ce06a1..af834ab 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -15,17 +15,17 @@ jobs:
run: |
sudo add-apt-repository -y ppa:chris-lea/redis-server
sudo apt-get update
- sudo apt-get install -y redis-server valgrind
+ sudo apt-get install -y redis-server valgrind libevent-dev
- name: Build using cmake
env:
- EXTRA_CMAKE_OPTS: -DENABLE_EXAMPLES:BOOL=ON -DENABLE_SSL:BOOL=ON -DENABLE_SSL_TESTS:BOOL=ON
+ EXTRA_CMAKE_OPTS: -DENABLE_EXAMPLES:BOOL=ON -DENABLE_SSL:BOOL=ON -DENABLE_SSL_TESTS:BOOL=ON -DENABLE_ASYNC_TESTS:BOOL=ON
CFLAGS: -Werror
CXXFLAGS: -Werror
run: mkdir build-ubuntu && cd build-ubuntu && cmake ..
- name: Build using makefile
- run: USE_SSL=1 make
+ run: USE_SSL=1 TEST_ASYNC=1 make
- name: Run tests
env:
@@ -53,17 +53,17 @@ jobs:
run: |
yum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
yum -y --enablerepo=remi install redis
- yum -y install gcc gcc-c++ make openssl openssl-devel cmake3 valgrind
+ yum -y install gcc gcc-c++ make openssl openssl-devel cmake3 valgrind libevent-devel
- name: Build using cmake
env:
- EXTRA_CMAKE_OPTS: -DENABLE_EXAMPLES:BOOL=ON -DENABLE_SSL:BOOL=ON -DENABLE_SSL_TESTS:BOOL=ON
+ EXTRA_CMAKE_OPTS: -DENABLE_EXAMPLES:BOOL=ON -DENABLE_SSL:BOOL=ON -DENABLE_SSL_TESTS:BOOL=ON -DENABLE_ASYNC_TESTS:BOOL=ON
CFLAGS: -Werror
CXXFLAGS: -Werror
run: mkdir build-centos7 && cd build-centos7 && cmake3 ..
- name: Build using Makefile
- run: USE_SSL=1 make
+ run: USE_SSL=1 TEST_ASYNC=1 make
- name: Run tests
env:
@@ -93,17 +93,17 @@ jobs:
dnf -y install https://rpms.remirepo.net/enterprise/remi-release-8.rpm
dnf -y module install redis:remi-6.0
dnf -y group install "Development Tools"
- dnf -y install openssl-devel cmake valgrind
+ dnf -y install openssl-devel cmake valgrind libevent-devel
- name: Build using cmake
env:
- EXTRA_CMAKE_OPTS: -DENABLE_EXAMPLES:BOOL=ON -DENABLE_SSL:BOOL=ON -DENABLE_SSL_TESTS:BOOL=ON
+ EXTRA_CMAKE_OPTS: -DENABLE_EXAMPLES:BOOL=ON -DENABLE_SSL:BOOL=ON -DENABLE_SSL_TESTS:BOOL=ON -DENABLE_ASYNC_TESTS:BOOL=ON
CFLAGS: -Werror
CXXFLAGS: -Werror
run: mkdir build-centos8 && cd build-centos8 && cmake ..
- name: Build using Makefile
- run: USE_SSL=1 make
+ run: USE_SSL=1 TEST_ASYNC=1 make
- name: Run tests
env:
diff --git a/CMakeLists.txt b/CMakeLists.txt
index eb43f01..6d290a7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -5,6 +5,7 @@ PROJECT(hiredis)
OPTION(ENABLE_SSL "Build hiredis_ssl for SSL support" OFF)
OPTION(DISABLE_TESTS "If tests should be compiled or not" OFF)
OPTION(ENABLE_SSL_TESTS "Should we test SSL connections" OFF)
+OPTION(ENABLE_ASYNC_TESTS "Should we run all asynchronous API tests" OFF)
MACRO(getVersionBit name)
SET(VERSION_REGEX "^#define ${name} (.+)$")
@@ -218,11 +219,14 @@ ENDIF()
IF(NOT DISABLE_TESTS)
ENABLE_TESTING()
ADD_EXECUTABLE(hiredis-test test.c)
+ TARGET_LINK_LIBRARIES(hiredis-test hiredis)
IF(ENABLE_SSL_TESTS)
ADD_DEFINITIONS(-DHIREDIS_TEST_SSL=1)
- TARGET_LINK_LIBRARIES(hiredis-test hiredis hiredis_ssl)
- ELSE()
- TARGET_LINK_LIBRARIES(hiredis-test hiredis)
+ TARGET_LINK_LIBRARIES(hiredis-test hiredis_ssl)
+ ENDIF()
+ IF(ENABLE_ASYNC_TESTS)
+ ADD_DEFINITIONS(-DHIREDIS_TEST_ASYNC=1)
+ TARGET_LINK_LIBRARIES(hiredis-test event)
ENDIF()
ADD_TEST(NAME hiredis-test
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/test.sh)
diff --git a/Makefile b/Makefile
index 34c7909..f30c2ac 100644
--- a/Makefile
+++ b/Makefile
@@ -75,6 +75,9 @@ USE_SSL?=0
ifeq ($(USE_SSL),1)
export CFLAGS+=-DHIREDIS_TEST_SSL
endif
+ifeq ($(TEST_ASYNC),1)
+ export CFLAGS+=-DHIREDIS_TEST_ASYNC
+endif
ifeq ($(uname_S),Linux)
ifdef OPENSSL_PREFIX
@@ -211,6 +214,9 @@ ifeq ($(USE_SSL),1)
TEST_LIBS += $(SSL_STLIBNAME)
TEST_LDFLAGS = $(SSL_LDFLAGS) -lssl -lcrypto -lpthread
endif
+ifeq ($(TEST_ASYNC),1)
+ TEST_LDFLAGS += -levent
+endif
hiredis-test: test.o $(TEST_LIBS)
$(CC) -o $@ $(REAL_CFLAGS) -I. $^ $(REAL_LDFLAGS) $(TEST_LDFLAGS)