PLDM: Automate Test Scenarios for pldm commands
- Verify GetPDR
- Verify SetStateEffecterStates
- Verify GetTID
- Verify GetBIOSTable For StringTable
- Verify GetFruRecordTableMetadata
Note: Ouput for GetBIOSTable type stringtable is dynamic
will submit the verification part in the next commit.
Change-Id: I422c2df4485ac25d6ff4183bd51b5ddc6c3bf3cc
Signed-off-by: Sridevi Ramesh <sridevra@in.ibm.com>
Signed-off-by: George Keishing <gkeishin@in.ibm.com>
diff --git a/data/pldm_variables.py b/data/pldm_variables.py
index 1c030b3..d836b4d 100755
--- a/data/pldm_variables.py
+++ b/data/pldm_variables.py
@@ -120,3 +120,70 @@
'''
CMD_SETDATETIME = 'bios SetDateTime -d %s'
+
+
+CMD_GETPDR = 'platform GetPDR -d %s'
+
+'''
+e.g. : SetStateEffecterStates usage
+
+pldmtool platform GetPDR -d <effecterID, requestSet, effecterState>
+
+pldmtool platform SetStateEffecterStates -d 1 1 1
+
+'''
+
+CMD_SETSTATEEFFECTERSTATES = 'platform SetStateEffecterStates -d %s'
+
+# GetPDR parsed response message for record handle.
+# Dictionary value array holds the expected output for record handle 1, 2.
+# e.g. : 'nextrecordhandle': ['0', '2']
+#
+# Note :
+# Record handle - 0 is default & has same behaviour as record handle 1
+# Only record handle 0, 1, 2 are supported as of now.
+
+RESPONSE_DICT_GETPDR = {
+ 'nextrecordhandle': ['0', '2'],
+ 'responsecount': ['29', '30'],
+ 'recordhandle': ['1', '2'],
+ 'pdrheaderversion': ['1'],
+ 'pdrtype': ['11'],
+ 'recordchangenumber': ['0'],
+ 'datalength': ['19', '20'],
+ 'pldmterminushandle': ['0'],
+ 'effecterid': ['1', '2'],
+ 'entitytype': ['33', '45'],
+ 'entityinstancenumber': ['0'],
+ 'containerid': ['0'],
+ 'effectersemanticid': ['0'],
+ 'effecterinit': ['0'],
+ 'effecterdescriptionpdr': ['false'],
+ 'compositeeffectercount': ['1'],
+ 'statesetid': ['196', '260'],
+ 'possiblestatessize': ['1', '2'],
+ 'possiblestates': ['6', '0']}
+
+RESPONSE_DICT_GETFRURECORDTABLEMETADATA = {
+ 'frudatamajorversion': ['1'],
+ 'frudataminorversion': ['0'],
+ 'frutablemaximumsize': ['4294967295'],
+ 'frutablelength': ['60'],
+ 'total_number_of_record_set_identifiers_in_table': ['1'],
+ 'total_number_of_records_in_table': ['1']}
+
+RESPONSE_DICT_GETBIOSTABLE_STRTABLE = {
+ 'biosstringhandle': ['BIOSString'],
+ '0': ['Allowed'],
+ '1': ['Disabled'],
+ '2': ['Enabled'],
+ '3': ['Not Allowed'],
+ '4': ['Perm'],
+ '5': ['Temp'],
+ '6': ['pvm-fw-boot-side'],
+ '7': ['pvm-inband-code-update'],
+ '8': ['pvm-os-boot-side'],
+ '9': ['pvm-pcie-error-inject'],
+ '10': ['pvm-surveillance'],
+ '11': ['pvm-system-name'],
+ '12': ['vmi-if-count']}
diff --git a/lib/pldm_utils.py b/lib/pldm_utils.py
index 513e3f3..7367932 100644
--- a/lib/pldm_utils.py
+++ b/lib/pldm_utils.py
@@ -57,6 +57,7 @@
stdout = re.sub(":\n", ":", stdout)
# Remove first line (e.g. "Encode request successfully").
stdout = re.sub("^.*\\n", "", stdout)
+ stdout = re.sub('\x00', "", stdout)
result = vf.key_value_outbuf_to_dict(stdout)
if 'supported_types' in result:
# 'supported types' begins like this:
@@ -68,9 +69,16 @@
supported_types['raw'].append(record[0])
supported_types['text'].append(record[1].rstrip(")"))
result['supported_types'] = supported_types
-
- if 'date_&_time' in result:
+ elif 'date_&_time' in result:
+ # Date & Time :
+ # YYYY-MM-DD HH:MM:SS - 2020-02-24 06:44:16
return result['yyyy-mm-dd_hh'].split(' - ')[1]
+ elif 'parsed_response_msg' in result:
+ dict_data1, dict_data2 = vf.split_dict_on_key('parsed_response_msg', result)
+ dict_data2.pop('parsed_response_msg')
+ if 'fru_datastructuretableintegritychecksum' in dict_data2:
+ dict_data2.pop('fru_datastructuretableintegritychecksum')
+ return dict_data2
return result
diff --git a/pldm/test_pldm_base.robot b/pldm/test_pldm_base.robot
index d7f8dac..0d05182 100644
--- a/pldm/test_pldm_base.robot
+++ b/pldm/test_pldm_base.robot
@@ -10,7 +10,6 @@
*** Test Cases ***
-
Verify Get PLDM Types
[Documentation] Verify supported PLDM types.
[Tags] Verify_Get_PLDM_Types
@@ -53,3 +52,15 @@
${pldm_cmd}= Evaluate $CMD_GETPLDMVERSION % 'fru'
${pldm_output}= Pldmtool ${pldm_cmd}
Valid Value pldm_output['type_4(fru)'] ['${VERSION_FRU['STRING']}']
+
+Verify GetTID
+ [Documentation] Verify GetTID (Terminus ID) response message.
+ [Tags] Verify_GetTID
+
+ # Example output:
+ # TID : 1
+
+ ${pldm_output}= Pldmtool base GetTID
+ Rprint Vars pldm_output
+
+ Valid Dict pldm_output valid_values={'tid': ['1']}
diff --git a/pldm/test_pldm_bios.robot b/pldm/test_pldm_bios.robot
index 0413e16..ef02930 100644
--- a/pldm/test_pldm_bios.robot
+++ b/pldm/test_pldm_bios.robot
@@ -15,7 +15,6 @@
*** Test Cases ***
Verify GetDateTime
-
[Documentation] Verify host date & time.
[Tags] Verify_GetDateTime
@@ -33,7 +32,6 @@
Verify SetDateTime
-
[Documentation] Verify set date & time for the host.
[Tags] Verify_SetDateTime
@@ -58,10 +56,35 @@
${pldm_output}= Pldmtool ${cmd_set_time}
Valid Value pldm_output['setdatetime'] ['SUCCESS']
+
+Verify GetBIOSTable For StringTable
+ [Documentation] Verify GetBIOSTable for table type string table.
+ [Tags] Verify_GetBIOSTable_For_StringTable
+
+ # pldm_output:
+ # [biosstringhandle]: BIOSString
+ # [0]: Allowed
+ # [1]: Disabled
+ # [2]: Enabled
+ # [3]: Not Allowed
+ # [4]: Perm
+ # [5]: Temp
+ # [6]: pvm-fw-boot-side
+ # [7]: pvm-inband-code-update
+ # [8]: pvm-os-boot-side
+ # [9]: pvm-pcie-error-inject
+ # [10]: pvm-surveillance
+ # [11]: pvm-system-name
+ # [12]: vmi-if-count
+
+ ${pldm_output}= Pldmtool bios GetBIOSTable -t 0
+ Rprint Vars pldm_output
+ # TODO: Implement verification for GetBIOSTable response message.
+ # Valid Dict pldm_output valid_values=${RESPONSE_DICT_GETBIOSTABLE_STRTABLE}
+
*** Keywords ***
PLDM BIOS Suite Cleanup
-
[Documentation] Perform pldm BIOS suite cleanup.
${result}= Get Current Date UTC exclude_millis=True
diff --git a/pldm/test_pldm_fru.robot b/pldm/test_pldm_fru.robot
new file mode 100644
index 0000000..00a0fc3
--- /dev/null
+++ b/pldm/test_pldm_fru.robot
@@ -0,0 +1,28 @@
+*** Settings ***
+
+Documentation Module to test PLDM FRU (Field Replaceable Unit) commands.
+
+Library ../lib/pldm_utils.py
+Variables ../data/pldm_variables.py
+Resource ../lib/openbmc_ffdc.robot
+
+Test Setup Printn
+Test Teardown FFDC On Test Case Fail
+
+*** Test Cases ***
+
+Verify GetFruRecordTableMetadata
+ [Documentation] Verify get fru record table meta data reponse message.
+ [Tags] Verify_GetFruRecordTableMetadata
+
+ # pldm_output:
+ # [frutablelength]: 60
+ # [frudatamajorversion]: 1
+ # [total_number_of_record_set_identifiers_in_table]: 1
+ # [frudataminorversion]: 0
+ # [total_number_of_records_in_table]: 1
+ # [frutablemaximumsize]: 4294967295
+
+ ${pldm_output}= Pldmtool fru GetFruRecordTableMetadata
+ Rprint Vars pldm_output
+ Valid Dict pldm_output valid_values=${RESPONSE_DICT_GETFRURECORDTABLEMETADATA}
diff --git a/pldm/test_pldm_platform.robot b/pldm/test_pldm_platform.robot
new file mode 100644
index 0000000..c85b847
--- /dev/null
+++ b/pldm/test_pldm_platform.robot
@@ -0,0 +1,83 @@
+*** Settings ***
+
+Documentation Module to test PLDM platform commands.
+
+Library ../lib/pldm_utils.py
+Variables ../data/pldm_variables.py
+Resource ../lib/openbmc_ffdc.robot
+
+Test Setup Printn
+Test Teardown FFDC On Test Case Fail
+
+*** Test Cases ***
+
+Verify GetPDR
+ [Documentation] Verify GetPDR (Platform Descpritor Record) response message.
+ [Tags] Verify_GetPDR
+ [Template] Verify GetPDR For Record Handle
+
+ # RecordHandle
+ '0'
+ '1'
+ '2'
+
+
+Verify SetStateEffecterStates
+ [Documentation] Verify set state effecter states response message.
+ [Tags] Verify_SetStateEffecterStates
+ [Template] Verify SetStateEffecterStates For Effecter States
+
+ # EffecterStates (effecterID requestSet effecterState)
+ '1 1 1'
+ '1 1 2'
+
+*** Keywords ***
+
+Verify GetPDR For Record Handle
+ [Documentation] Verify GetPDR (Platform Descpritor Record) for given input record handle.
+ [Arguments] ${record_handle}
+
+ # Description of argument(s):
+ # ${record_handle} Record handle (e.g. '1').
+
+ # pldm_output:
+ # [responseCount]: 29
+ # [recordHandle]: 1
+ # [PDRHeaderVersion]: 1
+ # [PDRType]: 11
+ # [recordChangeNumber]: 0
+ # [dataLength]: 19
+ # [PLDMTerminusHandle]: 0
+ # [effecterID]: 1
+ # [entityType]: 33
+ # [entityInstanceNumber]: 0
+ # [containerID]: 0
+ # [effecterSemanticID]: 0
+ # [effecterInit]: 0
+ # [effecterDescriptionPDR]: false
+ # [compositeEffecterCount]: 1
+ # [stateSetID]: 196
+ # [possibleStatesSize]: 1
+ # [possibleStates]: 6
+
+ ${pldm_cmd}= Evaluate $CMD_GETPDR % ${record_handle}
+ ${pldm_output}= Pldmtool ${pldm_cmd}
+ Rprint Vars pldm_output
+ Valid Dict pldm_output valid_values=${RESPONSE_DICT_GETPDR}
+
+
+Verify SetStateEffecterStates For Effecter States
+ [Documentation] Verify set state effecter states for given input effecter states.
+ [Arguments] ${effecter_states}
+
+ # Description of argument(s):
+ # ${effecter_states} (effecterID requestSet effecterState).
+ # e.g. '1 1 1'.
+
+ # Example output:
+ # SetStateEffecterStates ]: SUCCESS
+
+ ${pldm_cmd}= Evaluate $CMD_SETSTATEEFFECTERSTATES % ${effecter_states}
+ ${pldm_output}= Pldmtool ${pldm_cmd}
+ Rprint Vars pldm_output
+ Valid Value pldm_output['setstateeffecterstates'] ['SUCCESS']