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

tests/xtimer_usleep_short: add expected runtime #9037

Closed
wants to merge 9 commits into from
8 changes: 8 additions & 0 deletions tests/xtimer_usleep_short/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,25 @@
#define TEST_USLEEP_MIN (0)
#define TEST_USLEEP_MAX (500)

#define TEST_TIME (125250)
Copy link
Contributor

Choose a reason for hiding this comment

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

How did you determine this value ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

@aabadie aabadie Apr 27, 2018

Choose a reason for hiding this comment

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

Then threre's direct relationship with TEST_USLEEP_MAX and TEST_USLEEP_MIN, so I think it's useless.

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 don't understand what you mean, but changed the value to be calculated.


int main(void)
{
xtimer_sleep(3);
Copy link
Contributor

Choose a reason for hiding this comment

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

This xtimer_sleep(3) break my tests when doing make flash test on some boards as the test could match the child.expect(u"This test will call xtimer_usleep for values from (\d+) down to (\d+)") line before make reset is done.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Any suggestions on how to fix this? Increase the sleep?

printf("This test will call xtimer_usleep for values from %d down to %d\n",
TEST_USLEEP_MAX, TEST_USLEEP_MIN);

uint32_t start, sleeping_time=0;
Copy link
Contributor

Choose a reason for hiding this comment

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

put spaces around = operator


for (int i = TEST_USLEEP_MAX; i >= TEST_USLEEP_MIN; i--) {
printf("going to sleep %d usecs...\n", i);
start = xtimer_now_usec();
xtimer_usleep(i);
sleeping_time += xtimer_now_usec() - start;
}

printf("Slept for %" PRIu32 " expected %" PRIu32"\n", sleeping_time, TEST_TIME);

puts("[SUCCESS]");

return 0;
Expand Down
9 changes: 9 additions & 0 deletions tests/xtimer_usleep_short/tests/01-run.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ def testfunc(child):
break
Copy link
Contributor

Choose a reason for hiding this comment

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

This break should be an exit(1), not print failed then success
It's a good time to fix it.

i = i - 1

child.expect(u"Slept for (\\d+) expected (\\d+)", timeout=3)
runtime = int(child.match.group(1))
expected = int(child.match.group(2))

if runtime < expected*0.9 or runtime > expected*1.1:
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be tested in the test application not by the pexpect script

print("xtimer slept to long")
print("[FAILED]")
return

child.expect(u"[SUCCESS]", timeout=3)


Expand Down