Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

common-io: Refactoring and updates to RTC test cases and top-level header file #1977

Merged
merged 2 commits into from
May 19, 2020

Conversation

osloapps-max
Copy link
Contributor

Description

  • Added TEST_PROTECT sections to test cases
  • Removed global handle as the usage of the RTC is always open -> close which means the handle would be closed after the first test had run (often without setting it to NULL again).
  • Added "Week day" to the date/time structure for each test so that the whole structure is in a known state when performing the tests.
  • Changed semaphore timeouts to not be "eternal".
  • Added global variable that can be used to configure which RTC instance to open (test was hard-coded to 0)
  • Updated/added expected return value to the top-level API header file based on how the test cases was setup (please feedback on this as the test and API description was not aligned).

Checklist:

  • I have tested my changes. No regression in existing tests.
  • My code is Linted.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

qiutongs
qiutongs previously approved these changes May 8, 2020
xSetDateTime.usYear = testIotRTC_DEFAULT_CURRENT_YEAR;
xSetDateTime.ucMonth = testIotRTC_DEFAULT_CURRENT_MONTH;
xSetDateTime.ucDay = testIotRTC_DEFAULT_CURRENT_DAY;
xSetDateTime.ucHour = testIotRTC_DEFAULT_CURRENT_HOUR;
xSetDateTime.ucMinute = testIotRTC_DEFAULT_CURRENT_MINUTE;
xSetDateTime.ucSecond = testIotRTC_DEFAULT_CURRENT_SECOND;
xSetDateTime.ucSecond = testIotRTC_DEFAULT_CURRENT_SECOND + testIotRTC_DEFAULT_ALARM_TIME;

Choose a reason for hiding this comment

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

Why is the DEFAULT_ALARM_TIME added here to the default time being set? #722 may not return error if its the current second.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reason is due to the fact that testIotRTC_DEFAULT_CURRENT_SECOND is zero. The original setup would subtract 5 from 0 in a uint8 causing a underflow. That said, it could be a good idea to bump it so that xSetDateTime.ucSecond > testIotRTC_DEFAULT_ALARM_TIME.

You agree with bumping it to say 2 * testIotRTC_DEFAULT_ALARM_TIME? Alternatively, set testIotRTC_DEFAULT_CURRENT_SECOND > testIotRTC_DEFAULT_ALARM_TIME.

Choose a reason for hiding this comment

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

Yes. Didnt realize that. I agree to either of the approach

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

vjjunnut
vjjunnut previously approved these changes May 13, 2020
@qiutongs
Copy link
Contributor

/bot run checks

@qiutongs
Copy link
Contributor

/bot run checks

Max Wennerfeldt added 2 commits May 14, 2020 14:02
…on how the test was setup. Refactored tests to use TEST_PROTECT sections, init all values of the date/time struct and not having 'eternal block' on semaphores
…RtcSetAlarmInvalid test-case as it needs to setup alarm ni the past.
@qiutongs qiutongs force-pushed the fix/common-io-rtc-test branch from 571f87a to d4bfe4f Compare May 14, 2020 21:02
@qiutongs
Copy link
Contributor

/bot run checks

1 similar comment
@qiutongs
Copy link
Contributor

/bot run checks

@qiutongs qiutongs merged commit a34c8f2 into aws:master May 19, 2020
alfred2g pushed a commit to alfred2g/amazon-freertos that referenced this pull request May 21, 2020
…ader file (aws#1977)

* Updated iot_rtc.h documentation to cover expected return value based on how the test was setup. Refactored tests to use TEST_PROTECT sections, init all values of the date/time struct and not having 'eternal block' on semaphores

* Changed default seconds value from 0 to 10 to better fit the AFQP_IotRtcSetAlarmInvalid test-case as it needs to setup alarm ni the past.

Co-authored-by: Max Wennerfeldt <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants