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!
Acroname Auxiliary
This plugin can be used to control a acroname usb hub.
Find below an example with all available features:
1*** Settings ***
2Documentation Robot framework Demo for acroname auxiliary implementation
3
4Library pykiso.lib.robot_framework.acroname_auxiliary.AcronameAuxiliary WITH NAME AcroAux
5
6*** Variables ***
7${NO_ERROR} = ${0}
8
9*** Test Cases ***
10
11Disable / Enable USB Ports
12 [Documentation] Disable and Enable USB Ports
13
14 Log Disable all Ports
15
16 FOR ${index} IN RANGE 0 4
17 Log Disable USB port ${index}
18 ${state} Set port disable acroname_aux ${index}
19 Should Be Equal ${state} ${NO_ERROR}
20 END
21
22 Sleep 1s
23
24 FOR ${index} IN RANGE 0 4
25 Log Enable USB port ${index}
26 ${state} Set port disable acroname_aux ${index}
27 Should Be Equal ${state} ${NO_ERROR}
28 END
29
30 Sleep 1s
31
32Get Port Current
33 [Documentation] Read usb port current
34
35 Log Read port current
36
37 FOR ${index} IN RANGE 0 4
38 ${current} Get port current acroname_aux ${index} mA
39 Log Current on port ${index} is ${current} mA
40 END
41
42 Sleep 1s
43
44Get Port Voltage
45 [Documentation] Read usb port voltage
46
47 Log Read port voltage
48
49 FOR ${index} IN RANGE 0 4
50 ${voltage} Get port voltage acroname_aux ${index} mV
51 Log Voltage on port ${index} is ${voltage} mV
52 END
53
54 Sleep 1s
55
56Set Port Current Limit
57 [Documentation] Set usb port current
58
59 Log Read port current
60
61 FOR ${index} IN RANGE 0 4
62 Log Set port current on port ${index} to 500 mA
63 ${state} Set port current limit acroname_aux ${index} ${500} mA
64 Should Be Equal ${state} ${NO_ERROR}
65 END
66
67 Sleep 1s
68
69Get Port Current Limit
70 [Documentation] Get usb port current limit
71
72 Log Read port current
73
74 FOR ${index} IN RANGE 0 4
75 ${current} Get port current limit acroname_aux ${index} mA
76 Log Port limit on port ${index} is ${current} mA
77 END
78
79 Sleep 1s
80
81Set Port Current Limit to max
82 [Documentation] Set usb port current limit
83
84 Log Read port current
85
86 FOR ${index} IN RANGE 0 4
87 Log Set port current on port ${index} to 1500 mA
88 ${state} Set port current limit acroname_aux ${index} ${1500} mA
89 Should Be Equal ${state} ${NO_ERROR}
90 END
91
92 Sleep 1s
To run the available example:
cd examples
robot robot_test_suite/test_instrument
Record Auxiliary
Auxiliary used to record a connectors receive channel which are configured in the yaml config. The library needs then only to be loaded. See example below:
config.yaml:
1auxiliaries:
2 record_aux:
3 connectors:
4 com: rtt_channel
5 config:
6 # When is_active is set, it actively polls the connector. It demands if
7 # the used connector needs to be polled actively.
8 is_active: False # False because rtt_channel has its own receive thread
9 type: pykiso.lib.auxiliaries.record_auxiliary:RecordAuxiliary
10
11connectors:
12 rtt_channel:
13 config:
14 chip_name: "STM12345678"
15 speed: 4000
16 block_address: 0x12345678
17 verbose: True
18 tx_buffer_idx: 1
19 rx_buffer_idx: 1
20 # Path relative to this yaml where the RTT logs should be written to.
21 # Creates a file named rtt.log
22 rtt_log_path: ./
23 # RTT channel from where the RTT logs should be read
24 rtt_log_buffer_idx: 0
25 # Manage RTT log CPU impact by setting logger speed. eg: 100% CPU load
26 # default: 1000 lines/s
27 rtt_log_speed: null
28 type: pykiso.lib.connectors.cc_rtt_segger:CCRttSegger
29
30test_suite_list:
31- suite_dir: test_record
32 test_filter_pattern: '*.py'
33 test_suite_id: 1
Robot file:
1*** Settings ***
2Documentation Robot framework Demo for record auxiliary
3
4# Library import will start recording
5Library pykiso.lib.robot_framework.record_auxiliary.RecordAuxiliary
6
7*** Keywords ***
8
9*** Test Cases ***
10
11Test Something
12 [Documentation] Record channel in the background
13
14 Sleep 5s
To run the available example:
cd examples
robot robot_test_suite/test_record/
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.
- class pykiso.lib.robot_framework.proxy_auxiliary.MpProxyAuxiliary[source]
Robot framework plugin for MpProxyAuxiliary.
Initialize attributes.
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