Skip to content

mtest: Add watchdog test - #3719

Open
wiktorkwiatkowski wants to merge 2 commits into
apache:masterfrom
wiktorkwiatkowski:watchdog_mtest
Open

mtest: Add watchdog test#3719
wiktorkwiatkowski wants to merge 2 commits into
apache:masterfrom
wiktorkwiatkowski:watchdog_mtest

Conversation

@wiktorkwiatkowski

Copy link
Copy Markdown
Contributor

No description provided.

@sjanc sjanc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

just minor comment, otherwise looks ok

MTEST_RUN_INIT(watchdog_test);
switch (reset_count) {
case 0:
watchdog_test_case_1();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

while those functions should never return I'd still add break for sake of coding style

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

if (now - start >= 2 * (MYNEWT_VAL(WATCHDOG_INTERVAL) * 1000)) {
break;
}

watchdog_test_case_1(); actually does return when the time counter is at least 2x WATCHDOG_INTERVAL.
Adding a break statement would break the test flow, and watchdog_test_case_2(); would never execute.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I can change the switch statement to something like this:

if (reset_count == 0) { 
        watchdog_test_case_1();
        watchdog_test_case_2();
    } else if (reset_count == 1) {
        watchdog_test_case_2();
    } else {
        boot_status = 0;
        reset_count = 0;
    } 

It will work the same but will get rid of the fallthrough in the switch statement.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

switch is fine, but comment if fall-through is on purpose

Define MTEST_START_DELAY [s] to pause before test cases begin.
No delay by default.
This test adds two main test cases. The first case verifies whether
periodically calling hal_watchdog_tickle prevents the watchdog from
firing. The second case verifies that starving the watchdog correctly
triggers a system reset.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants