testing: pools - it does not make sense to block on a semaphore there
authorMichael Wallner <mike@php.net>
Wed, 7 Oct 2020 07:28:18 +0000 (09:28 +0200)
committerMichael Wallner <mike@php.net>
Wed, 7 Oct 2020 07:28:18 +0000 (09:28 +0200)
.github/workflows/cmake-build-ci.gen
.github/workflows/cmake-build-ci.yml
codecov.yml
test/CMakeLists.txt
test/conf.h.in
test/tests/memcached/util_pool_thread.cpp

index 2648ecafaa623ef2d482588afcc820dcc42f3b0a..6f7c48a18e27d1129f740ce228efdb909bd78bbd 100755 (executable)
@@ -192,6 +192,7 @@ on:
       - "docs/**"
     branches-ignore:
       - gh-pages
+      - catch
       - v1.x
   pull_request:
     branches:
index 7e5939f889a27386e1bbca51fb27c3a8c19b5dcd..e2de43d1d1df4fc688af5ca93b7ed085ce41d429 100644 (file)
@@ -6,6 +6,7 @@ on:
       - "docs/**"
     branches-ignore:
       - gh-pages
+      - catch
       - v1.x
   pull_request:
     branches:
index df50744daa2d6f29e638388b26ca56b63234b6d2..afa0dac194800fcb093bce9a4909512483fd29f5 100644 (file)
@@ -10,7 +10,7 @@ coverage:
       default:
         target: auto
         threshold: 1%
-  range: 60..90
+  range: 50..80
   round: nearest
   precision: 0
   notify:
index 7a6faee9682a749b1aa9eb1809d4d2c7fbe1b3e7..ebb39afe84a755f11b8da79f8ca69ac91b1f7f2d 100644 (file)
@@ -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)
index 931aab96aacb361ee50f500c55a9f9e10156436e..91843964527538ecf40ceade4b0b812a0f5a010a 100644 (file)
@@ -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
index 0f90a008f17cce081aea94ec1c6bf47f77697f60..f8ac8501594c9882f8b054784ea75601d71edc05 100644 (file)
@@ -1,36 +1,18 @@
 #include "test/lib/common.hpp"
 
-#if HAVE_SEMAPHORE_H
-
 #include "libmemcachedutil-1.0/pool.h"
 #include <cassert>
-#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<test_pool_context_st *>(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