Issue 195: SLP Service Discovery Verification
This change addresses:
1. Find service types request
2. Find service agents
Resolves issue openbmc/openbmc-test-automation#195
Change-Id: I52e3aaaf0a350665715c173a41b5b4042148d7cb
Signed-off-by: Prashanth Katti <prkatti1@in.ibm.com>
diff --git a/extended/test_slp.robot b/extended/test_slp.robot
new file mode 100644
index 0000000..d6ccd3d
--- /dev/null
+++ b/extended/test_slp.robot
@@ -0,0 +1,81 @@
+*** Settings ***
+Documentation Find services and service agents on the system.
+Library OperatingSystem
+Library Collections
+Library String
+
+Resource ../lib/utils.robot
+
+# Get the SLP services available, make it suite global.
+Suite Setup Get Service Types Output
+
+*** Variables ***
+${service_types} findsrvtypes
+${service_agents} findsrvs
+${service_path} /etc/slp/services
+# SLP_SERVICES Services listed by slptool, by default Empty.
+${SLP_SERVICES} ${EMPTY}
+
+*** Test Cases ***
+
+Verify SLP Service Types
+ [Documentation] Find services supported by system.
+ [Tags] Verify_SLP_Service_Types
+ Verify Service Types
+
+Verify Service Agents For Service Types
+ [Documentation] Find And verify service agents.
+ [Tags] Verify_Service_Agents_For_Service_Types
+ @{parameters}= Split String ${SLP_SERVICES} ${\n}
+ :FOR ${parameter} IN @{parameters}
+ \ ${output}= Run SLP command ${service_agents} ${parameter}
+ \ Verify Service Agents ${output} ${parameter}
+
+*** Keywords ***
+
+Get Service Types Output
+ [Documentation] Get SLP services.
+ ${output}= Run which slptool
+ Should Not Be Empty ${output}
+ ... msg=slptool not installed.
+ ${SLP_SERVICES}= Run SLP command ${service_types}
+ Set Suite Variable ${SLP_SERVICES}
+
+Run SLP Command
+ [Documentation] Run SLPTool command and return output.
+ [Arguments] ${cmd} ${param}=${EMPTY}
+ # cmd The SLP command to be run.
+ # param The SLP command parameters.
+
+ ${rc} ${output}= Run And Return Rc And Output
+ ... slptool -u ${OPENBMC_HOST} ${cmd} ${param}
+ Should Be Equal As Integers ${rc} 0
+ [Return] ${output}
+
+Verify Service Types
+ [Documentation] Verifies the output of service types.
+
+ ${remove_prefix}= Remove String ${SLP_SERVICES} service:
+ @{services}= Split String ${remove_prefix} ${\n}
+ ${service_count}= Get Length ${services}
+ Open Connection And Log In
+ ${stdout} ${stderr}= Execute Command ls ${service_path}
+ ... return_stderr=True
+ Should Be Empty ${stderr}
+ ${file_count}= Get Line Count ${stdout}
+ Should Be Equal ${service_count} ${file_count}
+ ... msg=Number of services on system & command are not equal.
+ :FOR ${service} IN @{services}
+ \ Should Contain ${stdout} ${service}
+ ... msg=Services on system & command are not same.
+
+Verify Service Agents
+ [Documentation] Verifies the output of srvs.
+ [Arguments] ${output} ${service_agent}
+ # Example of output
+ # <service:service_name:tcp//xxx.xxx.xxx.xxx,2200>
+
+ Run Keywords Should Contain ${output} ${service_agent} AND
+ ... Should Contain ${output} ${OPENBMC_HOST},
+ ... msg=Expected process info missing.
+