Functions | |
| include (fname) | |
| include python code in a test script | |
| test_file () | |
| get the test file name with path | |
| test_dir () | |
| get the test directory (relative to the current directory) | |
| test (title, opt=0) | |
| start a new test | |
| skip (nTests=9999) | |
| skip the tests following this command. | |
| SCENARIO (self, title="", opt=0) | |
| start a new BDD-style scenario (alternative #1) | |
| GIVEN (self, msg="", dest=0x3) | |
| start the "given" section of a BDD-style scenario (alternative #1) | |
| WHEN (self, msg="", dest=0x3) | |
| start the "when" section of a BDD-style scenario (alternative #1) | |
| THEN (self, msg="", dest=0x3) | |
| start the "then" section of a BDD-style scenario (alternative #1) | |
| AND (self, msg="", dest=0x3) | |
| adds the "and" section of a BDD-style scenario (alternative #1) | |
| scenario (title, opt=0) | |
| start a new BDD-style scenario (alternative #2) | |
| given (given_msg, and_msg) | |
| start the "given" section of a BDD-style scenario (alternative #2) | |
| when (given_msg, and_msg) | |
| start the "when" section of a BDD-style scenario (alternative #2) | |
| then (given_msg, and_msg) | |
| start the "then" section of a BDD-style scenario (alternative #2) | |
| expect (match) | |
| defines an expectation for the current test | |
| ensure (bool_expr) | |
| ensures that the provided Boolean expression is true | |
| glb_filter (*args) | |
| Send the QS Global Filter to the Target. | |
| loc_filter (*args) | |
| Send the Local Filter to the Target. | |
| ao_filter (obj_id) | |
| Updates the Local Filter for a given AO in the Target. | |
| current_obj (obj_kind, obj_id) | |
| Set the Current-Object in the Target. | |
| query_curr (obj_kind) | |
| query the current object in the Target | |
| tick (tick_rate=0) | |
| trigger system clock tick in the Target | |
| expect_pause () | |
| defines expectation for a Test Pause | |
| expect_run () | |
| defines expectation for calling QF_run()/QF::run() | |
| continue_test () | |
| sends the CONTINUE packet to the Target to continue a test | |
| command (cmdId, param1=0, param2=0, param3=0) | |
| executes a given command in the Target | |
| init (signal=0, params=None) | |
| take the top-most initial transition in the current SM object in the Target | |
| dispatch (signal, params=None) | |
| dispatch a given event in the current SM object in the Target | |
| post (signal, params=None) | |
| post a given event to the current AO object in the Target | |
| publish (signal, params=None) | |
| publish a given event to subscribers in the Target | |
| probe (func, data) | |
| sends a Test-Probe to the Target | |
| peek (offset, size, num) | |
| peeks data in the Target | |
| poke (offset, size, data) | |
| pokes data into the Target. | |
| fill (offset, size, num, item=0) | |
| fills data into the Target. | |
| note (msg, dest=(SCREEN|TRACE)) | |
| display a note in the QUTest output and in QSPY output. | |
| tag (msg, dest=(SCREEN|TRACE)) | |
| display a tag in the QUTest output and in QSPY output. | |
| pack (format, v1, v2) | |
| packs data into binary string to be sent to QSPY. | |
| last_rec () | |
| returns last record received from the target as string. | |
| on_reset () | |
| callback function invoked after each Target reset | |
| on_setup () | |
| callback function invoked at the beginning of each test | |
| on_teardown () | |
| callback function invoked at the end of each test | |
Variables | |
| int | VERSION = 740 |
| current version of the Python QUTest interface | |
| qutest_dsl.include | ( | fname | ) |
include python code in a test script
Description
This preamble command includes python code in a specified file into the test script. The included file can contain any code that you would put into test scripts (see Example below).
| [in] | fname | name of the file to include. May contain a path relative to the test script. |
Usage
Example
file to be included:
test script calling include():
Definition at line 56 of file qutest_dsl.py.
| qutest_dsl.test_file | ( | ) |
get the test file name with path
Description
This command returns a string containing the file name of the currently executed test script ("test group").
Usage
Definition at line 68 of file qutest_dsl.py.
| qutest_dsl.test_dir | ( | ) |
get the test directory (relative to the current directory)
Description
This complex command returns a string containing the directory name of the currently executed test script ("test group").
Usage
Definition at line 80 of file qutest_dsl.py.
| qutest_dsl.test | ( | title, | |
| opt = 0 ) |
start a new test
Description
This complex command starts a new test and gives it a name.
| [in] | title | title of the test |
| [in] | opt | options {0=default, NORESET} |
Usage
Definition at line 101 of file qutest_dsl.py.
| qutest_dsl.skip | ( | nTests = 9999 | ) |
skip the tests following this command.
| [in] | nTests | number of tests to skip (default-all remaining tests) e.g., skip(1) will skip one test following this command. |
Usage
Definition at line 126 of file qutest_dsl.py.
| qutest_dsl.SCENARIO | ( | self, | |
| title = "", | |||
| opt = 0 ) |
start a new BDD-style scenario (alternative #1)
Description
This function that starts a new BDD-style scenario.
| [in] | title | title of the scenario |
| [in] | opt | options {0=default, NORESET} |
The SCENARIO() command outputs the provided title (text) to the QUTest output (text/log) and the QSPY output (text/log), adding the prefix
Usage
Definition at line 159 of file qutest_dsl.py.
| qutest_dsl.GIVEN | ( | self, | |
| msg = "", | |||
| dest = 0x3 ) |
start the "given" section of a BDD-style scenario (alternative #1)
Description
This function defines the "given" section of a BDD-scenario. The GIVEN() section typically sets up the context for the "given-when-then" sequence. Therefore, a GIVEN() section should follow SCENARIO().
| [in] | msg | optional "given" message |
| [in] | dest | optional destination of the message (both screen and QSPY) |
Usage
Definition at line 192 of file qutest_dsl.py.
| qutest_dsl.WHEN | ( | self, | |
| msg = "", | |||
| dest = 0x3 ) |
start the "when" section of a BDD-style scenario (alternative #1)
Description
This function that defines the "when" section of a BDD-scenario. The commands in this section typically include the command() or post() command. The WHEN() section should follow the GIVEN() section.
| [in] | msg | optional "when" message |
| [in] | dest | optional destination of the message (both screen and QSPY) |
Usage
Definition at line 225 of file qutest_dsl.py.
| qutest_dsl.THEN | ( | self, | |
| msg = "", | |||
| dest = 0x3 ) |
start the "then" section of a BDD-style scenario (alternative #1)
Description
This function that defines the "then" section of a BDD-scenario. The commands in this section typically include the expect() command. The THEN() section should follow the WHEN() section.
| [in] | msg | optional "when" message |
| [in] | dest | optional destination of the message (both screen and QSPY) |
Usage
Definition at line 258 of file qutest_dsl.py.
| qutest_dsl.AND | ( | self, | |
| msg = "", | |||
| dest = 0x3 ) |
adds the "and" section of a BDD-style scenario (alternative #1)
Description
This function that defines the "and" section of a BDD-scenario. This section can augment the "given" or the "then" sections to better delimit the additional preconditions or additional effects.
| [in] | msg | optional "when" message |
| [in] | dest | optional destination of the message (both screen and QSPY) |
Usage
Definition at line 290 of file qutest_dsl.py.
| qutest_dsl.scenario | ( | title, | |
| opt = 0 ) |
start a new BDD-style scenario (alternative #2)
Description
This is a Python decorator to a function that starts a new BDD-style scenario.
| [in] | title | title of the scenario |
| [in] | opt | options {0=default, NORESET} |
The @scenario() decorator outputs the provided title (text) to the QUTest output (text/log) and the QSPY output (text/log), adding the prefix "Scenario:" in front.
The decorated function must take the:
| [in,out] | context | execution context (clean context at the start of a scenario) |
Usage
Definition at line 334 of file qutest_dsl.py.
| qutest_dsl.given | ( | given_msg, | |
| and_msg ) |
start the "given" section of a BDD-style scenario (alternative #2)
Description
This is a Python decorator to a function that defines the "given" section. The @given section typically sets up the context for the "given-when-then" sequence. Therefore, a @given section should follow @scenario() or it might follow the @then() section to define another "given-when-then" sequence.
| [in] | given_msg | optional "given" message |
| [in] | and_msg | optional "and" messages |
The @given() command outputs the provided given_msg (text) to the QUTest output (text/log) and the QSPY output (text/log), adding the prefix "Given:" in front. Additionally, every subsequent and_msg is also output with the prefix "And:".
The decorated function must take the:
| [in,out] | context | execution context |
Usage
Definition at line 393 of file qutest_dsl.py.
| qutest_dsl.when | ( | given_msg, | |
| and_msg ) |
start the "when" section of a BDD-style scenario (alternative #2)
Description
This is a Python decorator to a function that defines the "when" section. The @when section typically executes a command() or post() command. The @when section should follow the @given() section.
| [in] | when_msg | optional "when" message |
| [in] | and_msg | optional "and" messages |
The @when() command outputs the provided when_msg (text) to the QUTest output (text/log) and the QSPY output (text/log), adding the prefix "When:" in front. Additionally, every subsequent and_msg is also output with the prefix "And:".
The decorated function must take the:
| [in,out] | context | execution context |
Usage
Definition at line 444 of file qutest_dsl.py.
| qutest_dsl.then | ( | given_msg, | |
| and_msg ) |
start the "then" section of a BDD-style scenario (alternative #2)
Description
This is a Python decorator to a function that defines the "then" section. The @then section typically calls the expect() commands to verify the expectaion of the "given-when-then" sequence. The @then section should follow the @when() section.
| [in] | then_msg | optional "then" message |
| [in] | and_msg | optional "and" messages |
The @then command outputs the provided then_msg (text) to the QUTest output (text/log) and the QSPY output (text/log), adding the prefix "Then:" in front. Additionally, every subsequent and_msg is also output with the prefix "And:".
The decorated function must take the:
| [in,out] | context | execution context |
Usage
Definition at line 500 of file qutest_dsl.py.
| qutest_dsl.expect | ( | match | ) |
defines an expectation for the current test
Description
This command defines a new expecation for the textual output produced by QSPY.
| [in] | match | the expected match for the QSPY output The match string can contain special characters, such as: *, ? and [chars], which are matched according to the Python command fnmatch.fnmatchcase() |
match string can be the printf-style %-subsitution string (compatible with Python 2 and Python 3), or the new "f-string" (compatible only with Python 3).match parameter will be automatically replaced with the current numerical value of the test sequence-counter.Usage
Definition at line 529 of file qutest_dsl.py.
| qutest_dsl.ensure | ( | bool_expr | ) |
ensures that the provided Boolean expression is true
Description
This command performs checking of a condition, which is believed to be true in order for a test to pass. If the provided Boolean expression evaluates to false, the test is failed in the usual way.
| [in] | bool_expr | the Boolean expression to check |
Usage
Definition at line 543 of file qutest_dsl.py.
| qutest_dsl.glb_filter | ( | * | args | ) |
Send the QS Global Filter to the Target.
Description
This simple command sends the complete QS Global Filter to the Target. Any existing Global Filter setting inside the Target will be overwritten.
| [in] | args | list of Record-Type groups or individual Record-Types to set or clear. A given filter-group or an individual filter is set when it is positive, and cleared with it is preceded with the minus (-) sign. The filter list can contain the following: GRP_ALL # all Record-Types
GRP_SM # State Machine Record-Types
GRP_AO # Active Object Record-Types
GRP_MP # Memory Pool Record-Types
GRP_EQ # Event Queue Record-Types
GRP_TE # Time Events Record-Types
GRP_QF # Framework Record-Types (e.g., post/publish/..)
GRP_SC # Scheduler Record-Types (e.g., scheduler lock/unlock)
GRP_SEM # Semaphore Record-Types (e.g., Semaphore take/signal)
GRP_MTX # Mutex Record-Types (e.g., Mutex lock/unlock)
GRP_U0 # User group 0 (Record-Types 100-104)
GRP_U1 # User group 1 (Record-Types 105-109)
GRP_U2 # User group 2 (Record-Types 110-114)
GRP_U3 # User group 3 (Record-Types 115-119)
GRP_U4 # User group 0 (Record-Types 120-124)
GRP_UA # All user records (Record-Types 100-124)
<num> # Specific QS trace Record-Type in the range 0..127
|
Usage
Definition at line 588 of file qutest_dsl.py.
| qutest_dsl.loc_filter | ( | * | args | ) |
Send the Local Filter to the Target.
Description
This simple command sends the complete QS Local Filter to the Target. Any existing Local Filter setting inside the Target will be overwritten.
| [in] | args | list of QS-ID groups or individual QS-IDs to set or clear. A given filter-group or an individual filter is set when it is positive, and cleared with it is preceded with the minus (-) sign. |
This parameter can take one of the following values:
Usage
Definition at line 621 of file qutest_dsl.py.
| qutest_dsl.ao_filter | ( | obj_id | ) |
Updates the Local Filter for a given AO in the Target.
Description
This simple command sets or clears the QS Local Filter corresponding to the given AO in the Target. Unlike loc_filter(), this facility changes only the QS-ID (AO's priority) of the given AO in the Target. All other Local Filters will be left unchanged.
| [in] | obj_id | active object to set/clear the local filter for in the Target |
This parameter can be either a string (name of the AO) or the AO's priority. Also, it can be either positive (to set) or negative (to clear) the QS local filter.
Usage
Definition at line 645 of file qutest_dsl.py.
| qutest_dsl.current_obj | ( | obj_kind, | |
| obj_id ) |
Set the Current-Object in the Target.
Description
This simple command sets the "current object" in the Target.
| [in] | obj_kind | Kind of object to set |
This parameter can take one of the following values:
| [in] | obj_id | Name or addres of the object |
Usage
Definition at line 678 of file qutest_dsl.py.
| qutest_dsl.query_curr | ( | obj_kind | ) |
query the current object in the Target
Description
This complex command queries the current object in the Target.
| [in] | obj_kind | Kind of object to query |
This parameter can take one of the following values:
Usage
The queries for various objects generate the following QS trace records from the Target
Definition at line 719 of file qutest_dsl.py.
| qutest_dsl.tick | ( | tick_rate = 0 | ) |
trigger system clock tick in the Target
Description
This complex command triggers the following actions in the Target:
| [in] | tick_rate | the tick rate (0..QF_MAX_TICK_RATE) |
Usage
Definition at line 739 of file qutest_dsl.py.
| qutest_dsl.expect_pause | ( | ) |
defines expectation for a Test Pause
Description
This is a special expectation that must match the macro QS_TEST_PAUSE() inside the test fixture.
Usage
Definition at line 757 of file qutest_dsl.py.
| qutest_dsl.expect_run | ( | ) |
defines expectation for calling QF_run()/QF::run()
Description
This is a special expectation for the target calling the QF_run()/QF::run() function.
Usage
Definition at line 775 of file qutest_dsl.py.
| qutest_dsl.continue_test | ( | ) |
sends the CONTINUE packet to the Target to continue a test
Description
This command continues the test after QS_TEST_PAUSE().
Usage
Definition at line 788 of file qutest_dsl.py.
| qutest_dsl.command | ( | cmdId, | |
| param1 = 0, | |||
| param2 = 0, | |||
| param3 = 0 ) |
executes a given command in the Target
Description
This complex command causes execution of the QS_onCommand() callback in the test fixture.
| [in] | cmdId | the first cmdId argument for the QS_onCommand() callback function in the test fixture. |
| [in] | param1 | the "param1" argument to QS_onCommand() (optional) |
| [in] | param2 | the "param2" argument to QS_onCommand() (optional) |
| [in] | param3 | the "param3" argument to QS_onCommand() (optional) |
Usage
Definition at line 811 of file qutest_dsl.py.
| qutest_dsl.init | ( | signal = 0, | |
| params = None ) |
take the top-most initial transition in the current SM object in the Target
Description
This complex command takes the top-most initial transition in the current SM object in the Target.
| [in] | signal | the event signal of the "initialization event" |
| [in] | params | the parameters of the "initialization event" |
Usage
Definition at line 832 of file qutest_dsl.py.
| qutest_dsl.dispatch | ( | signal, | |
| params = None ) |
dispatch a given event in the current SM object in the Target
Description
This complex command dispatches a given event in the current SM object in the Target.
| [in] | signal | the event signal of the event to be dispatched |
| [in] | params | the parameters of the event to be dispatched |
Usage
Definition at line 851 of file qutest_dsl.py.
| qutest_dsl.post | ( | signal, | |
| params = None ) |
post a given event to the current AO object in the Target
Description
This complex command posts a given event to the current AO object in the Target.
| [in] | signal | the event signal of the event to be posted |
| [in] | params | the parameters of the event to be posted |
Usage
Definition at line 870 of file qutest_dsl.py.
| qutest_dsl.publish | ( | signal, | |
| params = None ) |
publish a given event to subscribers in the Target
Description
This complex command publishes a given event in the Target.
| [in] | signal | the event signal of the event to be posted |
| [in] | params | the parameters of the event to be posted |
Usage
Definition at line 889 of file qutest_dsl.py.
| qutest_dsl.probe | ( | func, | |
| data ) |
sends a Test-Probe to the Target
Description
This simple command sends the Test Probe data to the Target. The Target collects these Test Probes preserving the order in which they were sent. Subsequently, whenever a given API is called inside the Target, it can obtain the Test-Probe by means of the QS_TEST_PROBE_DEF() macro. The QS_TEST_PROBE_DEF() macro returns the Test-Probes in the same order as they were received to the Target. If there are no more Test- Probes for a given API, the Test-Probe is initialized to zero.
| [in] | func | the name or raw address of a function |
| [in] | data | the data (uint32_t) for the Test-Probe |
Usage
Definition at line 916 of file qutest_dsl.py.
| qutest_dsl.peek | ( | offset, | |
| size, | |||
| num ) |
peeks data in the Target
Description
This complex command peeks data at the given offset from the start address of the current_obj() inside the Target.
| [in] | offset | offset [in bytes] from the start of the current_obj() |
| [in] | size | size of the data items (1, 2, or 4) |
| [in] | num | number of data items to peek |
Usage
Definition at line 937 of file qutest_dsl.py.
| qutest_dsl.poke | ( | offset, | |
| size, | |||
| data ) |
pokes data into the Target.
Description
This simple command pokes provided data at the given offset from the start address of the current AP object inside the Target.
| [in] | offset | offset [in bytes] from the start of the current_obj() |
| [in] | size | size of the data items (1, 2, or 4) |
| [in] | data | binary data to send |
Usage
Definition at line 957 of file qutest_dsl.py.
| qutest_dsl.fill | ( | offset, | |
| size, | |||
| num, | |||
| item = 0 ) |
fills data into the Target.
Description
This simple command fills provided data at the given offset from the start address of the current_obj() inside the Target.
| [in] | offset | offset [in bytes] from the start of the current_obj() |
| [in] | size | size of the data item (1, 2, or 4) |
| [in] | num | number of data items to fill |
| [in] | item | data item to fill with |
Usage
Definition at line 977 of file qutest_dsl.py.
| qutest_dsl.note | ( | msg, | |
| dest = (SCREEN | TRACE) ) |
display a note in the QUTest output and in QSPY output.
Description
This command allows the test script to output a note (text) both to the QUTest output (text/log) and the QSPY output (text/log). This command can be also used for commenting the test scripts.
| [in] | msg | text message |
| [in] | dest | destination (SCREEN, TRACE), default both Usage note("This is a short note")
note('''
This test group checks the MPU (Memory Protection Unit)
by reading/writing from/to various memory addresses
in the target
''', SCREEN)
|
Definition at line 999 of file qutest_dsl.py.
| qutest_dsl.tag | ( | msg, | |
| dest = (SCREEN | TRACE) ) |
display a tag in the QUTest output and in QSPY output.
Description
This is an alias for the note() command for the BDD-style testing.
Definition at line 1007 of file qutest_dsl.py.
| qutest_dsl.pack | ( | format, | |
| v1, | |||
| v2 ) |
packs data into binary string to be sent to QSPY.
Description
This command corresponds to Python struct.pack(). It returns a bytes object containing the values v1, v2,... packed according to the format string format. The arguments must match the values required by the [format](https://docs.python.org/3/library/struct.html#format-strings") exactly.
The pack() command is typically used inside other QUTest commands
to pack the binary event parameters or binary data for poke() and fill().
@param [in] format string
@param [in] v1 one or more data elements requried by format
@param [in] v2 one or more data elements requried by format
<strong>Usage</strong><br>
@code{py}
dispatch("MY_SIG", pack("<B", 2))
poke(2, 2, pack("<HH", 0xB2C2, 0xD2E2))
Definition at line 1031 of file qutest_dsl.py.
| qutest_dsl.last_rec | ( | ) |
returns last record received from the target as string.
Usage
Definition at line 1048 of file qutest_dsl.py.
| qutest_dsl.on_reset | ( | ) |
callback function invoked after each Target reset
Description
If defined, this callback should handle the expectations and end with expect_run(). If not defiend, the default implementation only expects QF_RUN.
Definition at line 1059 of file qutest_dsl.py.
| qutest_dsl.on_setup | ( | ) |
callback function invoked at the beginning of each test
Definition at line 1064 of file qutest_dsl.py.
| qutest_dsl.on_teardown | ( | ) |
callback function invoked at the end of each test
Definition at line 1069 of file qutest_dsl.py.
| int qutest_dsl.VERSION = 740 |
current version of the Python QUTest interface
Definition at line 30 of file qutest_dsl.py.