mirror of
https://github.com/zeromq/libzmq.git
synced 2024-12-13 18:55:10 +01:00
Merge pull request #1701 from madebr/cmake_test_include_source_dir
Problem: On Windows CI, in tests/test_timers.c, "Windows.hpp" could not be found.
This commit is contained in:
commit
47d9caa49a
@ -102,6 +102,7 @@ endif()
|
|||||||
|
|
||||||
foreach(test ${tests})
|
foreach(test ${tests})
|
||||||
add_executable(${test} ${test}.cpp)
|
add_executable(${test} ${test}.cpp)
|
||||||
|
target_include_directories(${test} PRIVATE "${CMAKE_SOURCE_DIR}/src")
|
||||||
target_link_libraries(${test} libzmq)
|
target_link_libraries(${test} libzmq)
|
||||||
|
|
||||||
if(RT_LIBRARY)
|
if(RT_LIBRARY)
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void _sleep (long timeout_)
|
void sleep_ (long timeout_)
|
||||||
{
|
{
|
||||||
#if defined ZMQ_HAVE_WINDOWS
|
#if defined ZMQ_HAVE_WINDOWS
|
||||||
Sleep (timeout_ > 0 ? timeout_ : INFINITE);
|
Sleep (timeout_ > 0 ? timeout_ : INFINITE);
|
||||||
@ -70,13 +70,13 @@ int main (void)
|
|||||||
assert (!timer_invoked);
|
assert (!timer_invoked);
|
||||||
|
|
||||||
// Wait half the time and check again
|
// Wait half the time and check again
|
||||||
_sleep (zmq_timers_timeout (timers) / 2);
|
sleep_ (zmq_timers_timeout (timers) / 2);
|
||||||
rc = zmq_timers_execute (timers);
|
rc = zmq_timers_execute (timers);
|
||||||
assert (rc == 0);
|
assert (rc == 0);
|
||||||
assert (!timer_invoked);
|
assert (!timer_invoked);
|
||||||
|
|
||||||
// Wait until the end
|
// Wait until the end
|
||||||
_sleep (zmq_timers_timeout (timers));
|
sleep_ (zmq_timers_timeout (timers));
|
||||||
rc = zmq_timers_execute (timers);
|
rc = zmq_timers_execute (timers);
|
||||||
assert (rc == 0);
|
assert (rc == 0);
|
||||||
assert (timer_invoked);
|
assert (timer_invoked);
|
||||||
@ -84,20 +84,20 @@ int main (void)
|
|||||||
|
|
||||||
// Wait half the time and check again
|
// Wait half the time and check again
|
||||||
long timeout = zmq_timers_timeout (timers);
|
long timeout = zmq_timers_timeout (timers);
|
||||||
_sleep (timeout / 2);
|
sleep_ (timeout / 2);
|
||||||
rc = zmq_timers_execute (timers);
|
rc = zmq_timers_execute (timers);
|
||||||
assert (rc == 0);
|
assert (rc == 0);
|
||||||
assert (!timer_invoked);
|
assert (!timer_invoked);
|
||||||
|
|
||||||
// Reset timer and wait half of the time left
|
// Reset timer and wait half of the time left
|
||||||
rc = zmq_timers_reset (timers, timer_id);
|
rc = zmq_timers_reset (timers, timer_id);
|
||||||
_sleep (timeout / 2);
|
sleep_ (timeout / 2);
|
||||||
rc = zmq_timers_execute (timers);
|
rc = zmq_timers_execute (timers);
|
||||||
assert (rc == 0);
|
assert (rc == 0);
|
||||||
assert (!timer_invoked);
|
assert (!timer_invoked);
|
||||||
|
|
||||||
// Wait until the end
|
// Wait until the end
|
||||||
_sleep (zmq_timers_timeout (timers));
|
sleep_ (zmq_timers_timeout (timers));
|
||||||
rc = zmq_timers_execute (timers);
|
rc = zmq_timers_execute (timers);
|
||||||
assert (rc == 0);
|
assert (rc == 0);
|
||||||
assert (timer_invoked);
|
assert (timer_invoked);
|
||||||
@ -105,7 +105,7 @@ int main (void)
|
|||||||
|
|
||||||
// reschedule
|
// reschedule
|
||||||
zmq_timers_set_interval (timers, timer_id, 50);
|
zmq_timers_set_interval (timers, timer_id, 50);
|
||||||
_sleep (51);
|
sleep_ (51);
|
||||||
rc = zmq_timers_execute (timers);
|
rc = zmq_timers_execute (timers);
|
||||||
assert (rc == 0);
|
assert (rc == 0);
|
||||||
assert (timer_invoked);
|
assert (timer_invoked);
|
||||||
@ -114,7 +114,7 @@ int main (void)
|
|||||||
// cancel timer
|
// cancel timer
|
||||||
timeout = zmq_timers_timeout (timers);
|
timeout = zmq_timers_timeout (timers);
|
||||||
zmq_timers_cancel (timers, timer_id);
|
zmq_timers_cancel (timers, timer_id);
|
||||||
_sleep (timeout * 2);
|
sleep_ (timeout * 2);
|
||||||
rc = zmq_timers_execute (timers);
|
rc = zmq_timers_execute (timers);
|
||||||
assert (rc == 0);
|
assert (rc == 0);
|
||||||
assert (!timer_invoked);
|
assert (!timer_invoked);
|
||||||
|
Loading…
Reference in New Issue
Block a user