Skip to content

Commit

Permalink
scripts: partition manager: split single test to multiple tests
Browse files Browse the repository at this point in the history
Refactored partition manager test to multiple
tests to have better coverage for each
functionality.

Signed-off-by: Lukasz Fundakowski <lukasz.fundakowski@nordicsemi.no>
  • Loading branch information
fundakol committed Feb 21, 2025
1 parent 5daca9e commit 07d4a76
Show file tree
Hide file tree
Showing 5 changed files with 323 additions and 206 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/scripts-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
branches:
- main
paths:
- 'scripts/**'
- 'scripts/**/*'

jobs:
test-scripts:
Expand All @@ -25,4 +25,4 @@ jobs:
- name: Install packages
run: python -m pip install -r scripts/requirements-test.txt
- name: Run tests
run: python -m pytest scripts/bootloader/tests scripts/tests
run: python -m pytest scripts
1 change: 1 addition & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,7 @@
/scripts/sdp/ @nrfconnect/ncs-ll-ursus
/scripts/twister/alt/zephyr/tests/drivers/mspi/api/testcase.yaml @nrfconnect/ncs-ll-ursus
/scripts/generate_psa_key_attributes.py @nrfconnect/ncs-aurora
/scripts/tests/ @nrfconnect/ncs-pluto @fundakol

/scripts/docker/*.rst @nrfconnect/ncs-doc-leads
/scripts/hid_configurator/*.rst @nrfconnect/ncs-si-bluebagel-doc
Expand Down
24 changes: 3 additions & 21 deletions scripts/partition_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause

import argparse
import yaml
from os import path
import sys
from os import path
from pprint import pformat
from io import StringIO

import yaml

PERMITTED_STR_KEYS = ['size', 'region']
END_TO_START = 'end_to_start'
Expand Down Expand Up @@ -1050,23 +1050,5 @@ def main():
write_yaml_out_file(regions, args.output_regions)


def expect_addr_size(td, name, expected_address, expected_size):
if expected_size is not None:
assert td[name]['size'] == expected_size, \
'Size of {} was {}, expected {}.\ntd:{}'.format(name, td[name]['size'], expected_size, pformat(td))
if expected_address is not None:
assert td[name]['address'] == expected_address, \
'Address of {} was {}, expected {}.\ntd:{}'.format(name, td[name]['address'], expected_address, pformat(td))
if expected_size is not None and expected_address is not None:
assert td[name]['end_address'] == expected_address + expected_size, \
'End address of {} was {}, expected {}.\ntd:{}'.format(name, td[name]['end_address'], expected_address + expected_size, pformat(td))


def expect_list(expected, actual):
expected_list = list(sorted(expected))
actual_list = list(sorted(actual))
assert sorted(expected_list) == sorted(actual_list), 'Expected list {}, was {}'.format(expected_list, actual_list)


if __name__ == '__main__':
main()
1 change: 1 addition & 0 deletions scripts/requirements-test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
cryptography
intelhex
pytest
pyyaml
Loading

0 comments on commit 07d4a76

Please sign in to comment.