Skip to content

Commit

Permalink
Add OTA Job Parser to Library (#88)
Browse files Browse the repository at this point in the history
* Add OTA Parser, OTA Parser MISRA fixes.

Add OTA Parser source and include files.
Add OTA Parser unit test files.
Add OTA Parser CBMC proofs.
OTA Parser MISRA fixes.


---------

Co-authored-by: GitHub Action <[email protected]>
  • Loading branch information
bradleysmith23 and actions-user authored Nov 7, 2023
1 parent 035be83 commit 0e4451b
Show file tree
Hide file tree
Showing 28 changed files with 1,999 additions and 347 deletions.
7 changes: 7 additions & 0 deletions .github/.cSpellWords.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
ASDFLKJ
CBMC
CBOR
CMOCK
CMock
Cmock
Coverity
DCMOCK
DNDEBUG
DUNITY
KQERL
MISRA
MEQCIGOTD
MEYCIQCV
Mrcd
Uhyc
MQTT
Misra
Wunused
Expand Down
1 change: 1 addition & 0 deletions .github/linkAllowList.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://s3.region.amazonaws.com/joe-ota/
3 changes: 3 additions & 0 deletions .github/memory_statistics_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
"lib_name": "AWS IoT Jobs",
"src": [
"source/jobs.c",
"source/otaJobParser/job_parser.c",
"source/otaJobParser/ota_job_handler.c",
"coreJSON/source/core_json.c"
],
"include": [
"source/include",
"source/otaJobParser/include",
"coreJSON/source/include"
]
}
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ jobs:
cmake -S test -B build/ \
-G "Unix Makefiles" \
-DCMAKE_BUILD_TYPE=Debug \
-DBUILD_CLONE_SUBMODULES=ON \
-DCMAKE_C_FLAGS='--coverage -Wall -Wextra -Werror'
make -C build/ all
- name: Test
Expand All @@ -28,7 +27,7 @@ jobs:
- name: Run Coverage
run: |
make -C build/ coverage
declare -a EXCLUDE=("\*test\*" "\*CMakeCCompilerId\*" "\*mocks\*" "\*source\*")
declare -a EXCLUDE=("\*test\*" "\*CMakeCCompilerId\*" "\*mocks\*" "\*source\*" "\*vendor/unity\*" "\*_deps\*")
echo ${EXCLUDE[@]} | xargs lcov --rc lcov_branch_coverage=1 -r build/coverage.info -o build/coverage.info
lcov --rc lcov_branch_coverage=1 --list build/coverage.info
- name: Check Coverage
Expand Down Expand Up @@ -108,14 +107,15 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: FreeRTOS/CI-CD-Github-Actions/link-verifier@main
with:
allowlist-file: ./.github/linkAllowList.txt

verify-manifest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
fetch-depth: 0
sparse-checkout: .

- name: Run manifest verifier
uses: FreeRTOS/CI-CD-GitHub-Actions/manifest-verifier@main
Expand Down
4 changes: 0 additions & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +0,0 @@
[submodule "test/unit-test/Unity"]
path = test/unit-test/Unity
url = https://github.com/ThrowTheSwitch/Unity
update = none
16 changes: 0 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,19 +104,6 @@ doxygen docs/doxygen/config.doxyfile

## Building unit tests

### Checkout Unity Submodule

By default, the submodules in this repository are configured with `update=none`
in [.gitmodules](.gitmodules) to avoid increasing clone time and disk space
usage of other repositories that submodule this repository.

To build unit tests, the submodule dependency of Unity is required. Use the
following command to clone the submodule:

```
git submodule update --checkout --init --recursive --test/unit-test/Unity
```

### Platform Prerequisites

- For running unit tests
Expand All @@ -128,9 +115,6 @@ git submodule update --checkout --init --recursive --test/unit-test/Unity

### Steps to build Unit Tests

1. Go to the root directory of this repository. (Make sure that the **Unity**
submodule is cloned as described [above](#checkout-unity-submodule).)

1. Create build directory: `mkdir build && cd build`

1. Run _cmake_ while inside build directory: `cmake -S ../test`
Expand Down
14 changes: 12 additions & 2 deletions docs/doxygen/include/size_table.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,24 @@
<td><center>2.8K</center></td>
<td><center>2.5K</center></td>
</tr>
<tr>
<td>job_parser.c</td>
<td><center>0.9K</center></td>
<td><center>0.9K</center></td>
</tr>
<tr>
<td>ota_job_handler.c</td>
<td><center>0.2K</center></td>
<td><center>0.2K</center></td>
</tr>
<tr>
<td>core_json.c</td>
<td><center>2.9K</center></td>
<td><center>2.4K</center></td>
</tr>
<tr>
<td><b>Total estimates</b></td>
<td><b><center>5.7K</center></b></td>
<td><b><center>4.9K</center></b></td>
<td><b><center>6.8K</center></b></td>
<td><b><center>6.0K</center></b></td>
</tr>
</table>
9 changes: 9 additions & 0 deletions jobsFilePaths.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,12 @@ set( JOBS_SOURCES
# JOBS library Public Include directories.
set( JOBS_INCLUDE_PUBLIC_DIRS
${CMAKE_CURRENT_LIST_DIR}/source/include )

# OTA Parser source files
set( OTA_HANDLER_SOURCES
${CMAKE_CURRENT_LIST_DIR}/source/otaJobParser/job_parser.c
${CMAKE_CURRENT_LIST_DIR}/source/otaJobParser/ota_job_handler.c )

# OTA Parser Public Include directories.
set( OTA_HANDLER_INCLUDES
${CMAKE_CURRENT_LIST_DIR}/source/otaJobParser/include )
35 changes: 35 additions & 0 deletions source/otaJobParser/include/job_parser.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright Amazon.com, Inc. and its affiliates. All Rights Reserved.
* SPDX-License-Identifier: MIT
*
* Licensed under the MIT License. See the LICENSE accompanying this file
* for the specific language governing permissions and limitations under
* the License.
*/

#ifndef JOB_PARSER_H
#define JOB_PARSER_H

#include <stdbool.h>
#include <stdlib.h>
#include <stdint.h>

typedef struct AfrOtaJobDocumentFields_t * AfrOtaJobDocumentFields;

/**
* @brief Populate the fields of 'result', returning
* true if successful.
*
* @param jobDoc FreeRTOS OTA job document
* @param jobDocLength OTA job document length
* @param fileIndex The index of the file to use properties of
* @param result Job document structure to populate
* @return true Job document fields were parsed from the document
* @return false Job document fields were not parsed from the document
*/
bool populateJobDocFields( const char * jobDoc,
const size_t jobDocLength,
int32_t fileIndex,
AfrOtaJobDocumentFields result );

#endif /* JOB_PARSER_H */
25 changes: 25 additions & 0 deletions source/otaJobParser/include/ota_job_processor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright Amazon.com, Inc. and its affiliates. All Rights Reserved.
* SPDX-License-Identifier: MIT
*
* Licensed under the MIT License. See the LICENSE accompanying this file
* for the specific language governing permissions and limitations under
* the License.
*/

#ifndef OTA_JOB_PROCESSOR_H
#define OTA_JOB_PROCESSOR_H

#include <stdint.h>

#include <stddef.h>
#include <stdint.h>

#include "job_parser.h"

int8_t otaParser_parseJobDocFile( const char * jobDoc,
const size_t jobDocLength,
const uint8_t fileIndex,
AfrOtaJobDocumentFields fields );

#endif /*OTA_JOB_PROCESSOR_H*/
Loading

0 comments on commit 0e4451b

Please sign in to comment.