diff options
-rw-r--r-- | .github/workflows/build.yml | 18 | ||||
-rw-r--r-- | CMakeLists.txt | 10 | ||||
-rw-r--r-- | Makefile | 6 |
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) @@ -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) |