-
Notifications
You must be signed in to change notification settings - Fork 3k
Add tests for ticker HAL API. #5233
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
Add tests for ticker HAL API. #5233
Conversation
44f1213
to
3206c2b
Compare
3206c2b
to
8de3061
Compare
8de3061
to
59eca6c
Compare
I restarted Jenkins CI as it is now fixed @mprse Please rebase (circle-ci should be then updated) |
@maciejbocianski @fkjagodzinski - ready for review. |
59eca6c
to
51528a1
Compare
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.
Minor fixes needed.
|
||
#define TICKER_OVERFLOW_DELTA 50 | ||
#if DEVICE_LOWPOWERTIMER | ||
#define TICKER_OVERFLOW_DELTA 0 // this will allow to detect that ticker counter rollsovers to 0 |
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.
Typo: rollsovers.
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.
Fixed.
{ | ||
const ticker_info_t* p_ticker_info = lp_ticker_get_info(); | ||
|
||
/* Check conditions. */ |
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.
Comments like this one are unnecessary. It is perfectly clear what the code is doing.
TESTS/host_tests/ticker_timing.py
Outdated
""" | ||
def _ticker_clk_freq(self, key, value, timestamp): | ||
self.ticker_clk_freq = int(value) | ||
self.freq_delta_10_prc = self.ticker_clk_freq / 10 |
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.
Use floor division operator //
to remove ambiguity if run on Python3. Alternatively use int(self.ticker_clk_freq / 10)
for better readability.
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.
Fixed as suggested.
TESTS/host_tests/ticker_timing.py
Outdated
self.ticker_clk_freq = int(value) | ||
self.freq_delta_10_prc = self.ticker_clk_freq / 10 | ||
self.send_kv("start", 0) | ||
time.sleep(DELAY_10S) |
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.
Since Python's time.sleep()
is not very accurate I suggest measuring the actual delay with time.clock()
i.e.
t1 = time.clock()
time.sleep(DELAY)
t2 = time.clock()
actual_host_delay = t2 - t1 # float
and using this measurement in further calculations.
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.
Fixed as suggested.
/* Indicate failure if interrupt has fired earlier. */ | ||
if (intFlag != 0) { | ||
TEST_ASSERT(0); | ||
} |
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.
Increase verbosity:
TEST_ASSERT_EQUAL_INT_MESSAGE(0, intFlag, "Interrupt fired too early");
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.
Fixed as suggested.
#if DEVICE_LOWPOWERTIMER | ||
#define TICKER_OVERFLOW_DELTA 0 // this will allow to detect that ticker counter rollsovers to 0 | ||
#endif | ||
#define TICKER_EXAMPLE_VALUE 100 |
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.
This name does not say much about the use of this value. Rename or add a comment.
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.
Modified variable name.
* | ||
* NOTE: | ||
* high freq ticker: 250 KHz (1 tick per 4 us) - 8 Mhz (1 tick per 1/8 us) | ||
* low power ticker: 8 KHz (1 tikck per 125 us) - 64 KHz (1 tick per ~15.6 us) |
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.
Typo: tikck.
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.
Fixed.
/* ---- Test ticker_clear_interrupt function. ---- */ | ||
timer.reset(); | ||
timer.start(); | ||
while (counter--) { |
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 guess you forgot to reset the counter to NUM_OF_CALLS
.
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.
Fixed.
greentea_parse_kv(_key, _value, sizeof(_key), sizeof(_value)); | ||
|
||
/* Indicate test status. */ | ||
TEST_ASSERT_MESSAGE("passed", _key); |
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.
This always evaluates to true. Use TEST_ASSERT_EQUAL_STRING(expected, actual)
.
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.
Fixed as suggested.
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 suppose you forgot to push that commit. ;)
const uint32_t tick_count_stop = intf->read(); | ||
|
||
/* Send number of counted ticks between start and stop to the host. */ | ||
greentea_send_kv("total_tick_count", tick_count_stop - tick_count_start); |
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.
The assumption that ticker doesn't overflow during test should be documented.
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.
Added comment with missing assumption.
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.
Style nits
TESTS/host_tests/ticker_timing.py
Outdated
self.total_tick_count = int(value) | ||
self.counted_freq = self.total_tick_count / DELAY_10S | ||
|
||
if(self.ticker_clk_freq > (self.counted_freq + self.freq_delta_10_prc) or |
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.
Please add a space after if
and before (
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.
Fixed as suggested.
51528a1
to
1b6c373
Compare
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.
Should this new test units have header file with documentation?
#endif | ||
|
||
utest::v1::status_t ticker_case_teardown_handler_t(const Case *const source, const size_t passed, const size_t failed, const failure_t reason) { | ||
return greentea_case_teardown_handler(source, passed, failed, reason); |
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.
starting {
new line in these test code files
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.
Fixed style.
greentea_parse_kv(_key, _value, sizeof(_key), sizeof(_value)); | ||
|
||
/* Indicate test status. */ | ||
TEST_ASSERT_EQUAL_STRING("passed", _key); |
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.
Some comments are valuable , but line 66 is redundant for instance or line 56
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.
Removed redundant comments.
} | ||
timer.stop(); | ||
|
||
/* Check result. */ |
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.
redundant, please review the tests and possibly reduce comments like this
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.
Removed redundant comments.
f5c1e6c
to
7a9846b
Compare
Build : FAILUREBuild number : 108 |
/morph build |
@mprse Please see the failures, they are related |
Build : FAILUREBuild number : 116 |
To build this test successfully features provided in related PRs must be merged. |
508adde
to
c4fd6e0
Compare
Build : FAILUREBuild number : 234 |
…pecific drivers. Since target specific ticker drivers are not ready also features which uses ticker in upper layers may not work correctly and tests for these features. We need to disable also failing higher level ticker related tests (by adding check if DEVICE_USTICKER symbol is available and raise #error [NOT_SUPPORTED] if not).
64e7123
to
4728677
Compare
/morph build |
Build : SUCCESSBuild number : 864 Triggering tests/morph test |
Exporter Build : SUCCESSBuild number : 535 |
Test : SUCCESSBuild number : 710 |
LGTM, just one 7ec02a0 commit does not look needed (changing SDK driver) Update: That commit is fine, as it changes the implementation for mbed 👍 |
@jeromecoutant @jamesbeyond Can you please rereview the latest update? If all comments were addressed |
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.
all my last comments were addressed
@0xc0170 |
Current version: The function ticker_init resets the internal count and disables the ticker interrupt. Proposed version: The function ticker_init allows the ticker to keep counting and disables the ticker interrupt. This is a result of the following discussion: ARMmbed#5233 (review)
Current version: The function ticker_init resets the internal count and disables the ticker interrupt. Proposed version: The function ticker_init allows the ticker to keep counting and disables the ticker interrupt. This is a result of the following discussion: #5233 (review)
Current version: The function ticker_init resets the internal count and disables the ticker interrupt. Proposed version: The function ticker_init allows the ticker to keep counting and disables the ticker interrupt. This is a result of the following discussion: #5233 (review)
Current version: The function ticker_init resets the internal count and disables the ticker interrupt. Proposed version: The function ticker_init allows the ticker to keep counting and disables the ticker interrupt. This is a result of the following discussion: #5233 (review)
Current version: The function ticker_init resets the internal count and disables the ticker interrupt. Proposed version: The function ticker_init allows the ticker to keep counting and disables the ticker interrupt. This is a result of the following discussion: ARMmbed#5233 (review)
lp_ticker_init(); | ||
|
||
/* Wait for green tea UART transmission before entering deep-sleep mode. */ | ||
wait_cycles(40000); |
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.
Hi
Back on this new code: it seems that this 40000 value is not enough for STM32F401 for ex.
Why don't you use a simple wait(1) ?
Thx
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.
Hi,
What value would be enough for STM32F401? I'm not using wait()
since it uses ticker
mechanism which is tested here. Also original handler is replaced with our test handler.
Current version: The function ticker_init resets the internal count and disables the ticker interrupt. Proposed version: The function ticker_init allows the ticker to keep counting and disables the ticker interrupt. This is a result of the following discussion: ARMmbed#5233 (review)
Current version: The function ticker_init resets the internal count and disables the ticker interrupt. Proposed version: The function ticker_init allows the ticker to keep counting and disables the ticker interrupt. This is a result of the following discussion: #5233 (review)
Current version: The function ticker_init resets the internal count and disables the ticker interrupt. Proposed version: The function ticker_init allows the ticker to keep counting and disables the ticker interrupt. This is a result of the following discussion: #5233 (review)
Current version: The function ticker_init resets the internal count and disables the ticker interrupt. Proposed version: The function ticker_init allows the ticker to keep counting and disables the ticker interrupt. This is a result of the following discussion: ARMmbed#5233 (review)
Current version: The function ticker_init resets the internal count and disables the ticker interrupt. Proposed version: The function ticker_init allows the ticker to keep counting and disables the ticker interrupt. This is a result of the following discussion: #5233 (review)
Current version: The function ticker_init resets the internal count and disables the ticker interrupt. Proposed version: The function ticker_init allows the ticker to keep counting and disables the ticker interrupt. This is a result of the following discussion: ARMmbed#5233 (review)
Description
This PR contains ticker HAL API tests for high frequency ticker and low power ticker.
Test were created based on documentation provided documentation PR #5164 (e04ab9b)
Status
READY
Migrations
To run these tests the following features are required:
Related PRs
ARMmbed:feature-hal-spec-ticker | #5164
ARMmbed:feature-hal-spec-ticker | #5234