Author: gnichols
Date: 2011-03-16 00:03:52 +0000 (Wed, 16 Mar 2011)
New Revision: 815
Modified:
trunk/tests/profiler/profiler.py
Log:
678949 - oprofiled did not start on Nehalem-EX platform
Modified: trunk/tests/profiler/profiler.py
===================================================================
--- trunk/tests/profiler/profiler.py 2011-03-16 00:02:12 UTC (rev 814)
+++ trunk/tests/profiler/profiler.py 2011-03-16 00:03:52 UTC (rev 815)
@@ -17,7 +17,7 @@
import sys, os, time, fileinput, commands
from v7.test import Test, TestTag
-from v7.command import Command, V7CommandException
+from v7.command import Command, V7CommandException, V7CommandErrorOutput
from v7.tags import DeviceClass
class ProfilerTest(Test):
@@ -25,6 +25,7 @@
def __init__(self):
Test.__init__(self, name="profiler")
self.deviceClass = DeviceClass.processor
+ self.forcedTimerConfig = False
def tags(self):
return [TestTag.noninteractive, TestTag.certification]
@@ -44,6 +45,11 @@
def getRequiredRPMs(self):
return ["oprofile"]
+ def initialize(self):
+ self.getLinuxImage()
+ self.resetNMIWatchdog()
+ return True
+
def old_run(self):
FAILED = 1
PASSED = 0
@@ -124,8 +130,8 @@
print "^^^^ END: Errors during reset may be ignored. ^^^^\n"
sys.stdout.flush()
+
-
return True
def startOProfile(self):
@@ -146,6 +152,7 @@
command.echo()
command = Command("opcontrol --start")
command.echo()
+ self.getOProfileVersion()
return True
def startDaemon(self):
@@ -170,7 +177,11 @@
def report(self):
try:
Command("opcontrol --dump").echo()
- Command("opreport").echo()
+ try:
+ Command("opreport").echo()
+ except V7CommandErrorOutput, exception:
+ print "Warning: %s" % exception
+ exception.command.printErrors()
except V7CommandException, exception:
print exception
return False
@@ -210,47 +221,92 @@
modprobeConf = open(self.timerConfPath, "a")
modprobeConf.write("options oprofile timer=1\n")
modprobeConf.close()
+ self.forcedTimerConfig = True
except:
return False
- return self.run()
- return False
+ return True
+
def removeTimerConf(self):
if self.checkTimerConf():
for line in fileinput.input(self.timerConfPath, "inplace=1"):
if not line == "options oprofile timer=1\n":
print line.rstrip("\n")
+
+ def resetNMIWatchdog(self):
+ try:
+ self.nmiWatchdog = Command("cat /proc/sys/kernel/nmi_watchdog").getString()
+ print "NMI Watchdog = %s" % self.nmiWatchdog
+ if self.nmiWatchdog != "0":
+ print "reseting NMI watchdog"
+ Command("echo 0 > /proc/sys/kernel/nmi_watchdog").echo()
+ return True
+ except V7CommandException, exception:
+ print "Error: could not read/set NMI Watchdog"
+ print exception
+
+ return False
+
+ def restoreNMIWatchdog(self):
+ try:
+ nmiWatchdog = Command("cat /proc/sys/kernel/nmi_watchdog").getString()
+ if self.nmiWatchdog != "0" and nmiWatchdog != self.nmiWatchdog:
+ print "restoring NMI watchdog"
+ Command("echo %s > /proc/sys/kernel/nmi_watchdog" % self.nmiWatchdog).echo()
+ return True
+ except V7CommandException, exception:
+ print "Error: could not restore NMI Watchdog"
+ print exception
+
+ return False
+ def runOProfileStartup(self):
+ if not self.runSubTest(self.resetOProfile, "Reset"):
+ return False
+ if not self.runSubTest(self.startDaemon, "Start Daemon"):
+ return False
+ if not self.runSubTest(self.startOProfile, "Start OProfile"):
+ return False
+
+ return True
+
def run(self):
FAILED = 1
PASSED = 0
- try:
- self.getLinuxImage()
- if not self.runSubTest(self.resetOProfile, "Reset"):
- return FAILED
- if not self.runSubTest(self.startDaemon, "Start Daemon"):
- return FAILED
- if not self.runSubTest(self.startOProfile, "Start OProfile"):
- return FAILED
- self.getOProfileVersion()
- if not self.report() and not self.forceTimerConf():
+
+ success = True
+
+ if not self.runSubTest(self.initialize, "Initialize"):
+ success = False
+
+ if success and not self.runOProfileStartup():
+ success = False
+
+ # if report fails, re-try with a forced timer config
+ if not self.runSubTest(self.report, "Report"):
+ print "Re-try testing with forced timer configuration:"
+ if self.forceTimerConf():
+ if not self.runOProfileStartup():
+ success = False
+ else:
+ if not self.runSubTest(self.report, "Report"):
+ success = False
self.removeTimerConf()
- return FAILED
+
- self.removeTimerConf()
+ self.restoreNMIWatchdog()
- except Exception, e:
- print "Error: "
- print e
- self.closeOutput()
- return FAILED
# reset - ignore if it fails
try:
- self.resetOProfile()
+ self.runSubTest(self.resetOProfile, "Reset")
except:
pass
- return PASSED
+
+ if success:
+ return PASSED
+ else:
+ return FAILED
if __name__ == "__main__":
test = ProfilerTest()