From 96fce03b6aeece751471d10af766e1a195701b45 Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Wed, 7 Oct 2020 09:28:18 +0200 Subject: [PATCH] testing: pools - it does not make sense to block on a semaphore there --- .github/workflows/cmake-build-ci.gen | 1 + .github/workflows/cmake-build-ci.yml | 1 + codecov.yml | 2 +- test/CMakeLists.txt | 2 -- test/conf.h.in | 1 - test/tests/memcached/util_pool_thread.cpp | 32 ++++------------------- 6 files changed, 8 insertions(+), 31 deletions(-) diff --git a/.github/workflows/cmake-build-ci.gen b/.github/workflows/cmake-build-ci.gen index 2648ecaf..6f7c48a1 100755 --- a/.github/workflows/cmake-build-ci.gen +++ b/.github/workflows/cmake-build-ci.gen @@ -192,6 +192,7 @@ on: - "docs/**" branches-ignore: - gh-pages + - catch - v1.x pull_request: branches: diff --git a/.github/workflows/cmake-build-ci.yml b/.github/workflows/cmake-build-ci.yml index 7e5939f8..e2de43d1 100644 --- a/.github/workflows/cmake-build-ci.yml +++ b/.github/workflows/cmake-build-ci.yml @@ -6,6 +6,7 @@ on: - "docs/**" branches-ignore: - gh-pages + - catch - v1.x pull_request: branches: diff --git a/codecov.yml b/codecov.yml index df50744d..afa0dac1 100644 --- a/codecov.yml +++ b/codecov.yml @@ -10,7 +10,7 @@ coverage: default: target: auto threshold: 1% - range: 60..90 + range: 50..80 round: nearest precision: 0 notify: diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 7a6faee9..ebb39afe 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -4,8 +4,6 @@ endif() include(CMake/Catch.cmake) -check_header(semaphore.h) - check_decl(pipe2 unistd.h) check_decl(SOCK_NONBLOCK sys/socket.h) check_decl(SOCK_CLOEXEC sys/socket.h) diff --git a/test/conf.h.in b/test/conf.h.in index 931aab96..91843964 100644 --- a/test/conf.h.in +++ b/test/conf.h.in @@ -1,6 +1,5 @@ #pragma once -#cmakedefine HAVE_SEMAPHORE_H 1 #cmakedefine HAVE_PIPE2 1 #cmakedefine HAVE_SOCK_NONBLOCK 1 #cmakedefine HAVE_SOCK_CLOEXEC 1 diff --git a/test/tests/memcached/util_pool_thread.cpp b/test/tests/memcached/util_pool_thread.cpp index 0f90a008..f8ac8501 100644 --- a/test/tests/memcached/util_pool_thread.cpp +++ b/test/tests/memcached/util_pool_thread.cpp @@ -1,36 +1,18 @@ #include "test/lib/common.hpp" -#if HAVE_SEMAPHORE_H - #include "libmemcachedutil-1.0/pool.h" #include -#include "semaphore.h" struct test_pool_context_st { volatile memcached_return_t rc; memcached_pool_st *pool; memcached_st *memc; - sem_t _lock; - - test_pool_context_st(memcached_pool_st *pool_arg, memcached_st *memc_arg) : - rc(MEMCACHED_FAILURE), - pool(pool_arg), - memc(memc_arg) { - if (sem_init(&_lock, 0, 0)) { - perror("sem_init()"); - } - } - - void wait() { - sem_wait(&_lock); - } - - void release() { - sem_post(&_lock); - } - ~test_pool_context_st() { - sem_destroy(&_lock); + test_pool_context_st(memcached_pool_st *pool_arg, memcached_st *memc_arg) + : rc(MEMCACHED_FAILURE) + , pool(pool_arg) + , memc(memc_arg) + { } }; @@ -40,7 +22,6 @@ static void *connection_release(void *arg) { this_thread::sleep_for(200ms); auto res = static_cast(arg); res->rc = memcached_pool_release(res->pool, res->memc); - res->release(); pthread_exit(arg); } @@ -67,7 +48,6 @@ TEST_CASE("memcached_util_pool_thread") { test_pool_context_st item(pool, pool_memc); REQUIRE(0 == pthread_create(&tid, nullptr, connection_release, &item)); - item.wait(); memcached_st *pop_memc; do { @@ -92,5 +72,3 @@ TEST_CASE("memcached_util_pool_thread") { REQUIRE(memcached_pool_destroy(pool) == *memc); } - -#endif // HAVE_SEMAPHORE_H -- 2.30.2