xref: /openbmc/openbmc-test-automation/security/test_slp.robot (revision 44421de6af40b3e57ee59a89e44a53205b42a158)
1*** Settings ***
2Documentation   Find services and service agents on the system.
3Library         OperatingSystem
4Library         Collections
5Library         String
6
7Resource        ../lib/utils.robot
8
9# Get the SLP services available, make it suite global.
10Suite Setup     Suite Setup Execution
11
12Test Tags  SLP_Service_Test
13
14*** Variables ***
15${service_types}    findsrvtypes
16${service_agents}   findsrvs
17${service_path}     /etc/slp/services
18# SLP_SERVICES  Services listed by slptool, by default Empty.
19${SLP_SERVICES}       ${EMPTY}
20
21*** Test Cases ***
22
23Verify SLP Service Types
24    [Documentation]  Find services supported by system.
25    [Tags]  Verify_SLP_Service_Types
26
27    Verify Service Types
28
29Verify Service Agents For Service Types
30    [Documentation]  Find And verify service agents.
31    [Tags]  Verify_Service_Agents_For_Service_Types
32
33    @{parameters}=  Split String  ${SLP_SERVICES}  ${\n}
34
35    FOR  ${parameter}  IN  @{parameters}
36      ${output}=  Run SLP command  ${service_agents}  ${parameter}
37      Verify Service Agents  ${output}  ${parameter}
38    END
39
40*** Keywords ***
41
42Suite Setup Execution
43    [Documentation]  Get SLP services.
44
45    ${output}=  Run  which slptool
46    Should Not Be Empty  ${output}
47    ...  msg=slptool not installed.
48    ${SLP_SERVICES}=  Run SLP command  ${service_types}
49    Set Suite Variable  ${SLP_SERVICES}
50
51Run SLP Command
52    [Documentation]  Run SLPTool command and return output.
53    [Arguments]      ${cmd}  ${param}=${EMPTY}
54    # cmd    The SLP command to be run.
55    # param  The SLP command parameters.
56
57    ${rc}  ${output}=  Run And Return Rc And Output
58    ...   slptool -u ${OPENBMC_HOST} ${cmd} ${param}
59    Should Be Equal As Integers  ${rc}  0
60    RETURN  ${output}
61
62Verify Service Types
63    [Documentation]  Verifies the output of service types.
64
65    ${remove_prefix}=  Remove String  ${SLP_SERVICES}  service:
66    @{services}=  Split String  ${remove_prefix}  ${\n}
67    ${service_count}=  Get Length  ${services}
68    Open Connection And Log In
69    ${stdout}  ${stderr}=  Execute Command  ls ${service_path}
70    ...  return_stderr=True
71    Should Be Empty  ${stderr}
72    ${file_count}=  Get Line Count  ${stdout}
73    Should Be Equal  ${service_count}  ${file_count}
74    ...  msg=Number of services on system & command are not equal.
75
76    FOR  ${service}  IN  @{services}
77      Should Contain  ${stdout}  ${service}  msg=Services on system & command are not same.
78    END
79
80Verify Service Agents
81    [Documentation]  Verifies the output of srvs.
82    [Arguments]      ${output}  ${service_agent}
83
84    # Description of argument(s):
85    # output         SLP service output.
86    #                Example of output
87    #                <service:service_name:tcp//xxx.xxx.xxx.xxx,2200>
88    # service_agent  Service agent ('findsrvs').
89
90    Run Keywords  Should Contain  ${output}  ${service_agent}  AND
91    ...  Should Contain  ${output}  ${OPENBMC_HOST},
92    ...  msg=Expected process info missing.
93
94