-
Notifications
You must be signed in to change notification settings - Fork 3k
Ticker: add fire interrupt now function #4644
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
Merged
theotherjimmy
merged 3 commits into
ARMmbed:master
from
0xc0170:fix_ticker_delta_negative
Jul 17, 2017
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev
Previous commit
ticker test: add test for set interrupt with timestamp in the past
2 test cases added, one for event in the past, one for event in future but very close to the current time, thus once is set, it is already in the past, and we fire interrupt immediately.
- Loading branch information
commit 56cb1582bef242d8a5c47fa67ef04c86de858fb3
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1986,6 +1986,58 @@ static void test_irq_handler_insert_non_immediate_in_irq() | |
TEST_ASSERT_EQUAL(0, interface_stub.disable_interrupt_call); | ||
} | ||
|
||
static uint32_t ticker_interface_stub_read_interrupt_time() | ||
{ | ||
++interface_stub.read_call; | ||
// only if set interrupt call, to test the condition afterwards | ||
if (interface_stub.set_interrupt_call) { | ||
return interface_stub.interrupt_timestamp; | ||
} else { | ||
return interface_stub.timestamp; | ||
} | ||
} | ||
|
||
/** | ||
* Test to insert an event that is already in the past, the fire_interrupt should | ||
* be invoked, instead of set_interrupt | ||
*/ | ||
static void test_set_interrupt_past_time() | ||
{ | ||
interface_stub.set_interrupt_call = 0; | ||
interface_stub.fire_interrupt_call = 0; | ||
interface_stub.timestamp = 0xFF; | ||
|
||
|
||
// This tests fire now functinality when next_event_timestamp <= present | ||
ticker_event_t event = { 0 }; | ||
const timestamp_t event_timestamp = interface_stub.timestamp; | ||
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. Could you add another test similar to this one where 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. Done, added |
||
const uint32_t id_last_event = 0xDEADDEAF; | ||
|
||
ticker_insert_event(&ticker_stub, &event, event_timestamp, id_last_event); | ||
TEST_ASSERT_EQUAL(0, interface_stub.set_interrupt_call); | ||
TEST_ASSERT_EQUAL(1, interface_stub.fire_interrupt_call); | ||
} | ||
/** | ||
* Test to insert an event that is being delayed, set_interrupt is set | ||
* but then event is already in the past, thus fire_interrupt should be invoked right-away | ||
*/ | ||
static void test_set_interrupt_past_time_with_delay() | ||
{ | ||
interface_stub.set_interrupt_call = 0; | ||
interface_stub.fire_interrupt_call = 0; | ||
interface_stub.timestamp = 0xFF; | ||
|
||
// This tests fire now functionality when present time >= new_match_time | ||
interface_stub.interface.read = ticker_interface_stub_read_interrupt_time; | ||
ticker_event_t event = { 0 }; | ||
const timestamp_t event_timestamp = interface_stub.timestamp + 5; | ||
const uint32_t id_last_event = 0xDEADDEAF; | ||
|
||
ticker_insert_event(&ticker_stub, &event, event_timestamp, id_last_event); | ||
TEST_ASSERT_EQUAL(1, interface_stub.set_interrupt_call); | ||
TEST_ASSERT_EQUAL(1, interface_stub.fire_interrupt_call); | ||
} | ||
|
||
static const case_t cases[] = { | ||
MAKE_TEST_CASE("ticker initialization", test_ticker_initialization), | ||
MAKE_TEST_CASE( | ||
|
@@ -2070,6 +2122,14 @@ static const case_t cases[] = { | |
MAKE_TEST_CASE( | ||
"test_irq_handler_insert_non_immediate_in_irq", | ||
test_irq_handler_insert_non_immediate_in_irq | ||
), | ||
MAKE_TEST_CASE( | ||
"test_set_interrupt_past_time", | ||
test_set_interrupt_past_time | ||
), | ||
MAKE_TEST_CASE( | ||
"test_set_interrupt_past_time_with_delay", | ||
test_set_interrupt_past_time_with_delay | ||
) | ||
}; | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Could you comment what the test do like it is done for other test. The documentation (and test) is supposed to act as a specification of the code behavior .