Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use usleep instead of sleep/nanosleep on Mbed OS. #8393

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions src/messaging/tests/TestReliableMessageProtocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,14 +183,7 @@ class MockSessionEstablishmentDelegate : public ExchangeDelegate

void test_os_sleep_ms(uint64_t millisecs)
{
struct timespec sleep_time;
uint64_t s = millisecs / 1000;

millisecs -= s * 1000;
sleep_time.tv_sec = static_cast<time_t>(s);
sleep_time.tv_nsec = static_cast<long>(millisecs * 1000000);

nanosleep(&sleep_time, nullptr);
usleep(static_cast<useconds_t>(millisecs * 1000));
}

void CheckAddClearRetrans(nlTestSuite * inSuite, void * inContext)
Expand Down
2 changes: 1 addition & 1 deletion src/platform/tests/TestPlatformMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ static bool sleepRan;

static void SleepSome(intptr_t)
{
sleep(1);
usleep(static_cast<useconds_t>(1 * 1000 * 1000));
sleepRan = true;
}

Expand Down
22 changes: 4 additions & 18 deletions src/platform/tests/TestPlatformTime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,28 +70,14 @@ static const struct time_test_vector test_vector_system_time_us[] = {

#include <unistd.h>

void test_os_sleep_ms(uint64_t millisecs)
void test_os_sleep_us(uint64_t microsecs)
{
struct timespec sleep_time;
int s = millisecs / 1000;

millisecs -= s * 1000;
sleep_time.tv_sec = s;
sleep_time.tv_nsec = millisecs * 1000000;

nanosleep(&sleep_time, nullptr);
usleep(static_cast<useconds_t>(microsecs));
}

void test_os_sleep_us(uint64_t microsecs)
void test_os_sleep_ms(uint64_t millisecs)
{
struct timespec sleep_time;
int s = microsecs / 1000000;

microsecs -= s * 1000000;
sleep_time.tv_sec = s;
sleep_time.tv_nsec = microsecs * 1000;

nanosleep(&sleep_time, nullptr);
test_os_sleep_us(millisecs * 1000);
}

// =================================
Expand Down
9 changes: 1 addition & 8 deletions src/protocols/secure_channel/tests/TestPASESession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,7 @@ using TestContext = chip::Test::MessagingContext;

static void test_os_sleep_ms(uint64_t millisecs)
{
struct timespec sleep_time;
uint64_t s = millisecs / 1000;

millisecs -= s * 1000;
sleep_time.tv_sec = static_cast<time_t>(s);
sleep_time.tv_nsec = static_cast<long>(millisecs * 1000000);

nanosleep(&sleep_time, nullptr);
usleep(static_cast<useconds_t>(millisecs * 1000));
}

class PASETestLoopbackTransport : public Test::LoopbackTransport
Expand Down