Add cases to verify SEL action via IPMI

Add test cases to verify add SEL entry and reserve SEL via IPMI.

Signed-off-by: Tony Lee <tony.lee@quantatw.com>
Change-Id: I9b6cd6602bd9d2601774ad623157f4c48f0bfe85
diff --git a/data/ipmi_raw_cmd_table.py b/data/ipmi_raw_cmd_table.py
index 3d3dd65..4e1c811 100644
--- a/data/ipmi_raw_cmd_table.py
+++ b/data/ipmi_raw_cmd_table.py
@@ -71,5 +71,22 @@
             "dc",
             "Disable nibble position 6th LSB e.g. 0x00",
         ]
+    },
+    'SEL_entry':
+    {
+        'Add':
+        [
+            # raw command, expected output, comment
+            "0x0a 0x44 0x00 0x00 0x02 0x00 0x00 0x00 0x00 0x00 0x00 0x04 0x01 0x17 0x00 0xa0 0x04 0x07",
+            "02 00",
+            "02 00 is Record ID for added record, LS Byte first",
+        ],
+        'Reserve':
+        [
+            # raw command, expected output, comment
+            "0x0a 0x42",
+            "27 00",
+            "27 is Reservation ID, LSB, 00 Reservation ID, MSB ",
+        ]
     }
 }
diff --git a/ipmi/test_ipmi_sel.robot b/ipmi/test_ipmi_sel.robot
index e740b3a..aefe21b 100644
--- a/ipmi/test_ipmi_sel.robot
+++ b/ipmi/test_ipmi_sel.robot
@@ -3,9 +3,11 @@
 Documentation    Module to test IPMI SEL functionality.
 Resource         ../lib/ipmi_client.robot
 Resource         ../lib/openbmc_ffdc.robot
+Variables        ../data/ipmi_raw_cmd_table.py
 
 Test Teardown    FFDC On Test Case Fail
 
+
 *** Test Cases ***
 
 Verify IPMI SEL Version
@@ -27,3 +29,44 @@
     ${resp}=  Run IPMI Standard Command  sel list
     Should Contain  ${resp}  SEL has no entries  case_insensitive=True
 
+
+Verify Add SEL Entry
+    [Documentation]  Verify add SEL entry.
+    [Tags]  Verify_Add_SEL_Entry
+    [Teardown]  Run Keywords  FFDC On Test Case Fail  AND  Run IPMI Standard Command  sel clear
+
+    Run IPMI Standard Command  sel clear
+    Sleep  5s
+
+    Create SEL
+    # Get last SEL entry.
+    ${resp}=  Run IPMI Standard Command  sel elist last 1
+    Run Keywords  Should Contain  ${resp}  Temperature #0x17  AND
+    ...  Should Contain  ${resp}  Asserted
+    ...  msg=Add SEL Entry failed.
+
+
+Verify Reserve SEL
+    [Documentation]  Verify reserve SEL.
+    [Tags]  Verify_Reserve_SEL
+
+    ${resp}=  Run IPMI Standard Command
+    ...  raw ${IPMI_RAW_CMD['SEL_entry']['Reserve'][0]}
+    ${reserve_id}=  Split String  ${resp}
+
+    # Execute clear SEL raw command with Reservation ID.
+    # Command will not execute unless the correct Reservation ID value is provided.
+    Run IPMI Standard Command
+    ...  raw 0x0a 0x47 0x${reserve_id[0]} 0x${reserve_id[1]} 0x43 0x4c 0x52 0xaa
+
+
+*** Keywords ***
+
+Create SEL
+    [Documentation]  Create a SEL.
+
+    # Create a SEL.
+    # Example:
+    # a | 02/14/2020 | 01:16:58 | Temperature #0x17 |  | Asserted
+    Run IPMI Standard Command
+    ...  raw ${IPMI_RAW_CMD['SEL_entry']['Add'][0]}