ITF and Robot Framework
Integration Test Framework auxiliary<->connector mechanism is usable with Robot framework. In order to achieve it, extra plugins have been developed :
RobotLoader : handle the import magic mechanism
RobotComAux : keyword declaration for existing CommunicationAuxiliary
Note
See Robot framework regarding details about Robot keywords, cli…
How to
To bind ITF with Robot framework, the RobotLoader library has to be used in order to correctly create all auxiliaries and connectors (using the “usual” yaml configuration style). This step is mandatory, and could be done using the “Library” keyword and RobotLoader install/uninstall function. For example, inside a test suite using “Suite Setup” and “Suite Teardown”:
*** Settings ***
Documentation How to handle auxiliaries and connectors creation using Robot framework
Library pykiso.lib.robot_framework.loader.RobotLoader robot_com_aux.yaml WITH NAME Loader
Suite Setup Loader.install
Suite Teardown Loader.uninstall
Ready to Use Auxiliaries
Communication Auxiliary
This plugin only contains two keywords “Send message” and “Receive message”. The first one simply sends raw bytes using the associated connector and the second one returns one received message (raw form).
See below a complete example of the Robot Communication Auxiliary plugin:
*** Settings ***
Documentation Robot framework Demo for communication auxiliary implementation
Library pykiso.lib.robot_framework.communication_auxiliary.CommunicationAuxiliary WITH NAME ComAux
*** Keywords ***
send raw message
[Arguments] ${raw_msg} ${aux}
${is_executed}= ComAux.Send message ${raw_msg} ${aux}
[return] ${is_executed}
get raw message
[Arguments] ${aux} ${blocking} ${timeout}
${msg} ${source}= ComAux.Receive message ${aux} ${blocking} ${timeout}
[return] ${msg} ${source}
*** Test Cases ***
Test send raw bytes using keywords
[Documentation] Simply send raw bytes over configured channel
... using defined keywords
${state} send raw message \x01\x02\x03 aux1
Log ${state}
Should Be Equal ${state} ${TRUE}
${msg} ${source} get raw message aux1 ${TRUE} 0.5
Log ${msg}
Test send raw bytes
[Documentation] Simply send raw bytes over configured channel
... using communication auxiliary methods directly
${state} = Send message \x04\x05\x06 aux2
Log ${state}
Should Be Equal ${state} ${TRUE}
${msg} ${source} = Receive message aux2 ${FALSE} 0.5
Log ${msg}
DUT Auxiliary
This plugin can be used to control the ITF TestApp on the DUT.
See below an example of the Robot DUT Auxiliary plugin:
*** Settings ***
Documentation Test demo with RobotFramework and ITF TestApp
Library pykiso.lib.robot_framework.dut_auxiliary.DUTAuxiliary WITH NAME DutAux
Suite Setup Setup Aux
*** Keywords ***
Setup Aux
@{auxiliaries} = Create List aux1 aux2
Set Suite Variable @{suite_auxiliaries} @{auxiliaries}
*** Variables ***
*** Test Cases ***
Test TEST_SUITE_SETUP
[Documentation] Setup test suite on DUT
Test App TEST_SUITE_SETUP 1 1 ${suite_auxiliaries}
Test TEST_SECTION_RUN
[Documentation] Run test section on DUT
Test App TEST_SECTION_RUN 1 1 ${suite_auxiliaries}
Test TEST_CASE_SETUP
[Documentation] Setup test case on DUT
Test App TEST_CASE_SETUP 1 1 ${suite_auxiliaries}
Test TEST_CASE_RUN
[Documentation] Run test case on DUT
Test App TEST_CASE_RUN 1 1 ${suite_auxiliaries}
Test TEST_CASE_TEARDOWN
[Documentation] Teardown test case on DUT
Test App TEST_CASE_TEARDOWN 1 1 ${suite_auxiliaries}
Test TEST_SUITE_TEARDOWN
[Documentation] Teardown test suite on DUT
Test App TEST_SUITE_TEARDOWN 1 1 ${suite_auxiliaries}
Proxy Auxiliary
This robot plugin only contains two keywords : Suspend and Resume.
See below example :
*** Settings ***
Documentation Robot framework Demo for proxy auxiliary implementation
Library pykiso.lib.robot_framework.proxy_auxiliary.ProxyAuxiliary WITH NAME ProxyAux
*** Test Cases ***
Stop auxiliary run
[Documentation] Simply stop the current running auxiliary
Suspend ProxyAux
Resume auxiliary run
[Documentation] Simply resume the current running auxiliary
Resume ProxyAux
Instrument Control Auxiliary
As the “ITF” instrument control auxiliary, the robot version integrate exactly the same user’s interface.
Note
All return types between “ITF” and “Robot” auxiliary’s version stay identical!
Please find below a complete correlation table:
ITF method |
robot equivalent |
Parameter 1 |
Parameter 2 |
Parameter 3 |
---|---|---|---|---|
write |
Write |
command |
aux alias |
validation |
read |
Read |
aux alias |
||
query |
Query |
command |
aux alias |
|
get_identification |
Get identification |
aux alias |
||
get_status_byte |
Get status byte |
aux alias |
||
get_all_errors |
Get all errors |
aux alias |
||
reset |
Reset |
aux alias |
||
self_test |
Self test |
aux alias |
||
get_remote_control_state |
Get remote control state |
aux alias |
||
set_remote_control_on |
Set remote control on |
aux alias |
||
set_remote_control_off |
Set remote control off |
aux alias |
||
get_output_channel |
Get output channel |
aux alias |
||
set_output_channel |
Set output channel |
channel |
aux alias |
|
get_output_state |
Get output state |
aux alias |
||
enable_output |
Enable output |
aux alias |
||
disable_output |
Disable output |
aux alias |
||
get_nominal_voltage |
Get nominal voltage |
aux alias |
||
get_nominal_current |
Get nominal current |
aux alias |
||
get_nominal_power |
Get nominal power |
aux alias |
||
measure_voltage |
Measure voltage |
aux alias |
||
measure_current |
Measure current |
aux alias |
||
measure_power |
Measure power |
aux alias |
||
get_target_voltage |
Get target voltage |
aux alias |
||
get_target_current |
Get target current |
aux alias |
||
get_target_power |
Get target power |
aux alias |
||
set_target_voltage |
Set target voltage |
voltage |
aux alias |
|
set_target_current |
Set target current |
current |
aux alias |
|
set_target_power |
Set target power |
power |
aux alias |
|
get_voltage_limit_low |
Get voltage limit low |
aux alias |
||
get_voltage_limit_high |
Get voltage limit high |
aux alias |
||
get_current_limit_low |
Get current limit low |
aux alias |
||
get_current_limit_high |
Get current limit high |
aux alias |
||
get_power_limit_high |
Get power limit high |
aux alias |
||
set_voltage_limit_low |
Set voltage limit low |
voltage limit |
aux alias |
|
set_voltage_limit_high |
Set voltage limit high |
voltage limit |
aux alias |
|
set_current_limit_low |
Set current limit low |
current limit |
aux alias |
|
set_current_limit_high |
Set current limit high |
current limit |
aux alias |
|
set_power_limit_high |
Set power limit high |
power limit |
aux alias |
To run the available example:
cd examples
robot robot_test_suite/test_instrument
Note
A script demo with all available keywords is under examples/robot_test_suite/test_instrument and yaml see robot_inst_aux.yaml!
Library Documentation
Dynamic Loader plugin
- module
loader
- synopsis
implementation of existing magic import mechanism from ITF for Robot framework usage.
- class pykiso.lib.robot_framework.loader.RobotLoader(config_file)[source]
Robot framework plugin for ITF magic import mechanism.
Initialize attributes.
:param config_file : yaml configuration file path
Auxiliary interface
- module
aux_interface
- synopsis
Simply stored common methods for auxiliary’s when ITF is used with Robot framework.
- class pykiso.lib.robot_framework.aux_interface.RobotAuxInterface(aux_type)[source]
Common interface for all Robot auxiliary.
Initialize attributes.
- Parameters
aux_type (
AuxiliaryInterface
) – auxiliary’s class
Communication auxiliary plugin
- module
communication_auxiliary
- synopsis
implementation of existing CommunicationAuxiliary for Robot framework usage.
- class pykiso.lib.robot_framework.communication_auxiliary.CommunicationAuxiliary[source]
Robot framework plugin for CommunicationAuxiliary.
Initialize attributes.
- receive_message(aux_alias, blocking=True, timeout_in_s=None)[source]
Return a raw received message from the queue.
- Parameters
aux_alias (
str
) – auxiliary’s aliasblocking (
bool
) – wait for message till timeout elapses?timeout_in_s (
Optional
[float
]) – maximum time in second to wait for a response
- Return type
Union
[list
,Tuple
[list
,int
]]- Returns
raw message and source (return type could be different depending on the associated channel)
Testapp binding
- module
dut_auxiliary
- synopsis
implementation of existing DUTAuxiliary for Robot framework usage.
- class pykiso.lib.robot_framework.dut_auxiliary.DUTAuxiliary[source]
Robot library to control the TestApp on the DUT
Initialize attributes.
- test_app_run(command_type, test_suite_id, test_case_id, aux_list, timeout_cmd=5, timeout_resp=5)[source]
Handle default communication mechanism between test manager and device under test.
- Parameters
command_type (
str
) – message command sub-type (TEST_SECTION_SETUP , TEST_SECTION_RUN, …)test_suite_id (
int
) – select test suite id on duttest_case_id (
int
) – select test case id on dutaux_list (
List
[str
]) – List of selected auxiliarytimeout_cmd (
int
) – timeout in seconds for auxiliary run_commandtimeout_resp (
int
) – timeout in seconds for auxiliary wait_and_get_report
- Return type
None
- class pykiso.lib.robot_framework.dut_auxiliary.TestEntity(test_suite_id, test_case_id, aux_list)[source]
Dummy Class to use handle_basic_interaction from test_message_handler.
Initialize generic test-case
- Parameters
test_suite_id (
int
) – test suite identification numbertest_case_id (
int
) – test case identification numberaux_list (
List
[AuxiliaryInterface
]) – list of used aux_list
- cleanup_and_skip(aux, info_to_print)[source]
Cleanup auxiliary and log reasons.
- Parameters
aux (
AuxiliaryInterface
) – corresponding auxiliary to abortinfo_to_print (
str
) – A message you want to print while cleaning up the test
Proxy auxiliary plugin
- module
proxy_auxiliary
- synopsis
implementation of existing ProxyAuxiliary for Robot framework usage.
Instrument control auxiliary plugin
- module
instrument_control_auxiliary
- synopsis
implementation of existing InstrumentControlAuxiliary for Robot framework usage.
- class pykiso.lib.robot_framework.instrument_control_auxiliary.InstrumentControlAuxiliary[source]
Robot framework plugin for InstrumentControlAuxiliary.
Initialize attributes.
- disable_output(aux_alias)[source]
Disable output on the currently selected output channel of an instrument.
- Parameters
aux_alias (
str
) – auxiliary’s alias- Return type
str
- Returns
the writing operation’s status code
- enable_output(aux_alias)[source]
Enable output on the currently selected output channel of an instrument.
- Parameters
aux_alias (
str
) – auxiliary’s alias- Return type
str
- Returns
the writing operation’s status code
- get_all_errors(aux_alias)[source]
Get all errors of an instrument.
- Parameters
aux_alias (
str
) – auxiliary’s alias
return: list of off errors
- Return type
str
- get_current_limit_high(aux_alias)[source]
Returns the current upper limit (in V) of an instrument.
- Parameters
aux_alias (
str
) – auxiliary’s alias- Return type
str
- Returns
the query’s response message
- get_current_limit_low(aux_alias)[source]
Returns the current lower limit (in V) of an instrument.
- Parameters
aux_alias (
str
) – auxiliary’s alias- Return type
str
- Returns
the query’s response message
- get_identification(aux_alias)[source]
Get the identification information of an instrument.
- Parameters
aux_alias (
str
) – auxiliary’s alias- Return type
str
- Returns
the instrument’s identification information
- get_nominal_current(aux_alias)[source]
Query the nominal current of an instrument on the selected channel (in A)
- Parameters
aux_alias (
str
) – auxiliary’s alias- Return type
str
- Returns
the nominal current
- get_nominal_power(aux_alias)[source]
Query the nominal power of an instrument on the selected channel (in W).
- Parameters
aux_alias (
str
) – auxiliary’s alias- Return type
str
- Returns
the nominal power
- get_nominal_voltage(aux_alias)[source]
Query the nominal voltage of an instrument on the selected channel (in V).
- Parameters
aux_alias (
str
) – auxiliary’s alias- Return type
str
- Returns
the nominal voltage
- get_output_channel(aux_alias)[source]
Get the currently selected output channel of an instrument.
- Parameters
aux_alias (
str
) – auxiliary’s alias- Return type
str
- Returns
the currently selected output channel
- get_output_state(aux_alias)[source]
Get the output status (ON or OFF, enabled or disabled) of the currently selected channel of an instrument.
- Parameters
aux_alias (
str
) – auxiliary’s alias- Return type
str
- Returns
the output state (ON or OFF)
- get_power_limit_high(aux_alias)[source]
Returns the power upper limit (in W) of an instrument.
- Parameters
aux_alias (
str
) – auxiliary’s alias- Return type
str
- Returns
the query’s response message
- get_remote_control_state(aux_alias)[source]
Get the remote control mode (ON or OFF) of an instrument.
- Parameters
aux_alias (
str
) – auxiliary’s alias- Return type
str
- Returns
the remote control state
- get_status_byte(aux_alias)[source]
Get the status byte of an instrument.
- Parameters
aux_alias (
str
) – auxiliary’s alias- Return type
str
- Returns
the intrument’s status byte
- get_target_current(aux_alias)[source]
Get the desired output current (in A) of an instrument.
- Parameters
aux_alias (
str
) – auxiliary’s alias- Return type
str
- Returns
the target current
- get_target_power(aux_alias)[source]
Get the desired output power (in W) of an instrument.
- Parameters
aux_alias (
str
) – auxiliary’s alias- Return type
str
- Returns
the target power
- get_target_voltage(aux_alias)[source]
Get the desired output voltage (in V) of an instrument.
- Parameters
aux_alias (
str
) – auxiliary’s alias- Return type
str
- Returns
the target voltage
- get_voltage_limit_high(aux_alias)[source]
Returns the voltage upper limit (in V) of an instrument.
- Parameters
aux_alias (
str
) – auxiliary’s alias- Return type
str
- Returns
the query’s response message
- get_voltage_limit_low(aux_alias)[source]
Returns the voltage lower limit (in V) of an instrument.
- Parameters
aux_alias (
str
) – auxiliary’s alias- Return type
str
- Returns
the query’s response message
- measure_current(aux_alias)[source]
Return the measured output current of an instrument (in A).
- Parameters
aux_alias (
str
) – auxiliary’s alias- Return type
str
- Returns
the measured current
- measure_power(aux_alias)[source]
Return the measured output power of an instrument (in W).
- Parameters
aux_alias (
str
) – auxiliary’s alias- Return type
str
- Returns
the measured power
- measure_voltage(aux_alias)[source]
Return the measured output voltage of an instrument (in V).
- Parameters
aux_alias (
str
) – auxiliary’s alias- Return type
str
- Returns
the measured voltage
- query(query_command, aux_alias)[source]
Send a query request to the instrument.
- Parameters
query_command (
str
) – query command to sendaux_alias (
str
) – auxiliary’s alias
- Return type
str
- Returns
Response message, None if the request expired with a timeout.
- read(aux_alias)[source]
Send a read request to the instrument.
- Parameters
aux_alias (
str
) – auxiliary’s alias- Return type
str
- Returns
Response message, None if the request expired with a timeout.
- reset(aux_alias)[source]
Reset an instrument.
- Parameters
aux_alias (
str
) – auxiliary’s alias- Return type
str
- Returns
NO_VALIDATION status code
- self_test(aux_alias)[source]
Performs a self-test of an instrument.
- Parameters
aux_alias (
str
) – auxiliary’s alias- Return type
str
- Returns
the query’s response message
- set_current_limit_high(limit_value, aux_alias)[source]
Set the current upper limit (in A) of an instrument.
- Parameters
limit_value (
float
) – limit value to be set on the instrumentaux_alias (
str
) – auxiliary’s alias
- Return type
str
- Returns
the writing operation’s status code
- set_current_limit_low(limit_value, aux_alias)[source]
Set the current lower limit (in A) of an instrument.
- Parameters
limit_value (
float
) – limit value to be set on the instrumentaux_alias (
str
) – auxiliary’s alias
- Return type
str
- Returns
the writing operation’s status code
- set_output_channel(channel, aux_alias)[source]
Set the output channel of an instrument.
- Parameters
channel (
int
) – the output channel to select on the instrumentaux_alias (
str
) – auxiliary’s alias
- Return type
str
- Returns
the writing operation’s status code
- set_power_limit_high(limit_value, aux_alias)[source]
Set the power upper limit (in W) of an instrument.
- Parameters
limit_value (
float
) – limit value to be set on the instrumentaux_alias (
str
) – auxiliary’s alias
- Return type
str
- Returns
the writing operation’s status code
- set_remote_control_off(aux_alias)[source]
Disable the remote control of an instrument. The instrument will respond to query and read commands only.
- Parameters
aux_alias (
str
) – auxiliary’s alias- Return type
str
- Returns
the writing operation’s status code
- set_remote_control_on(aux_alias)[source]
Enables the remote control of an instrument. The instrument will respond to all SCPI commands.
- Parameters
aux_alias (
str
) – auxiliary’s alias- Return type
str
- Returns
the writing operation’s status code
- set_target_current(value, aux_alias)[source]
Set the desired output current (in A) of an instrument.
- Parameters
value (
float
) – value to be set on the instrumentaux_alias (
str
) – auxiliary’s alias
- Return type
str
- Returns
the writing operation’s status code
- set_target_power(value, aux_alias)[source]
Set the desired output power (in W) of an instrument.
- Parameters
value (
float
) – value to be set on the instrumentaux_alias (
str
) – auxiliary’s alias
- Return type
str
- Returns
the writing operation’s status code
- set_target_voltage(value, aux_alias)[source]
Set the desired output voltage (in V) of an instrument.
- Parameters
value (
float
) – value to be set on the instrumentaux_alias (
str
) – auxiliary’s alias
- Return type
str
- Returns
the writing operation’s status code
- set_voltage_limit_high(limit_value, aux_alias)[source]
Set the voltage upper limit (in V) of an instrument.
- Parameters
limit_value (
float
) – limit value to be set on the instrumentaux_alias (
str
) – auxiliary’s alias
- Return type
str
- Returns
the writing operation’s status code
- set_voltage_limit_low(limit_value, aux_alias)[source]
Set the voltage lower limit (in V) of an instrument.
- Parameters
limit_value (
float
) – limit value to be set on the instrumentaux_alias (
str
) – auxiliary’s alias
- Return type
str
- Returns
the writing operation’s status code
- write(write_command, aux_alias, validation=None)[source]
Send a write request to the instrument and then returns if the value was successfully written. A query is sent immediately after the writing and the answer is compared to the expected one.
- Parameters
write_command (
str
) – write command to sendaux_alias (
str
) – auxiliary’s aliasvalidation (
Optional
[tuple
]) – tuple of the form (validation command (str), expected output (str))
- Return type
str
- Returns
status message depending on the command validation: SUCCESS, FAILURE or NO_VALIDATION