|
| 1 | +# OTA Platform Abstraction Layer (PAL) Test |
| 2 | + |
| 3 | +## On this page: |
| 4 | +1. [Introduction](#1-introduction) |
| 5 | +2. [OTA PAL Test Cases](#2-ota-pal-test-cases) |
| 6 | +3. [Prerequisites For OTA PAL Test](#3-prerequisites-for-ota-pal-test) |
| 7 | +4. [Configure OTA PAL Test](#4-configure-ota-pal-test) |
| 8 | +5. [Running OTA PAL Test](#5-running-ota-pal-test) |
| 9 | + |
| 10 | +## 1. Introduction |
| 11 | + |
| 12 | +OTA PAL tests help to verify OTA PAL implementation. OTA PAL interface can be found [here](https://freertos.org/Documentation/api-ref/ota-for-aws-iot-embedded-sdk/docs/doxygen/output/html/ota_pal_interface.html). |
| 13 | + |
| 14 | +OTA PAL tests have the following required parameters that should be setup in `SetupOtaPalTestParam()` implementation: |
| 15 | +* pageSize: page size of flash. All test writes will be aligned to this page size. |
| 16 | + |
| 17 | +## 2. OTA PAL Test Cases |
| 18 | + |
| 19 | +The OTA PAL tests verify the implementation by running various test cases. |
| 20 | + |
| 21 | +|Test Case |Test Case Detail |Expected result | |
| 22 | +|--- |--- |--- | |
| 23 | +|otaPal_CloseFile_ValidSignature | Test otaPal_CloseFile with a valid signature and signature verification certificate | otaPal_CloseFile returns OtaPalSuccess | |
| 24 | +|otaPal_CloseFile_InvalidSignatureBlockWritten |Call otaPal_CloseFile with an invalid signature in the file context after writing a block of dummy data to the file | otaPal_CloseFile returns OtaPalSignatureCheckFailed | |
| 25 | +|otaPal_CloseFile_InvalidSignatureNoBlockWritten | Call otaPal_CloseFile with an invalid signature in the file context without writing to the file | otaPal_CloseFile returns OtaPalSignatureCheckFailed | |
| 26 | +|otaPal_CloseFile_NonexistingCodeSignerCertificate | Call otaPal_CloseFile with a signature verification certificate path does not exist in the system. | otaPal_CloseFile returns OtaPalBadSignerCert| |
| 27 | +|otaPal_CreateFileForRx_CreateAnyFile | Create a file with any name with otaPal_CreateFileForRx | otaPal_CreateFileForRx returns OtaPalSuccess| |
| 28 | +|otaPal_Abort_OpenFile |Abort on an open file | otaPal_Abort returns OtaPalSuccess | |
| 29 | +|otaPal_Abort_FileWithBlockWritten | Abort after writing a block to an open file | otaPal_Abort returns OtaPalSuccess | |
| 30 | +|otaPal_Abort_NullFileHandle |Call otaPal_Abort on a NULL file handle | otaPal_Abort returns OtaPalSuccess | |
| 31 | +|otaPal_Abort_NonExistentFile |Call otaPal_Abort on a non-existent file | otaPal_Abort returns OtaPalSuccess | |
| 32 | +|otaPal_WriteBlock_WriteSingleByte | Write one byte of data into created OTA file | otaPal_WriteBlock returns 1 | |
| 33 | +|otaPal_WriteBlock_WriteManyBlocks | Write multiple blocks of data into created OTA file |otaPal_WriteBlock returns number of bytes written | |
| 34 | +|otaPal_SetPlatformImageState_AcceptedStateWithoutClose | Set the platform state to accepted before closing the file | otaPal_SetPlatformImageState returns OtaPalCommitFailed | |
| 35 | +|otaPal_SetPlatformImageState_InvalidImageState | Set an invalid platform image state exceeding the range | otaPal_SetPlatformImageState returns OtaPalBadImageState| |
| 36 | +|otaPal_SetPlatformImageState_UnknownImageState | Set the image state to unknown | otaPal_SetPlatformImageState returns OtaPalBadImageState | |
| 37 | +|otaPal_GetPlatformImageState_InvalidImageStateFromFileCloseFailure | Set the platform image state to aborted | otaPal_SetPlatformImageState returns success | |
| 38 | + |
| 39 | + |
| 40 | +Assert may be used to check invalid parameters. In that case, you may need to replace |
| 41 | +the assert macro to return negative value in your implementation |
| 42 | +to ensure invalid parameter error can be catched by assert.<br><br> |
| 43 | +For example, if you are using FreeRTOS configASSERT macro to check invalid parameters, |
| 44 | +you can replace the macro with the following code: |
| 45 | +``` |
| 46 | +#define configASSERT( x ) if( !( x ) ) { return NEGATIVE_VALUE_TO_INDICATE_ERROR; } |
| 47 | +``` |
| 48 | + |
| 49 | +## 3. Prerequisites For OTA PAL Test |
| 50 | + |
| 51 | +The OTA PAL test assumes the tested platform already has the following components integrated. |
| 52 | + |
| 53 | +* **OTA PAL implementation** |
| 54 | + |
| 55 | +* **Unity test framework** |
| 56 | + The OTA PAL tests make use of the Unity test framework. Reference the [website](https://github.com/ThrowTheSwitch/Unity) for integration guide. |
| 57 | + |
| 58 | +## 4. Configure OTA PAL Test |
| 59 | +Please refer to top level [README](https://github.com/FreeRTOS/FreeRTOS-Libraries-Integration-Tests/blob/main/README.md) on high level project setup. |
| 60 | +This section covers OTA PAL test specific configuration. |
| 61 | + |
| 62 | +1. Implement the setup function, **SetupOtaPalParam**, for OTA PAL test to provide test parameters. The following are required test parameters: |
| 63 | + |
| 64 | +```C |
| 65 | +typedef struct OtaPalTestParam |
| 66 | +{ |
| 67 | + uint32_t pageSize; |
| 68 | +} OtaPalTestParam_t; |
| 69 | + |
| 70 | +void SetupOtaPalTestParam( OtaPalTestParam_t * pTestParam ); |
| 71 | +``` |
| 72 | +
|
| 73 | +
|
| 74 | +## 5. Running OTA PAL Test |
| 75 | +
|
| 76 | +Open test_execution_config.h and define `OTA_PAL_TEST_ENABLED` to 1. |
| 77 | +
|
| 78 | +In test_param_config.h, update the following options: |
| 79 | +
|
| 80 | +* OTA_PAL_TEST_CERT_TYPE: Select the certificate type used |
| 81 | +* OTA_PAL_CERTIFICATE_FILE: Path to on device certificate, if applicable. |
| 82 | +* OTA_PAL_FIRMWARE_FILE: Name of the firmware file, if applicable. |
| 83 | +* OTA_PAL_USE_FILE_SYSTEM: Set to 1 if the OTA PAL uses file system abtraction. |
| 84 | +
|
| 85 | +Build and flash the application using toolchain of your choice. When RunQualificationTest() is called, the OTA PAL tests will run. Test results are outputted to serial. |
0 commit comments