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 Temp Sensor test cases #1932

Merged
merged 4 commits into from
May 19, 2020

Conversation

osloapps-max
Copy link
Contributor

  • Added TEST_PROTECT sections
  • Removed AFQP_IotTsensorCalibrationNullInputFuzz as the test was not valid according the API description stating that this request will not return invalid status on NULL buffer.
  • Updated AFQP_IotTsensorCalibrationSuccess to test for status when passing in NULL buffer
  • Reworked AFQP_IotTsensorTriggerMinThreshold and AFQP_IotTsensorTriggerMaxThreshold.
  • Updated expected return values based on what is defined by the API header file

Description

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.

Copy link
Contributor

@gkwicker gkwicker left a comment

Choose a reason for hiding this comment

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

See comments

@@ -79,6 +81,16 @@ TEST_TEAR_DOWN( TEST_IOT_TSENSOR )
*/
TEST_GROUP_RUNNER( TEST_IOT_TSENSOR )
{
if( xtestIotTsensorMinSemaphore == NULL )
{
xtestIotTsensorMinSemaphore = xSemaphoreCreateBinary();
Copy link
Contributor

Choose a reason for hiding this comment

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

In general, you should always check return codes here since xSemaphoreCreateBinary() can return NULL.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It makes sense. I moved the block out to the test setup phase and added asserts to check against NULL return.

@tgsong tgsong requested review from aggarg and removed request for aggarg April 30, 2020 00:09
@tgsong tgsong requested a review from qiutongs May 4, 2020 18:22
qiutongs
qiutongs previously approved these changes May 8, 2020
vjjunnut
vjjunnut previously approved these changes May 11, 2020
@qiutongs
Copy link
Contributor

/bot run checks

Max Wennerfeldt added 3 commits May 14, 2020 16:11
…s and reworked AFQP_IotTsensorTriggerMinThreshold and AFQP_IotTsensorTriggerMaxThreshold. Updated expected return values based on what is defined by the API header file
@qiutongs qiutongs dismissed stale reviews from vjjunnut and themself via acaae4f May 14, 2020 23:11
@qiutongs qiutongs force-pushed the fix/common-io-tsensor-test branch from a55e130 to acaae4f Compare May 14, 2020 23:11
@qiutongs
Copy link
Contributor

/bot run checks

1 similar comment
@qiutongs
Copy link
Contributor

/bot run checks

qiutongs
qiutongs previously approved these changes May 15, 2020
cobusve
cobusve previously approved these changes May 18, 2020
@@ -61,6 +63,17 @@ TEST_GROUP( TEST_IOT_TSENSOR );
*/
TEST_SETUP( TEST_IOT_TSENSOR )
{
if( xtestIotTsensorMinSemaphore == NULL )
Copy link
Member

Choose a reason for hiding this comment

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

It think the test should check this and assert and fail if it already exists. What will happen if a prior test hands you a locked semaphore?

Copy link
Member

Choose a reason for hiding this comment

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

There are a couple of these further down also, this applies to all of them.

Copy link
Contributor

Choose a reason for hiding this comment

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

I fixed them.

@qiutongs qiutongs requested a review from gkwicker May 18, 2020 21:39
@qiutongs qiutongs dismissed stale reviews from cobusve and themself via d1e8b10 May 18, 2020 22:07
@qiutongs
Copy link
Contributor

/bot run checks

Copy link
Contributor

@gkwicker gkwicker left a comment

Choose a reason for hiding this comment

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

No changes needed, just see comments and think about them for future versions.

@@ -39,6 +39,7 @@
#include "FreeRTOS.h"
#include "semphr.h"

#define testIotTSENSOR_DELAY pdMS_TO_TICKS( 5000 )
Copy link
Contributor

Choose a reason for hiding this comment

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

In general when a #define macro or variable has units, add the units to the end of the name. This helps reviewers and maintainers spot misuse. Here we would prefer the name testIoTSENSOR_DELAY_TICKS.

lRetVal = iot_tsensor_ioctl( xTsensorHandle, eTsensorSetMinThreshold, &setLowThreshold );
/* Set min threshold to be 5 degrees C higher than current temperature.
* Expect it to fire immediately */
setLowThreshold += 5000;
Copy link
Contributor

Choose a reason for hiding this comment

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

These values are in millidegrees Celsius, consider a naming convention so that maintainers/readers can ensure the values are used & converted properly.

@qiutongs qiutongs merged commit 7eac471 into aws:master May 19, 2020
alfred2g pushed a commit to alfred2g/amazon-freertos that referenced this pull request May 21, 2020
* Refactored and updated tsensor test cases. Added TEST_PROTECT sections and reworked AFQP_IotTsensorTriggerMinThreshold and AFQP_IotTsensorTriggerMaxThreshold. Updated expected return values based on what is defined by the API header file

* Updated AFQP_IotTsensorCalibrationSuccess to test NULL buffer

* Moved semaphore creation into setup phase and added test asserts to check for NULL return

* Create/delete semaphore for each test case

Co-authored-by: Max Wennerfeldt <[email protected]>
Co-authored-by: qiutongs <songqt01@gmail,com>
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.

5 participants