UnitTest: start a redis server if no local one; skip memory check if valgrind is not found;

This commit is contained in:
holmes1412
2023-02-23 16:27:27 +08:00
parent 577d320806
commit 3e0ff22719
2 changed files with 12 additions and 4 deletions

View File

@@ -71,7 +71,8 @@ foreach(src ${TEST_LIST})
add_dependencies(check ${src})
endforeach()
foreach(src ${TEST_LIST})
add_test(${src}-memory-check ${memcheck_command} ./${src})
endforeach()
if (NOT ${CMAKE_MEMORYCHECK_COMMAND} STREQUAL "CMAKE_MEMORYCHECK_COMMAND-NOTFOUND")
foreach(src ${TEST_LIST})
add_test(${src}-memory-check ${memcheck_command} ./${src})
endforeach()
endif ()

View File

@@ -158,6 +158,11 @@ TEST(redis_unittest, WFRedisTask2)
std::mutex mutex;
std::condition_variable cond;
bool done = false;
bool server_started = false;
WFRedisServer server(__redis_process);
if (server.start("127.0.0.1", 6379) == 0)
server_started = true;
test_client("redis://127.0.0.1/6", mutex, cond, done);
std::unique_lock<std::mutex> lock(mutex);
@@ -165,5 +170,7 @@ TEST(redis_unittest, WFRedisTask2)
cond.wait(lock);
lock.unlock();
if (server_started)
server.stop();
}