Skip to content

Conversation

@gchwier
Copy link
Contributor

@gchwier gchwier commented Nov 15, 2024

Extended hardware map to share a single board between variants. To run tests for different variants on the same board without re-configuring the hardware map file for each variant, one can extend the platform attribute with board names separated by spaces or use platform as a list.

Generate hardware map:
${ZEPHYR_BASE}/scripts/twister --generate-hardware-map hardware_map.yml

Update platform with two variants you want to use:

- connected: true
  id: '001050076605'
  platform: nrf5340dk/nrf5340/cpuapp nrf5340dk/nrf5340/cpuapp/ns
  product: J-Link
  runner: nrfjprog
  serial: /dev/ttyACM1

Run tests:
./scripts/twister -T samples/hello_world --device-testing --hardware-map hardware_map.yml --west-flash=--recover -vv --no-clean -ll debug

DEBUG   - platform filter: ['nrf5340dk/nrf5340/cpuapp', 'nrf5340dk/nrf5340/cpuapp/ns']
...
| Board                       |           ID |   Counter |   Failures |
|-----------------------------|--------------|-----------|------------|
| nrf5340dk/nrf5340/cpuapp    | 001050076605 |         1 |          0 |
| nrf5340dk/nrf5340/cpuapp/ns | 001050076605 |         1 |          0 |

When test is run on a selected board, then all DUTs with same id are locked.

@gchwier gchwier force-pushed the grch_hwmap_with_variants branch from d0d0536 to c6253a9 Compare November 18, 2024 09:23
Copy link
Member

Choose a reason for hiding this comment

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

can this instead be a list with type: any in the schema so it does support one single entry and a list if variants if needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I considered using:

type: seq
sequence:
    - type str

but that would break backward compatibility, so I didn't apply it.

Good idea with type: any, I will try to update it.
I was looking into testsuite-schema and there are a few fields that can be either a string or a list. There is also a logic in config_parser.py to properly cast those fields. I need to look into it more closely.
Thanks for the advice.

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 with type: any. Now user can use a list of platforms:
in line, separated by spaces:

platform: nrf5340dk/nrf5340/cpuapp nrf5340dk/nrf5340/cpuapp/ns

or as a list:

platform:
- nrf5340dk/nrf5340/cpuapp
- nrf5340dk/nrf5340/cpuapp/ns

@hakehuang
Copy link
Contributor

@gchwier this would be a problem, if we add pre_script/post_scripts, we need know the platform, so we need pass the platform name to the scripts as well?

@gchwier gchwier force-pushed the grch_hwmap_with_variants branch 2 times, most recently from e390690 to 9edf959 Compare November 20, 2024 11:21
@gchwier
Copy link
Contributor Author

gchwier commented Nov 20, 2024

@gchwier this would be a problem, if we add pre_script/post_scripts, we need know the platform, so we need pass the platform name to the scripts as well?

It will work with PR #81389
because a separate DUT instance is created for every platform.
If you plan to rework your PR to pass parameters to pre-script directly from hardware map yaml file, you can still use separate entries for every variants (as it works now, this change is backward compatible)

Copy link
Member

Choose a reason for hiding this comment

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

The title is not clear IMO. Maybe Using Single Board For Multiple Variants? Or Boards Supporting Multiple Variants?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed to Using Single Board For Multiple Variants, thanks!

Comment on lines 1284 to 1287
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
The ``platform`` attribute can be a list of names or can be extended
with names separated by spaces. This allows you to run tests for
different variants on the same board without re-configuring
the hardware map file for each variant. For example:
The ``platform`` attribute can be a list of names or a string
with names separated by spaces. This allows to run tests for
different platform variants on the same physical board, without re-configuring
the hardware map file for each variant. For example:

Extended hardware map to share a single board between variants.
To run tests for different variants on the same board
without re-configuring the hardware map file for each variant,
one can use a `platform` atribute as a list of names.

Signed-off-by: Grzegorz Chwierut <grzegorz.chwierut@nordicsemi.no>
@gchwier gchwier force-pushed the grch_hwmap_with_variants branch from 9edf959 to 65b34ed Compare November 20, 2024 17:55
@gchwier gchwier requested a review from PerMac November 20, 2024 18:03
dut = DUT()
dut.available = 0
dut.failures = 0
handler.duts = [dut]
Copy link
Member

@golowanow golowanow Nov 21, 2024

Choose a reason for hiding this comment

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

would be nice to have some tests added for the changed behavior with several DUTs in the list

@henrikbrixandersen henrikbrixandersen merged commit e0bd7e7 into zephyrproject-rtos:main Nov 21, 2024
31 checks passed
@gchwier gchwier deleted the grch_hwmap_with_variants branch November 21, 2024 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants