[Discuss OpenCPI] Unit testing with optional ports / testing failure conditions

From: <dwp_at_md1tech.co.uk>
Date: Thu, 01 Jun 23 15:01:58 +0000

Hello,

I have a component with the following spec:

`<ComponentSpec>`\
` <Property name='scalingStyle' type='string' stringlength='10' writable='true' default='log'/>`\
` <Property name='maxValueAfterScale' type='ULong' writable='true' default='255'/>`\
` <Property name='verbose' type='bool' writable='true' default='false'/>`\
` <Port name='in' producer='false' protocol='largeIqStream-prot.xml'/>`\
` <Port name='outULong' producer='true' protocol='largeULongStream-prot.xml' optional='true'/>`\
` <Port name='outUShort' producer='true' protocol='largeUShortStream-prot.xml' optional='true'/>`\
` <Port name='outUChar' producer='true' protocol='largeUCharStream-prot.xml' optional='true'/>`\
`</ComponentSpec>`

In order to avoid sending unnecessarily large streams of data, the output port that should be used will depend on the value of `maxValueAfterScale` (0-255 `uCharStream`, 255-65,535 `uShortStream`, 65,535+ `uLongStream`).

Within the RCC Worker for this component, a check is performed that only the correct output port is connected and `RCC_FATAL` is returned if this is not the case.

1. Is there a way I can specify within a unit test that I only want certain output ports to be connected? The application file that gets generated has all 3 ports connected with the following test XML:\
   `<Tests UseHDLFileIo='true'>`\
   ` <Input port='in' script='generate.py'/>`\
   ` <Output port='outUChar' script='verify.py'/>`\
   ` <Property name='scalingStyle' values='log, linear, none'/>`\
   ` <Property name='maxValueAfterScale' values='100, 10000, 100000'/>`\
   `</Tests>`

2. Thinking more generally, how can I test within a unit test that a component fails when it is supposed to, and test the console output it gives in these fail situations.






Received on Thu Jun 01 2023 - 15:01:58 CDT

This archive was generated by hypermail 2.3.0 : Fri Jun 05 2026 - 08:45:25 CDT