1*3075ff32SSathyajith M S*** Settings ***
2*3075ff32SSathyajith M SDocumentation   Test Non-maskable interrupt functionality.
3*3075ff32SSathyajith M S
4*3075ff32SSathyajith M SResource        ../lib/bmc_redfish_resource.robot
5*3075ff32SSathyajith M SResource        ../lib/boot_utils.robot
6*3075ff32SSathyajith M SResource        ../lib/openbmc_ffdc.robot
7*3075ff32SSathyajith M SResource        ../lib/secureboot/secureboot.robot
8*3075ff32SSathyajith M SResource        ../lib/state_manager.robot
9*3075ff32SSathyajith M SLibrary         ../lib/bmc_ssh_utils.py
10*3075ff32SSathyajith M SLibrary         ../syslib/utils_os.py
11*3075ff32SSathyajith M S
12*3075ff32SSathyajith M STest Teardown   FFDC On Test Case Fail
13*3075ff32SSathyajith M SSuite Teardown  Redfish.Logout
14*3075ff32SSathyajith M S
15*3075ff32SSathyajith M S
16*3075ff32SSathyajith M S*** Test Cases ***
17*3075ff32SSathyajith M S
18*3075ff32SSathyajith M STrigger NMI When OPAL/Host OS Is Not Up
19*3075ff32SSathyajith M S    [Documentation]  Verify return error code from Redfish
20*3075ff32SSathyajith M S    ...  while injecting NMI when HOST OS is not up.
21*3075ff32SSathyajith M S    [Tags]  Trigger_NMI_When_OPAL/Host_OS_Is_Not_Up
22*3075ff32SSathyajith M S
23*3075ff32SSathyajith M S    Redfish Power Off
24*3075ff32SSathyajith M S    Trigger NMI
25*3075ff32SSathyajith M S
26*3075ff32SSathyajith M S
27*3075ff32SSathyajith M STrigger NMI When OPAL/Host OS Is Running And Secureboot Is Disabled
28*3075ff32SSathyajith M S    [Documentation]  Verify valid return status code from Redfish
29*3075ff32SSathyajith M S    ...  while injecting NMI, when HOST OS is running and
30*3075ff32SSathyajith M S    ...  secureboot is disabled.
31*3075ff32SSathyajith M S    [Tags]  Trigger_NMI_When_OPAL/Host_OS_Is_Running_And_Secureboot_Is_Disabled
32*3075ff32SSathyajith M S    [Setup]  Test Setup Execution  ${0}
33*3075ff32SSathyajith M S
34*3075ff32SSathyajith M S    Trigger NMI  valid_status_codes=[${HTTP_OK}]
35*3075ff32SSathyajith M S    # NMI Post Crash Dump Verification
36*3075ff32SSathyajith M S    Wait Until Keyword Succeeds  10 min  1 min  Is Host Rebooted
37*3075ff32SSathyajith M S    Is OS Booted
38*3075ff32SSathyajith M S    Wait Until Keyword Succeeds  1 min  10 sec  Verify Crash Dump Directory
39*3075ff32SSathyajith M S
40*3075ff32SSathyajith M S
41*3075ff32SSathyajith M S*** Keywords ***
42*3075ff32SSathyajith M S
43*3075ff32SSathyajith M STest Setup Execution
44*3075ff32SSathyajith M S    [Documentation]  Test setup execution.
45*3075ff32SSathyajith M S    [Arguments]  ${secure_boot_mode}=${1}
46*3075ff32SSathyajith M S
47*3075ff32SSathyajith M S    # Description of argument(s):
48*3075ff32SSathyajith M S    # secure_boot_mode  Secure boot -> Enable-1 or Disable-0.
49*3075ff32SSathyajith M S
50*3075ff32SSathyajith M S    Redfish Power Off  stack_mode=skip
51*3075ff32SSathyajith M S    Set Auto Reboot  ${1}
52*3075ff32SSathyajith M S    # Set and verify secure boot policy as disabled.
53*3075ff32SSathyajith M S    Set And Verify TPM Policy  ${secure_boot_mode}
54*3075ff32SSathyajith M S    Redfish Power On
55*3075ff32SSathyajith M S    # Delete any pre-existing dump files.
56*3075ff32SSathyajith M S    OS Execute Command  rm -rf /var/crash/*
57*3075ff32SSathyajith M S    ${os_release_info}=  Get OS Release Info
58*3075ff32SSathyajith M S    # Start crash dump utility on OS.
59*3075ff32SSathyajith M S    ${cmd}=  Set Variable If
60*3075ff32SSathyajith M S    ...  '${os_release_info['id']}' == 'ubuntu'  kdump-config show  kdumpctl start
61*3075ff32SSathyajith M S    OS Execute Command  ${cmd}  print_out=1
62*3075ff32SSathyajith M S
63*3075ff32SSathyajith M S
64*3075ff32SSathyajith M STrigger NMI
65*3075ff32SSathyajith M S    [Documentation]  Inject non-maskable interrupt Redfish URI.
66*3075ff32SSathyajith M S    [Arguments]  ${valid_status_codes}=[${HTTP_INTERNAL_SERVER_ERROR}]
67*3075ff32SSathyajith M S
68*3075ff32SSathyajith M S    # Description of argument(s):
69*3075ff32SSathyajith M S    # valid_status_codes  A list of status codes that the
70*3075ff32SSathyajith M S    #                     caller considers acceptable.
71*3075ff32SSathyajith M S    #                     See lib/redfish_plus.py for details.
72*3075ff32SSathyajith M S
73*3075ff32SSathyajith M S    Redfish.Login
74*3075ff32SSathyajith M S    Redfish.Post  ${SYSTEM_BASE_URI}Actions/ComputerSystem.Reset
75*3075ff32SSathyajith M S    ...  body={"ResetType": "Nmi"}  valid_status_codes=${valid_status_codes}
76*3075ff32SSathyajith M S
77*3075ff32SSathyajith M SVerify Crash Dump Directory
78*3075ff32SSathyajith M S    [Documentation]  Verify that the crash dump directory is not empty.
79*3075ff32SSathyajith M S
80*3075ff32SSathyajith M S    # As per the requirement, there should be a crash dump file
81*3075ff32SSathyajith M S    # after successful NMI injection.
82*3075ff32SSathyajith M S    ${output}  ${stderr}  ${rc}=
83*3075ff32SSathyajith M S    ...  OS Execute Command  ls -ltr /var/crash/*  print_out=1
84