Skip to content

Commit 99a130a

Browse files
committed
OpTestInterrupt.py: This patch validates interrupt controller mechanism
It checks system reboot with xive on and off and it also validates interrupts handled by CPU's Signed-off-by: shirisha Ganta <[email protected]>
1 parent 7f03ffa commit 99a130a

File tree

1 file changed

+189
-0
lines changed

1 file changed

+189
-0
lines changed

testcases/OpTestInterrupt.py

+189
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
#!/usr/bin/env python3
2+
# IBM_PROLOG_BEGIN_TAG
3+
# This is an automatically generated prolog.
4+
#
5+
# $Source: op-test-framework/testcases/OpTestXive.py $
6+
#
7+
# OpenPOWER Automated Test Project
8+
#
9+
# Contributors Listed Below - COPYRIGHT 2017
10+
# [+] International Business Machines Corp.
11+
#
12+
#
13+
# Licensed under the Apache License, Version 2.0 (the "License");
14+
# you may not use this file except in compliance with the License.
15+
# You may obtain a copy of the License at
16+
#
17+
# http://www.apache.org/licenses/LICENSE-2.0
18+
#
19+
# Unless required by applicable law or agreed to in writing, software
20+
# distributed under the License is distributed on an "AS IS" BASIS,
21+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
22+
# implied. See the License for the specific language governing
23+
# permissions and limitations under the License.
24+
#
25+
# IBM_PROLOG_END_TAG
26+
27+
'''
28+
OpTestInterrupt
29+
---------------
30+
31+
This module contain testcases related to XIVE.
32+
33+
1.Enable kernel logging, basically generate traffic
34+
2.Enable console traffic by printing the
35+
processes/tasks to the console
36+
3.check Xive is configured properly or not
37+
4.check system reboot with xive=on
38+
5.check system reboot with xive=off
39+
6.validate interrupts handled by CPU's
40+
'''
41+
import os
42+
import re
43+
import sys
44+
import time
45+
import pexpect
46+
import unittest
47+
import subprocess
48+
49+
import OpTestConfiguration
50+
from common import OpTestHMC, OpTestFSP
51+
from common.OpTestSOL import OpSOLMonitorThread
52+
from common.OpTestError import OpTestError
53+
from common.OpTestSystem import OpSystemState
54+
from common.OpTestSSH import ConsoleState as SSHConnectionState
55+
from common.OpTestConstants import OpTestConstants as BMC_CONST
56+
from common.Exceptions import KernelOOPS, KernelKdump
57+
58+
import logging
59+
import OpTestLogger
60+
log = OpTestLogger.optest_logger_glob.get_logger(__name__)
61+
62+
63+
class OpTestInterrupt(unittest.TestCase):
64+
def setUp(self):
65+
conf = OpTestConfiguration.conf
66+
self.cv_SYSTEM = conf.system()
67+
self.cv_HOST = conf.host()
68+
self.platform = conf.platform()
69+
self.bmc_type = conf.args.bmc_type
70+
self.util = self.cv_SYSTEM.util
71+
self.c = self.cv_SYSTEM.console
72+
self.con = self.cv_SYSTEM.cv_HOST.get_ssh_connection()
73+
74+
def xive_test(self):
75+
'''
76+
This function will do below steps
77+
1.Enable kernel logging, basically generate traffic
78+
2.Enable console traffic by printing the
79+
processes/tasks to the console
80+
'''
81+
self.c.run_command("echo 10 > /proc/sys/kernel/printk")
82+
try:
83+
i = 1
84+
while i <= 10:
85+
self.c.run_command("echo t > /proc/sysrq-trigger", timeout=600)
86+
i = i+1
87+
except(KernelOOPS, KernelKdump):
88+
self.cv_SYSTEM.goto_state(OpSystemState.OS)
89+
self.c.run_command("echo $?")
90+
91+
class XiveTesting(OpTestInterrupt):
92+
'''
93+
1.This function will check xive is configured properly or not
94+
2.check for system reboot with Xive=off
95+
3.check for system reboot with Xive=on
96+
'''
97+
def setup_test(self):
98+
self.cv_SYSTEM.goto_state(OpSystemState.OS)
99+
self.con.run_command("uname -a")
100+
result = self.con.run_command("grep -i --color=never xive /boot/config-`uname -r`")
101+
for line in result:
102+
temp = ''.join(self.con.run_command("echo %s | cut -d '=' -f 2" % line))
103+
if temp != 'y':
104+
self.fail("xive is not configured properly")
105+
res = self.con.run_command("cat /etc/os-release | grep NAME | head -1")
106+
if 'SLES' in res[0].strip():
107+
self.distro = 'SLES'
108+
self.con.run_command_ignore_fail("sed -i -e 's/xive=.* / /' -e 's/xive=.*/\"/' /etc/default/grub")
109+
self.con.run_command("sed -i '/GRUB_CMDLINE_LINUX_DEFAULT/s/\"$/ xive=off\"/' /etc/default/grub")
110+
self.con.run_command("grub2-mkconfig -o /boot/grub2/grub.cfg")
111+
self.con.run_command("sync;sleep 10")
112+
self.cv_SYSTEM.goto_state(OpSystemState.OFF)
113+
self.cv_SYSTEM.goto_state(OpSystemState.OS)
114+
self.con.run_command("cat /proc/cmdline")
115+
self.con.run_command_ignore_fail("cat /proc/interrupts | grep -Eai 'xive'")
116+
self.con.run_command("sed -i 's/xive=.*/xive=on\"/' /etc/default/grub")
117+
self.con.run_command("grub2-mkconfig -o /boot/grub2/grub.cfg")
118+
self.con.run_command("sync;sleep 10")
119+
self.cv_SYSTEM.goto_state(OpSystemState.OFF)
120+
self.cv_SYSTEM.goto_state(OpSystemState.OS)
121+
self.con.run_command("cat /proc/cmdline")
122+
elif 'Red Hat' in res[0].strip():
123+
self.distro = 'RHEL'
124+
self.rhel_grub('off')
125+
self.rhel_grub('on')
126+
127+
def rhel_grub(self, param):
128+
'''
129+
This function will pass xive=on and off parameters
130+
to command line.
131+
'''
132+
self.con.run_command("grubby --info=/boot/vmlinuz-`uname -r`")
133+
self.con.run_command_ignore_fail("grubby --remove-args=xive* --update-kernel=/boot/vmlinuz-`uname -r`")
134+
self.con.run_command("grubby --args=xive=%s --update-kernel=/boot/vmlinuz-`uname -r`" % param)
135+
self.con.run_command("sync; sync; sleep 5")
136+
self.cv_SYSTEM.goto_state(OpSystemState.OFF)
137+
self.cv_SYSTEM.goto_state(OpSystemState.OS)
138+
self.con.run_command("grubby --info=/boot/vmlinuz-`uname -r`")
139+
140+
def interrupt_cpu_check(self):
141+
'''
142+
This function will validate interrupts handled by CPU's.
143+
Make sure while running this function xive should be on
144+
'''
145+
self.con = self.cv_SYSTEM.cv_HOST.get_ssh_connection()
146+
res = self.con.run_command("ip route list | grep default | awk '{print $5}'")
147+
inter = "cat /proc/interrupts | grep %s | head -1" % res[0]
148+
self.con.run_command(inter)
149+
self.con.run_command("ppc64_cpu --cores-on")
150+
self.con.run_command("ppc64_cpu --cores-on=1")
151+
self.con.run_command(inter)
152+
temp = "%s | awk '{print $2}'" % inter
153+
self.con.run_command("ppc64_cpu --smt=off")
154+
tmp1 = self.con.run_command(temp)
155+
time.sleep(10)
156+
tmp2 = self.con.run_command(temp)
157+
if (tmp1[0] < tmp2[0]):
158+
log.info("Interrupts are handled by CPU0")
159+
self.con.run_command("ppc64_cpu --cores-on=all")
160+
self.con.run_command("ppc64_cpu --smt=on")
161+
output = self.con.run_command(inter)
162+
cmd = "%s | awk '{print $4}'" % inter
163+
tmp3 = self.con.run_command(cmd)
164+
smp = "%s | awk '{print $1}'" % inter
165+
result = self.con.run_command(smp)
166+
self.con.run_command("cd /proc/irq/%s" % result[0].lstrip().split(':')[0])
167+
self.con.run_command("cat smp_affinity_list")
168+
log.info("setting smp_affinity_list to CPU2")
169+
self.con.run_command("echo 2 > smp_affinity_list")
170+
self.con.run_command(inter)
171+
time.sleep(10)
172+
tmp4 = self.con.run_command(cmd)
173+
if (tmp3[0] < tmp4[0]):
174+
log.info("Interrupts are handled by CPU2")
175+
else:
176+
self.fail("Interrupts are not handled by CPU2")
177+
else:
178+
self.fail("Interrupts are not handled by CPU")
179+
180+
def runTest(self):
181+
self.setup_test()
182+
self.xive_test()
183+
self.interrupt_cpu_check()
184+
185+
186+
def crash_suite():
187+
s = unittest.TestSuite()
188+
s.addTest(XiveTesting())
189+
return s

0 commit comments

Comments
 (0)