-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Changes from 1 commit
9af59b4
6550535
c4e543c
dfcf9e9
cb23ea4
6a4b963
fd6a9c6
ec11938
bfe9884
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,17 +22,25 @@ | |
#define TEST_USLEEP_MIN (0) | ||
#define TEST_USLEEP_MAX (500) | ||
|
||
#define TEST_TIME (125250) | ||
|
||
int main(void) | ||
{ | ||
xtimer_sleep(3); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. put spaces around |
||
|
||
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; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,15 @@ def testfunc(child): | |
break | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This |
||
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: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||
|
||
|
||
|
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
http://www.wolframalpha.com/input/?i=500%2B499%2B498%2B+...+%2B+1
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.