1*** Settings ***
2Documentation   This suite tests Platform Event Log (PEL) functionality of OpenBMC.
3
4Library         ../../lib/pel_utils.py
5Resource        ../../lib/openbmc_ffdc.robot
6
7Test Setup      Redfish.Login
8Test Teardown   Run Keywords  Redfish.Logout  AND  FFDC On Test Case Fail
9
10
11*** Variables ***
12
13${CMD_INTERNAL_FAILURE}  busctl call xyz.openbmc_project.Logging /xyz/openbmc_project/logging
14...  xyz.openbmc_project.Logging.Create Create ssa{ss} xyz.openbmc_project.Common.Error.InternalFailure
15...  xyz.openbmc_project.Logging.Entry.Level.Error 0
16
17
18*** Test Cases ***
19
20Create Test PEL Log And Verify
21    [Documentation]  Create PEL log using busctl command and verify via peltool.
22    [Tags]  Create_Test_PEL_Log_And_Verify
23
24    Redfish Purge Event Log
25    Create Test PEL Log
26    ${pel_id}=  Get PEL Log Via BMC CLI
27    Should Not Be Empty  ${pel_id}  msg=System PEL log entry is empty.
28
29
30Verify PEL Log Persistence After BMC Reboot
31    [Documentation]  Verify PEL log persistence after BMC reboot.
32    [Tags]  Verify_PEL_Log_Persistence_After_BMC_Reboot
33
34    Create Test PEL Log
35    ${pel_before_reboot}=  Get PEL Log Via BMC CLI
36
37    Redfish OBMC Reboot (off)
38    ${pel_after_reboot}=  Get PEL Log Via BMC CLI
39
40    List Should Contain Sub List  ${pel_after_reboot}  ${pel_before_reboot}
41
42
43Verify PEL ID Numbering
44    [Documentation]  Verify PEL ID numbering.
45    [Tags]  Verify_PEL_ID_Numbering
46
47    Redfish Purge Event Log
48    Create Test PEL Log
49    Create Test PEL Log
50
51    ${pel_ids}=  Get PEL Log Via BMC CLI
52
53    # Example of PEL IDs from PEL logs.
54    #  [0x50000012]:             <--- First PEL ID
55    #    [CreatorID]:                  BMC
56    #    [CompID]:                     0x1000
57    #    [PLID]:                       0x50000012
58    #    [Subsystem]:                  BMC Firmware
59    #    [Message]:                    An application had an internal failure
60    #    [SRC]:                        BD8D1002
61    #    [Commit Time]:                03/02/2020  09:35:15
62    #    [Sev]:                        Unrecoverable Error
63    #
64    #  [0x50000013]:             <--- Second PEL ID
65    #    [CreatorID]:                  BMC
66    #    [CompID]:                     0x1000
67    #    [PLID]:                       0x50000013
68    #    [Subsystem]:                  BMC Firmware
69    #    [Message]:                    An application had an internal failure
70    #    [SRC]:                        BD8D1002
71    #    [Commit Time]:                03/02/2020  09:35:15
72    #    [Sev]:                        Unrecoverable Error
73
74    Should Be True  ${pel_ids[1]} == ${pel_ids[0]}+1
75
76
77*** Keywords ***
78
79Create Test PEL Log
80    [Documentation]  Generate test PEL log.
81
82    # Test PEL log entry example:
83    # {
84    #    "0x5000002D": {
85    #            "SRC": "BD8D1002",
86    #            "Message": "An application had an internal failure",
87    #            "PLID": "0x5000002D",
88    #            "CreatorID": "BMC",
89    #            "Subsystem": "BMC Firmware",
90    #            "Commit Time": "02/25/2020  04:47:09",
91    #            "Sev": "Unrecoverable Error",
92    #            "CompID": "0x1000"
93    #    }
94    # }
95
96    BMC Execute Command  ${CMD_INTERNAL_FAILURE}
97
98
99Get PEL Log Via BMC CLI
100    [Documentation]  Returns the list of PEL IDs using BMC CLI.
101
102    ${pel_records}=  Peltool  -l
103    ${ids}=  Get Dictionary Keys  ${pel_records}
104
105    [Return]  ${ids}
106