mirror of
https://github.com/falk-werner/webfuse
synced 2024-10-27 20:34:10 +00:00
chore: replaced msleep by std::this_thread::sleep_for
This commit is contained in:
parent
1a29b44ad6
commit
107e66b65a
@ -18,7 +18,6 @@ add_executable(alltests
|
||||
lib/wf/timer/test/wf/timer/test_timer.cc
|
||||
test/webfuse/utils/tempdir.cc
|
||||
test/webfuse/utils/file_utils.cc
|
||||
test/webfuse/utils/msleep.cc
|
||||
test/webfuse/utils/die_if.cc
|
||||
test/webfuse/utils/timeout_watcher.cc
|
||||
test/webfuse/utils/path.c
|
||||
|
@ -1,10 +1,13 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include "wf/jsonrpc/proxy.h"
|
||||
#include "wf/timer/manager.h"
|
||||
#include "webfuse/utils/msleep.hpp"
|
||||
#include "webfuse/core/json_util.h"
|
||||
|
||||
using webfuse_test::msleep;
|
||||
#include <thread>
|
||||
#include <chrono>
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
|
||||
#define WF_DEFAULT_TIMEOUT (10 * 1000)
|
||||
|
||||
@ -289,7 +292,7 @@ TEST(wf_jsonrpc_proxy, timeout)
|
||||
ASSERT_TRUE(send_context.is_called);
|
||||
ASSERT_TRUE(json_is_object(send_context.response));
|
||||
|
||||
msleep(10);
|
||||
std::this_thread::sleep_for(10ms);
|
||||
wf_timer_manager_check(timer_manager);
|
||||
|
||||
ASSERT_TRUE(finished_context.is_called);
|
||||
|
@ -1,14 +1,16 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "webfuse/utils/msleep.hpp"
|
||||
#include "wf/timer/impl/timepoint.h"
|
||||
|
||||
using webfuse_test::msleep;
|
||||
#include <thread>
|
||||
#include <chrono>
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
TEST(wf_timer_timepoint, now)
|
||||
{
|
||||
wf_timer_timepoint start = wf_timer_impl_timepoint_now();
|
||||
msleep(42);
|
||||
std::this_thread::sleep_for(42ms);
|
||||
wf_timer_timepoint end = wf_timer_impl_timepoint_now();
|
||||
|
||||
ASSERT_LT(start, end);
|
||||
|
@ -1,13 +1,14 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <cstddef>
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
|
||||
#include "webfuse/utils/msleep.hpp"
|
||||
#include "wf/timer/timer.h"
|
||||
#include "wf/timer/manager.h"
|
||||
|
||||
using std::size_t;
|
||||
using webfuse_test::msleep;
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
extern "C"
|
||||
{
|
||||
@ -37,7 +38,7 @@ TEST(wf_timer, trigger)
|
||||
struct wf_timer * timer = wf_timer_create(manager, &on_timeout, reinterpret_cast<void*>(&triggered));
|
||||
|
||||
wf_timer_start(timer, 250);
|
||||
msleep(500);
|
||||
std::this_thread::sleep_for(500ms);
|
||||
wf_timer_manager_check(manager);
|
||||
|
||||
ASSERT_TRUE(triggered);
|
||||
@ -67,7 +68,7 @@ TEST(wf_timer, cancel)
|
||||
struct wf_timer * timer = wf_timer_create(manager, &on_timeout, reinterpret_cast<void*>(&triggered));
|
||||
|
||||
wf_timer_start(timer, 250);
|
||||
msleep(500);
|
||||
std::this_thread::sleep_for(500ms);
|
||||
wf_timer_cancel(timer);
|
||||
wf_timer_manager_check(manager);
|
||||
|
||||
@ -90,7 +91,7 @@ TEST(wf_timer, cancel_multiple_timers)
|
||||
wf_timer_start(timer[i], 0);
|
||||
}
|
||||
|
||||
msleep(10);
|
||||
std::this_thread::sleep_for(10ms);
|
||||
for(size_t i = 0; i < count; i++)
|
||||
{
|
||||
wf_timer_cancel(timer[i]);
|
||||
@ -122,7 +123,7 @@ TEST(wf_timer, multiple_timers)
|
||||
|
||||
for(size_t i = 0; i < count; i++)
|
||||
{
|
||||
msleep(100);
|
||||
std::this_thread::sleep_for(100ms);
|
||||
wf_timer_manager_check(manager);
|
||||
}
|
||||
|
||||
|
@ -3,10 +3,12 @@
|
||||
#include "webfuse/provider/impl/client.h"
|
||||
#include <thread>
|
||||
#include <mutex>
|
||||
#include <chrono>
|
||||
#include <string>
|
||||
#include "webfuse/utils/msleep.hpp"
|
||||
#include "webfuse/utils/static_filesystem.h"
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
namespace webfuse_test
|
||||
{
|
||||
|
||||
@ -29,7 +31,7 @@ public:
|
||||
}
|
||||
|
||||
thread = std::thread(Run, this);
|
||||
webfuse_test::msleep(200);
|
||||
std::this_thread::sleep_for(200ms);
|
||||
}
|
||||
|
||||
~Private()
|
||||
|
@ -6,7 +6,6 @@
|
||||
#include <unistd.h>
|
||||
#include "webfuse_adapter.h"
|
||||
#include "webfuse/adapter/impl/server.h"
|
||||
#include "webfuse/utils/msleep.hpp"
|
||||
|
||||
#define WF_PATH_MAX (100)
|
||||
|
||||
|
@ -1,19 +0,0 @@
|
||||
#include "webfuse/utils/msleep.hpp"
|
||||
#include <ctime>
|
||||
|
||||
namespace webfuse_test
|
||||
{
|
||||
|
||||
void msleep(long millis)
|
||||
{
|
||||
long const secs_per_msec = 1000;
|
||||
long const msecs_per_nsec = (1000 * 1000);
|
||||
|
||||
long const seconds = millis / secs_per_msec;
|
||||
long const nanos = (millis % secs_per_msec) * msecs_per_nsec;
|
||||
|
||||
struct timespec timeout = { seconds, nanos };
|
||||
while (0 != nanosleep(&timeout, &timeout));
|
||||
}
|
||||
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
#ifndef WF_TEST_MSLEEP_HPP
|
||||
#define WF_TEST_MSLEEP_HPP
|
||||
|
||||
namespace webfuse_test
|
||||
{
|
||||
|
||||
extern void msleep(long millis);
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user