Test suite to verify BIOS POST code log entries

Changes:
      - Create new suite to test BIOS POST codes
      - Added new keywords to support clear and GET BIOS PostCode
      - Added 1 test case to verify PostCode when system boots.

Note:  This is just a single test and basic infrastructure to test
       BIOS POST code.

Tested: Ran successfully redfish/systems/LogServices/test_post_codes.robot
Change-Id: I579daa523db2ebf18e3b527067c03d820ec068fc
Signed-off-by: George Keishing <gkeishin@in.ibm.com>
diff --git a/lib/logging_utils.robot b/lib/logging_utils.robot
index 16222a6..84104a7 100644
--- a/lib/logging_utils.robot
+++ b/lib/logging_utils.robot
@@ -315,3 +315,39 @@
 
     ${elogs}=  Get Event Logs
     Should Be Empty  ${elogs}  msg=System event log entry is not empty.
+
+
+Redfish Clear PostCodes
+    [Documentation]  Do Redfish PostCodes purge from system.
+
+    ${target_action}=  redfish_utils.Get Target Actions
+    ...  /redfish/v1/Systems/system/LogServices/PostCodes/  LogService.ClearLog
+    Redfish.Post  ${target_action}  body={'target': '${target_action}'}
+    ...  valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
+
+
+Redfish Get PostCodes
+    [Documentation]  Perform Redfish GET request and return the PostCodes entries as a list of dictionaries.
+
+    # Formatted example output from Rprint vars  members
+    # members:
+    #  [0]:
+    #    [@odata.id]:               /redfish/v1/Systems/system/LogServices/PostCodes/Entries/B1-1
+    #    [@odata.type]:             #LogEntry.v1_8_0.LogEntry
+    #    [AdditionalDataURI]:       /redfish/v1/Systems/system/LogServices/PostCodes/Entries/B1-1/attachment
+    #    [Created]:                 2022-08-06T04:38:10+00:00
+    #    [EntryType]:               Event
+    #    [Id]:                      B1-1
+    #    [Message]:                 Message": "Boot Count: 4: TS Offset: 0.0033; POST Code: 0x43
+    #    [MessageArgs]:
+    #      [0]:                    4
+    #      [1]:                    0.0033
+    #      [2]:                    0x43
+    #    [MessageId]:              OpenBMC.0.2.BIOSPOSTCodeASCII
+    #    [Name]:                   POST Code Log Entry
+    #    [Severity]:               OK
+
+    ${members}=  Redfish.Get Attribute  /redfish/v1/Systems/system/LogServices/PostCodes/Entries  Members
+    ...  valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
+
+    [Return]  ${members}
diff --git a/redfish/systems/LogServices/test_post_codes.robot b/redfish/systems/LogServices/test_post_codes.robot
new file mode 100644
index 0000000..4a432d6
--- /dev/null
+++ b/redfish/systems/LogServices/test_post_codes.robot
@@ -0,0 +1,61 @@
+*** Settings ***
+Documentation    Test suite to verify BIOS POST code log entries.
+
+Resource         ../../../lib/resource.robot
+Resource         ../../../lib/bmc_redfish_resource.robot
+Resource         ../../../lib/openbmc_ffdc.robot
+Resource         ../../../lib/logging_utils.robot
+
+Suite Setup      Suite Setup Execution
+Test Setup       Test Setup Execution
+Test Teardown    Test Teardown Execution
+Suite Teardown   Suite Teardown Execution
+
+*** Test Cases ***
+
+Test PostCodes When Host Boots
+    [Documentation]  Boot the system and verify PostCodes from host are logged.
+    [Tags]  Test_PostCodes_When_Host_Boots
+
+    Redfish Power On
+    ${post_code_list}=  Redfish Get PostCodes
+    Rprint Vars  post_code_list
+
+    ${post_codes}=  Redfish.Get Properties
+    ...  /redfish/v1/Systems/system/LogServices/PostCodes/Entries
+    Log To Console  BIOS POST Codes count: ${post_codes['Members@odata.count']}
+    Should Be True  ${post_codes['Members@odata.count']} >= 1  msg=No BIOS POST Codes populated.
+
+
+*** Keywords ***
+
+Test Setup Execution
+    [Documentation]  Do test setup operation.
+
+    Redfish.Login
+    Redfish Clear PostCodes
+
+
+Test Teardown Execution
+    [Documentation]  Do test teardown operation.
+
+    FFDC On Test Case Fail
+
+
+Suite Setup Execution
+    [Documentation]  Do suite setup operation.
+
+    Redfish.Login
+    Redfish Power Off  stack_mode=skip
+
+    Run Keyword And Ignore Error  Redfish Delete All BMC Dumps
+    Run Keyword And Ignore Error  Redfish Purge Event Log
+    Run Keyword And Ignore Error  Delete All Redfish Sessions
+
+
+Suite Teardown Execution
+    [Documentation]  Do suite teardown operation.
+
+    Run Keyword And Ignore Error  Redfish Delete All BMC Dumps
+    Run Keyword And Ignore Error  Redfish Purge Event Log
+    Run Keyword And Ignore Error  Delete All Redfish Sessions