Skip to content

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

Merged

Conversation

mprse
Copy link
Contributor

@mprse mprse commented Oct 2, 2017

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

@mprse mprse force-pushed the feature-hal-spec-ticker_tests branch from 44f1213 to 3206c2b Compare October 2, 2017 07:33
@mprse mprse force-pushed the feature-hal-spec-ticker_tests branch from 3206c2b to 8de3061 Compare October 2, 2017 08:41
@0xc0170
Copy link
Contributor

0xc0170 commented Oct 2, 2017

cc @c1728p9 @bulislaw @pan-

@mprse mprse force-pushed the feature-hal-spec-ticker_tests branch from 8de3061 to 59eca6c Compare October 2, 2017 08:58
@0xc0170
Copy link
Contributor

0xc0170 commented Oct 2, 2017

I restarted Jenkins CI as it is now fixed

@mprse Please rebase (circle-ci should be then updated)

@mprse
Copy link
Contributor Author

mprse commented Oct 9, 2017

@maciejbocianski @fkjagodzinski - ready for review.

Copy link
Member

@fkjagodzinski fkjagodzinski left a 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
Copy link
Member

Choose a reason for hiding this comment

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

Typo: rollsovers.

Copy link
Contributor Author

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. */
Copy link
Member

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.

"""
def _ticker_clk_freq(self, key, value, timestamp):
self.ticker_clk_freq = int(value)
self.freq_delta_10_prc = self.ticker_clk_freq / 10
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed as suggested.

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)
Copy link
Member

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.

Copy link
Contributor Author

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);
}
Copy link
Member

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");

Copy link
Contributor Author

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
Copy link
Member

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.

Copy link
Contributor Author

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)
Copy link
Member

Choose a reason for hiding this comment

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

Typo: tikck.

Copy link
Contributor Author

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--) {
Copy link
Member

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.

Copy link
Contributor Author

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);
Copy link
Member

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).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed as suggested.

Copy link
Member

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);
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Contributor

@theotherjimmy theotherjimmy left a comment

Choose a reason for hiding this comment

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

Style nits

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
Copy link
Contributor

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 (

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed as suggested.

@mprse mprse force-pushed the feature-hal-spec-ticker_tests branch from 51528a1 to 1b6c373 Compare October 11, 2017 07:26
Copy link
Contributor

@0xc0170 0xc0170 left a 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);
Copy link
Contributor

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

Copy link
Contributor Author

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);
Copy link
Contributor

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

Copy link
Contributor Author

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. */
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed redundant comments.

@0xc0170
Copy link
Contributor

0xc0170 commented Oct 11, 2017

cc @bulislaw @pan- @c1728p9

@mprse mprse force-pushed the feature-hal-spec-ticker_tests branch 2 times, most recently from f5c1e6c to 7a9846b Compare October 11, 2017 07:54
@mprse
Copy link
Contributor Author

mprse commented Oct 11, 2017

@0xc0170 Test header files with specification are provided here e04ab9b.

@mbed-ci
Copy link

mbed-ci commented Oct 11, 2017

Build : FAILURE

Build number : 108
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/5233/

@0xc0170
Copy link
Contributor

0xc0170 commented Oct 11, 2017

/morph build

@0xc0170
Copy link
Contributor

0xc0170 commented Oct 11, 2017

@mprse Please see the failures, they are related

@mbed-ci
Copy link

mbed-ci commented Oct 11, 2017

Build : FAILURE

Build number : 116
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/5233/

@mprse
Copy link
Contributor Author

mprse commented Oct 12, 2017

Build : FAILURE

Build number : 116
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/5233/

Error: #20: identifier "ticker_info_t" is undefined
Error: #20: identifier "lp_ticker_get_info" is undefined

To build this test successfully features provided in related PRs must be merged.

@mprse mprse force-pushed the feature-hal-spec-ticker_tests branch 2 times, most recently from 508adde to c4fd6e0 Compare October 17, 2017 11:09
@mbed-ci
Copy link

mbed-ci commented Oct 18, 2017

Build : FAILURE

Build number : 234
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/5233/

…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).
@mprse mprse force-pushed the feature-hal-spec-ticker_tests branch from 64e7123 to 4728677 Compare January 15, 2018 08:18
@0xc0170
Copy link
Contributor

0xc0170 commented Jan 15, 2018

/morph build

@mbed-ci
Copy link

mbed-ci commented Jan 15, 2018

Build : SUCCESS

Build number : 864
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/5233/

Triggering tests

/morph test
/morph uvisor-test
/morph export-build

@mbed-ci
Copy link

mbed-ci commented Jan 15, 2018

@mbed-ci
Copy link

mbed-ci commented Jan 15, 2018

@0xc0170
Copy link
Contributor

0xc0170 commented Jan 15, 2018

LGTM, just one 7ec02a0 commit does not look needed (changing SDK driver)

Update: That commit is fine, as it changes the implementation for mbed 👍

@0xc0170
Copy link
Contributor

0xc0170 commented Jan 15, 2018

@jeromecoutant @jamesbeyond Can you please rereview the latest update? If all comments were addressed

Copy link
Contributor

@jamesbeyond jamesbeyond left a 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

@mprse
Copy link
Contributor Author

mprse commented Jan 17, 2018

@0xc0170
This one is good to go. @jeromecoutant requests will be proceed in the separate task.

@0xc0170 0xc0170 merged commit 7414313 into ARMmbed:feature-hal-spec-ticker Jan 17, 2018
mprse added a commit to mprse/mbed-os that referenced this pull request Jan 19, 2018
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)
0xc0170 pushed a commit that referenced this pull request Jan 23, 2018
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)
cmonr pushed a commit that referenced this pull request Feb 13, 2018
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)
cmonr pushed a commit that referenced this pull request Feb 21, 2018
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)
mprse added a commit to mprse/mbed-os that referenced this pull request Feb 27, 2018
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);
Copy link
Collaborator

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

Copy link
Contributor Author

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.

bulislaw pushed a commit to bulislaw/mbed-os that referenced this pull request Mar 24, 2018
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)
bulislaw pushed a commit that referenced this pull request Mar 27, 2018
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)
bulislaw pushed a commit that referenced this pull request Apr 19, 2018
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)
bulislaw pushed a commit to bulislaw/mbed-os that referenced this pull request May 15, 2018
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)
bulislaw pushed a commit that referenced this pull request May 24, 2018
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)
bulislaw pushed a commit to bulislaw/mbed-os that referenced this pull request May 25, 2018
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.