mirror of
https://github.com/sogou/workflow.git
synced 2026-02-08 01:33:17 +08:00
UnitTest: start a redis server if no local one; skip memory check if valgrind is not found;
This commit is contained in:
@@ -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 ()
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user