Added MAC verify on fwenv testcases
Changes:
-Configure Valid MAC And Verify
-Configure Invalid MAC And Verify on FW_Env
-Configure Valid MAC And Verify Persistency
-Configure Invalid MAC And Verify Persistency On FW_Env
-Added Validate MAC On FW_Env in test teardown
-Configure Out Of Range MAC And Verify
-Configure More Byte MAC And Verify
Keywords added:
-Get FW_Env MAC Address
-Truncate MAC Address
-Truncate MAC bits
-Validate MAC On FW_Env
-Verify MAC Address via FW_Env
Change-Id: Ie72fa551497bd27c9d1befb04f33e5b213e989c5
Signed-off-by: shrsuman123 <shrsuman@in.ibm.com>
diff --git a/lib/bmc_network_utils.robot b/lib/bmc_network_utils.robot
index 0bd6403..4a7d7ea 100644
--- a/lib/bmc_network_utils.robot
+++ b/lib/bmc_network_utils.robot
@@ -153,6 +153,24 @@
[Return] ${output}
+Get FW_Env MAC Address
+ [Documentation] Get FW_Env MAC address.
+
+ # Sample output of "fw_printenv | grep ethaddr"
+ # ethaddr=xx:xx:xx:xx:xx:xx:xx
+
+ ${cmd_output} ${stderr} ${rc}= BMC Execute Command
+ ... /sbin/fw_printenv | grep ethaddr
+
+ # Split the line and return MAC address.
+ # Split list data:
+ # ethaddr | xx:xx:xx:xx:xx:xx:xx
+
+ @{words}= Split String ${cmd_output} =
+
+ [Return] ${words[1]}
+
+
Get List Of IP Address Via REST
[Documentation] Get list of IP address via REST.
[Arguments] @{ip_uri_list}
@@ -249,10 +267,63 @@
# mac_addr MAC address of the BMC.
${system_mac}= Get BMC MAC Address
+ ${mac_new_addr}= Truncate MAC Address ${system_mac} ${mac_addr}
- ${status}= Compare MAC Address ${system_mac} ${mac_addr}
+ ${status}= Compare MAC Address ${system_mac} ${mac_new_addr}
Should Be True ${status}
- ... msg=MAC address ${system_mac} does not match ${mac_addr}.
+ ... msg=MAC address ${system_mac} does not match ${mac_new_addr}.
+
+Validate MAC On FW_Env
+ [Documentation] Validate MAC on FW_Env.
+ [Arguments] ${mac_addr}
+
+ # Description of argument(s):
+ # mac_addr MAC address of the BMC.
+
+ ${fw_env_addr}= Get FW_Env MAC Address
+ ${mac_new_addr}= Truncate MAC Address ${fw_env_addr} ${mac_addr}
+
+ ${status}= Compare MAC Address ${fw_env_addr} ${mac_new_addr}
+ Should Be True ${status}
+ ... msg=MAC address ${fw_env_addr} does not match ${mac_new_addr}.
+
+Truncate MAC Address
+ [Arguments] ${sys_mac_addr} ${user_mac_addr}
+ # Description of argument(s):
+ # sys_mac_addr MAC address of the BMC.
+ # user_mac_addr user provided MAC address.
+
+ ${mac_byte}= Set Variable ${0}
+ @{user_mac_list}= Split String ${user_mac_addr} :
+ @{sys_mac_list}= Split String ${sys_mac_addr} :
+ ${user_new_mac_list} Create List
+
+ # Truncate extra bytes and bits from MAC address
+ FOR ${mac_item} IN @{sys_mac_list}
+ ${invalid_mac_byte} = Get Regexp Matches ${user_mac_list}[${mac_byte}] [^A-Za-z0-9]+
+ Return From Keyword If ${invalid_mac_byte} ${user_mac_addr}
+ ${mac_int} = Convert To Integer ${user_mac_list}[${mac_byte}] 16
+ ${user_mac_len} = Get Length ${user_mac_list}
+ ${user_mac_byte}= Run Keyword IF ${mac_int} >= ${256} Truncate MAC Bits ${user_mac_list}[${mac_byte}]
+ ... ELSE Set Variable ${user_mac_list}[${mac_byte}]
+
+ Append To List ${user_new_mac_list} ${user_mac_byte}
+ ${mac_byte} = Set Variable ${mac_byte + 1}
+ Exit For Loop If '${mac_byte}' == '${user_mac_len}'
+
+ END
+ ${user_new_mac_string}= Evaluate ":".join(${user_new_mac_list})
+ [Return] ${user_new_mac_string}
+
+Truncate MAC Bits
+ [Arguments] ${user_mac_addr_byte}
+ # Description of argument(s):
+ # user_mac_addr_byte user provided MAC address byte to truncate bits
+
+ ${user_mac_addr_int}= Convert To List ${user_mac_addr_byte}
+ ${user_mac_addr_byte}= Get Slice From List ${user_mac_addr_int} 0 2
+ ${user_mac_addr_byte_string}= Evaluate "".join(${user_mac_addr_byte})
+ [Return] ${user_mac_addr_byte_string}
Run Build Net
diff --git a/redfish/managers/test_bmc_network_mac.robot b/redfish/managers/test_bmc_network_mac.robot
index 182f7ec..0f3ec5b 100644
--- a/redfish/managers/test_bmc_network_mac.robot
+++ b/redfish/managers/test_bmc_network_mac.robot
@@ -37,9 +37,9 @@
Configure MAC Settings ${valid_mac} valid
- # Verify whether new MAC is configured on BMC.
+ # Verify whether new MAC is configured on BMC and FW_Env.
Validate MAC On BMC ${valid_mac}
-
+ Verify MAC Address Via FW_Env ${valid_mac} valid
Configure Zero MAC And Verify
[Documentation] Configure zero MAC via Redfish and verify.
@@ -49,7 +49,6 @@
# MAC address scenario
${zero_mac} error
-
Configure Broadcast MAC And Verify
[Documentation] Configure broadcast MAC via Redfish and verify.
[Tags] Configure_Broadcast_MAC_And_Verify
@@ -75,17 +74,41 @@
# Verify whether new MAC is configured on BMC.
Validate MAC On BMC ${valid_mac}
- # Reboot BMC and check whether MAC is persistent.
+ # Reboot BMC and check whether MAC is persistent on BMC and FW_Env.
OBMC Reboot (off)
Validate MAC On BMC ${valid_mac}
+ Verify MAC Address Via FW_Env ${valid_mac} valid
+
+Configure Invalid MAC And Verify On FW_Env
+ [Documentation] Configure Invalid MAC via Redfish and verify on FW_Env.
+ [Tags] Configure_Invalid_MAC_And_Verify_On_FW_Env
+
+ [Template] Configure MAC Settings
+
+ # invalid_MAC scenario
+ ${zero_mac} error
+ ${broadcast_mac} error
+ ${special_char_mac} error
+ ${less_byte_mac} error
+
+ Configure Invalid MAC And Verify Persistency On FW_Env
+ [Documentation] Configure invalid MAC and verify persistency on FW_Env.
+ [Tags] Configure_Invalid_MAC_And_Verify_Persistency_On_FW_Env
+
+ Configure MAC Settings ${special_char_mac} error
+
+ # Reboot BMC and check whether MAC is persistent on FW_Env.
+ OBMC Reboot (off)
+ Verify MAC Address Via FW_Env ${special_char_mac} error
Configure Out Of Range MAC And Verify
[Documentation] Configure out of range MAC via Redfish and verify.
[Tags] Configure_Out_Of_Range_MAC_And_Verify
- [Template] Configure MAC Settings
- # MAC address scenario
- ${out_of_range_mac} error
+ Configure MAC Settings ${out_of_range_mac} valid
+
+ # Verify whether new MAC is configured on FW_Env.
+ Verify MAC Address Via FW_Env ${out_of_range_mac} valid
Configure Less Byte MAC And Verify
[Documentation] Configure less byte MAC via Redfish and verify.
@@ -99,9 +122,9 @@
[Documentation] Configure more byte MAC via Redfish and verify.
[Tags] Configure_More_Byte_MAC_And_Verify
- [Template] Configure MAC Settings
- # MAC address scenario
- ${more_byte_mac} error
+ Configure MAC Settings ${more_byte_mac} valid
+ # Verify whether new MAC is configured on FW_Env.
+ Verify MAC Address Via FW_Env ${more_byte_mac} valid
*** Keywords ***
@@ -111,8 +134,9 @@
# Revert to initial MAC address.
Configure MAC Settings ${initial_mac_address} valid
- # Verify whether new MAC is configured on BMC.
+ # Verify whether new MAC is configured on BMC and FW_Env.
Validate MAC On BMC ${initial_mac_address}
+ Validate MAC On Fw_Env ${initial_mac_address}
FFDC On Test Case Fail
Redfish.Logout
@@ -159,7 +183,6 @@
# Verify whether new MAC address is populated on BMC system.
# It should not allow to configure invalid settings.
-
${status}= Run Keyword And Return Status
... Validate MAC On BMC ${mac_address}
@@ -170,3 +193,24 @@
... Should Be Equal ${status} ${True}
... msg=Not allowing the configuration of a valid MAC.
+ Verify MAC Address Via FW_Env ${mac_address} ${expected_result}
+
+Verify MAC Address Via FW_Env
+ [Documentation] Verify MAC address on FW_Env.
+ [Arguments] ${mac_address} ${expected_result}
+
+ # Description of argument(s):
+ # mac_address MAC address of BMC.
+ # expected_result Expected status of MAC configuration.
+
+ ${status}= Run Keyword And Return Status
+ ... Validate MAC On FW_Env ${mac_address}
+
+ Run Keyword If '${expected_result}' == 'error'
+ ... Should Be Equal ${status} ${False}
+ ... msg=Allowing the configuration of an invalid MAC.
+ ... ELSE
+ ... Should Be Equal ${status} ${True}
+ ... msg=Not allowing the configuration of a valid MAC.
+
+