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

Iox #32 implement posix timer and introduced timing test #69

Conversation

elfenpiff
Copy link
Contributor

No description provided.

…iming tests; tested timing test construct in TimerStopWatch tests

Signed-off-by: Christian Eltzschig <[email protected]>
…xpensive, therefore the timeout is increased

Signed-off-by: Christian Eltzschig <[email protected]>
…ch-timer' of github.com:elfenpiff/iceoryx into iox-eclipse-iceoryx#32-implement-posix-timer-via-dispatch-timer
Signed-off-by: Christian Eltzschig <[email protected]>
…ch-timer' of github.com:elfenpiff/iceoryx into iox-eclipse-iceoryx#32-implement-posix-timer-via-dispatch-timer
Signed-off-by: Christian Eltzschig <[email protected]>
Signed-off-by: Christian Eltzschig <[email protected]>
…ch-timer' of github.com:elfenpiff/iceoryx into iox-eclipse-iceoryx#32-implement-posix-timer-via-dispatch-timer
…n on heavy system load

Signed-off-by: Christian Eltzschig <[email protected]>
Signed-off-by: Christian Eltzschig <[email protected]>
Signed-off-by: Christian Eltzschig <[email protected]>
@mossmaurice mossmaurice linked an issue Mar 24, 2020 that may be closed by this pull request
@mossmaurice mossmaurice added the enhancement New feature label Mar 24, 2020
#include <functional>
#include <string>

/// @brief This headers provides TIMING_TEST unit test infrastructure. The idea
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name "TIMING_TEST" is a litle bit misleading here because there are no timing constrints checked here. What is here done is to repeat the test until the condition is met or to fail. I know the background why we are doing that but then i would rename it to something like "REPEAT_TEST". That name is more meaningful. Iknow that we have different timing constraints on different platforms like arm or x64. But this should be tested different.

Maybe we can use the timeout mechanism of the semaphore to offer a real timing test which checks for a certain timing constraint?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should stick to the name TIMING_TEST since with this name we communicate to fellow developers that we are testing a construct with timing constraints. Our approach is to test it repeatedly but maybe later we have an even better approach and then the name should be the same and the rest should just change under the hood.

iceoryx_posh/CMakeLists.txt Outdated Show resolved Hide resolved
iceoryx_posh/test/CMakeLists.txt Outdated Show resolved Hide resolved
iceoryx_utils/CMakeLists.txt Outdated Show resolved Hide resolved
dkroenke
dkroenke previously approved these changes May 27, 2020
@elfenpiff elfenpiff requested a review from elBoberido May 27, 2020 10:43
iceoryx_posh/test/CMakeLists.txt Show resolved Hide resolved
iceoryx_utils/source/posix_wrapper/timer.cpp Show resolved Hide resolved
Comment on lines 310 to 311
// This test has to be repeated more often since we are spawning a lot
// of threads in here
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this meant as an @todo?

@elfenpiff elfenpiff requested a review from mossmaurice May 27, 2020 13:33
mossmaurice
mossmaurice previously approved these changes May 27, 2020

static void stopTimerThread(timer_t timerid)
{
timerid->keepRunning.store(false, std::memory_order_relaxed);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this could be reordered after the notify_one call

startTime = timerid->parameter.startTime;
}
curr_value->it_value.tv_sec = curr_value->it_interval.tv_sec - (currentTime.tv_sec - startTime.tv_sec);
curr_value->it_value.tv_nsec = curr_value->it_interval.tv_nsec - (currentTime.tv_nsec - startTime.tv_nsec);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the calculation could become negative, are positive seconds and negative nanoseconds allowed?

{
timer->parameter.mutex.lock();
bool doCallCallback =
!timer->parameter.runOnce || timer->parameter.runOnce && !timer->parameter.wasCallbackCalled;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add braces to make the intention clear


auto end = osTimer.now();
public:
iox::units::Duration timeout{4_ms};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you make it const and uppercase to indicate that it's a constant

osTimer.stop();
TEST_F(TimerStopWatch_test, ResetWithDurationIsExpired)
{
Timer sut(1_ms);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

magic number

TEST_F(TimerStopWatch_test, ResetWithDurationIsExpired)
{
Timer sut(1_ms);
std::this_thread::sleep_for(std::chrono::milliseconds(2));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if no magic number was used, this could be 2 times the constant

elfenpiff added 2 commits May 27, 2020 16:49
Signed-off-by: Christian Eltzschig <[email protected]>
…ence is positive solved

Signed-off-by: Christian Eltzschig <[email protected]>
@elfenpiff elfenpiff merged commit 8a6943f into eclipse-iceoryx:master May 28, 2020
@elfenpiff elfenpiff deleted the iox-#32-implement-posix-timer-via-dispatch-timer branch May 28, 2020 07:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

macOS support
5 participants