PLDM: Automate test scenarios for pldmtool commands - phase 1
Test scenarios:
- Verify GetDateTime
- Verify SetDateTime
Resolves openbmc-test-automation/issues/#1998
Change-Id: I7b302a30f37041cef87c53560004cdd900c897a8
Signed-off-by: Sridevi Ramesh <sridevra@in.ibm.com>
diff --git a/data/pldm_variables.py b/data/pldm_variables.py
index b2e9e6e..b7447af 100755
--- a/data/pldm_variables.py
+++ b/data/pldm_variables.py
@@ -4,6 +4,7 @@
Contains PLDM-related constants.
"""
+PLDM_SUPPORTED_TYPES = ['base', 'platform', 'bios']
# PLDM types.
PLDM_TYPE_BASE = {'VALUE': '00', 'STRING': 'base'}
@@ -83,8 +84,6 @@
# PLDM command format.
-CMD_GETPLDMTYPES = 'base GetPLDMTypes'
-
'''
e.g. : GetPLDMVersion usage
@@ -114,4 +113,10 @@
' 0x00 0x00 0x00 0x00 0x%s 0x%s' # %(TransferOperationFlag, PLDMType)
-PLDM_SUPPORTED_TYPES = ['base', 'platform', 'bios']
+'''
+e.g. : SetDateTime usage
+
+pldmtool bios SetDateTime -d <YYYYMMDDHHMMSS>
+
+'''
+CMD_SETDATETIME = 'bios SetDateTime -d %s'
diff --git a/lib/pldm_utils.py b/lib/pldm_utils.py
index a6a8aee..513e3f3 100644
--- a/lib/pldm_utils.py
+++ b/lib/pldm_utils.py
@@ -52,7 +52,6 @@
bsu_options = fa.args_to_objects(bsu_options)
stdout, stderr, rc = bsu.bmc_execute_command('pldmtool ' + option_string, **bsu_options)
-
if parse_results:
# Remove linefeeds following colons.
stdout = re.sub(":\n", ":", stdout)
@@ -69,6 +68,10 @@
supported_types['raw'].append(record[0])
supported_types['text'].append(record[1].rstrip(")"))
result['supported_types'] = supported_types
+
+ if 'date_&_time' in result:
+ return result['yyyy-mm-dd_hh'].split(' - ')[1]
+
return result
return stdout
diff --git a/pldm/test_pldm_bios.robot b/pldm/test_pldm_bios.robot
new file mode 100644
index 0000000..7c66a6d
--- /dev/null
+++ b/pldm/test_pldm_bios.robot
@@ -0,0 +1,71 @@
+*** Settings ***
+
+Documentation Module to test PLDM BIOS commands.
+
+Library Collections
+Library String
+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
+Suite Teardown PLDM BIOS Suite Cleanup
+
+*** Test Cases ***
+
+Verify GetDateTime
+
+ [Documentation] Verify host date & time.
+ [Tags] Verify_GetDateTime
+
+ # Example output:
+ # YYYY-MM-DD HH:MM:SS - 09-02-2020 16:51:23
+
+ ${pldm_output}= Pldmtool bios GetDateTime
+ @{date_time}= Split String ${pldm_output} ${SPACE}
+ @{time}= Split String ${date_time}[1] :
+
+ # verify date & time.
+ ${current_date_time}= Get Current Date UTC exclude_millis=True
+ Should Contain ${current_date_time} ${date_time[0]}
+ Should Contain ${current_date_time} ${time[0]}
+
+
+Verify SetDateTime
+
+ [Documentation] Verify set date & time for the host.
+ [Tags] Verify_SetDateTime
+
+ # Example output:
+ # SetDateTime: SUCCESS
+
+ ${current_date_time}= Get Current Date UTC exclude_millis=True
+
+ ${date}= Add Time To Date ${current_date_time} 400 days exclude_millis=True
+ ${upgrade_date}= Evaluate re.sub(r'-* *:*', "", '${date}') modules=re
+
+ ${time}= Add Time To Date ${current_date_time} 01:01:00 exclude_millis=True
+ ${upgrade_time}= Evaluate re.sub(r'-* *:*', "", '${time}') modules=re
+
+ # Set date.
+ ${cmd_set_date}= Evaluate $CMD_SETDATETIME % '${upgrade_date}'
+ ${pldm_output}= Pldmtool ${cmd_set_date}
+ Valid Value pldm_output['setdatetime'] 'SUCCESS'
+
+ # Set time.
+ ${cmd_set_time}= Evaluate $CMD_SETDATETIME % '${upgrade_time}'
+ ${pldm_output}= Pldmtool ${cmd_set_time}
+ Valid Value pldm_output['setdatetime'] 'SUCCESS'
+
+*** Keywords ***
+
+PLDM BIOS Suite Cleanup
+
+ [Documentation] Perform pldm BIOS suite cleanup.
+
+ ${result}= Get Current Date UTC exclude_millis=True
+ ${current_date_time}= Evaluate re.sub(r'-* *:*', "", '${result}') modules=re
+ ${cmd_set_date_time}= Evaluate $CMD_SETDATETIME % '${current_date_time}'
+ ${pldm_output}= Pldmtool ${cmd_set_date_time}
+ Valid Value pldm_output['setdatetime'] 'SUCCESS'