Author: gnichols
Date: 2012-08-23 18:57:26 +0000 (Thu, 23 Aug 2012)
New Revision: 1364
Removed:
trunk/tests/suspend/runtest.sh
Modified:
trunk/tests/suspend/Makefile
trunk/tests/suspend/suspend.py
Log:
843611 - suspend test should not use HAL
Modified: trunk/tests/suspend/Makefile
===================================================================
--- trunk/tests/suspend/Makefile 2012-08-23 18:49:55 UTC (rev 1363)
+++ trunk/tests/suspend/Makefile 2012-08-23 18:57:26 UTC (rev 1364)
@@ -18,17 +18,12 @@
FILES=runtest.sh suspend.py
run: $(FILES) build
- ./runtest.sh
build: $(BUILT_FILES)
- chmod a+x ./runtest.sh ./suspend.py
+ chmod a+x ./suspend.py
clean:
rm -f *~ $(BUILT_FILES)
# Include Common Makefile
include $(DESTDIR)/usr/share/v7/lib/v7-make.include
-
-
-
-
Deleted: trunk/tests/suspend/runtest.sh
===================================================================
--- trunk/tests/suspend/runtest.sh 2012-08-23 18:49:55 UTC (rev 1363)
+++ trunk/tests/suspend/runtest.sh 2012-08-23 18:57:26 UTC (rev 1364)
@@ -1,3 +0,0 @@
-#!/bin/bash
-
-v7-run-simple-test ${TEST:-$(basename $PWD)} ./suspend.py
Modified: trunk/tests/suspend/suspend.py
===================================================================
--- trunk/tests/suspend/suspend.py 2012-08-23 18:49:55 UTC (rev 1363)
+++ trunk/tests/suspend/suspend.py 2012-08-23 18:57:26 UTC (rev 1364)
@@ -1,9 +1,9 @@
#!/usr/bin/python
-# Copyright (c) 2006 Red Hat, Inc. All rights reserved. This copyrighted material
-# is made available to anyone wishing to use, modify, copy, or
-# redistribute it subject to the terms and conditions of the GNU General
+# Copyright (c) 2006 Red Hat, Inc. All rights reserved. This copyrighted material
+# is made available to anyone wishing to use, modify, copy, or
+# redistribute it subject to the terms and conditions of the GNU General
# Public License v.2.
-#
+#
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
@@ -18,12 +18,11 @@
from v7.test import Test
from v7.tags import Constants, DeviceClass, TestTag
-from v7.hal import Hal
from v7.controller import Controller
from v7.redhatrelease import RedHatRelease
-class SuspendTest(Test):
-
+class SuspendTest(Test):
+
def __init__(self):
Test.__init__(self, name="suspend")
self.acpiListen = None
@@ -37,30 +36,28 @@
self.suspendMessage = dict()
self.suspendMessage[Constants.memory] = "Suspending computer because the
suspend button has been pressed"
self.suspendMessage[Constants.disk] = "Hibernating computer because the
hibernate button has been pressed"
-
+
def tags(self):
return [TestTag.interactive, TestTag.certification, TestTag.portable]
-
+
def plan(self, planner):
tests = list()
acAdapterDevice = None
- devices = planner.getHalDeviceDetector().getDevices()
+ devices = planner.getUdevDeviceDetector().getDevices()
for device in devices:
- if 'battery' in device.getProperty("info.category"):
+ if "power_supply" in device.getProperty("SUBSYSTEM") and
"BAT" in device.getProperty("POWER_SUPPLY_NAME"):
test = self.makeCopy()
test.setDevice(device)
tests.append(test)
# 450297: suspend test planned once per battery
- # change to only plan this test once, no matter how many
+ # change to only plan this test once, no matter how many
# batteries are reported
break
return tests
-
-
+
def getRequiredRPMs(self):
return ["pm-utils"]
-
def getSuspendMethods(self):
sysPowerState = open("/sys/power/state", "r")
if sysPowerState:
@@ -79,7 +76,7 @@
# otherwise
print "Error: could not determine allowable suspend methods"
return None
-
+
def suspendWithOSCommand(self, method):
""" suspend via pm-suspend/pm-hibernate """
if method == Constants.memory:
@@ -87,27 +84,27 @@
return False
elif method == Constants.disk:
if not os.system("pm-hibernate") is 0:
- return False
+ return False
else:
print "Error: unknown suspend method %s" % method
return False
-
+
# otherwise
return True
-
+
def suspendWithOSCommand2(self, method):
""" suspend using a write operation to /sys/power/state
"""
# if not os.system("echo \"%s\" > /sys/power/state" % method)
is 0:
sysPowerState = open("/sys/power/state", "w")
if sysPowerState:
-
- sysPowerState.write(method)
+
+ sysPowerState.write(method)
sysPowerState.close()
else:
print "Error: could not suspend the system"
return False
return True
-
+
def suspend(self, source, method):
print "This test will suspend the operating system."
print "Please resume by pressing the power button after suspend has
completed."
@@ -118,7 +115,7 @@
# self.acpiListen = os.popen("acpi_listen")
markerName = "%s-%s-%s" % (self.Name(), source, method)
syslog.syslog(self.v7Controller.getSystemLogMarker(markerName,
"begin"))
- if source == Constants.OSCommand:
+ if source == Constants.OSCommand:
if not self.promptConfirm(" suspend? "):
return False
waitTime = 5
@@ -126,27 +123,27 @@
sys.stdout.flush()
time.sleep(waitTime)
return self.suspendWithOSCommand(method)
-
+
# otherwise
- if source == Constants.FunctionKey:
+ if source == Constants.FunctionKey:
if not self.promptConfirm("Does this system have a function key (Fn) to
suspend the system to %s?" % method):
print "Warning: suspend test to %s not run from function key" %
method
return False
if not self.promptConfirm("Please press the function key (Fn) to suspend
the system to %s " % method):
return False
return True
-
+
# otherwise
print "Error: unknown suspend source"
return False
-
+
def checkResume(self, source, method):
self.verifiedResumeMethod = None
sys.stdout.flush()
self.promptConfirm("Has resume completed? ")
markerName = "%s-%s-%s" % (self.Name(), source, method)
- syslog.syslog(self.v7Controller.getSystemLogMarker(markerName, "end"))
-
+ syslog.syslog(self.v7Controller.getSystemLogMarker(markerName, "end"))
+
#check system log for acpi messages
log = self.v7Controller.getSystemLog("%s-%s-%s" % (self.Name(), source,
method))
@@ -171,7 +168,7 @@
if not resumeMessage in log:
print "Error: could not verify resume"
return False
-
+
# check that they used the correct method
self.verifiedResumeMethod = Constants.memory
methodMessage = re.compile("(swsusp|PM): Need to copy")
@@ -182,12 +179,12 @@
if method != self.verifiedResumeMethod:
print "Error: The suspend method was %s and should have been %s" %
(self.verifiedResumeMethod, method)
return False
-
+
# otherwise
print "Verified resume from %s" % self.verifiedResumeMethod
return True
-
+
def runSuspendResume(self, source, method):
if self.suspend(source, method):
return self.checkResume(source, method)
@@ -197,20 +194,20 @@
return True
#otherwise
return False
-
-
+
+
def run(self):
FAILED = 1
PASSED = 0
-
+
if self.getMode() == Constants.auto:
print "Error: suspend test can not be run in auto mode."
return FAILED
-
+
methods = self.getSuspendMethods()
if not methods or len(methods) is 0:
return FAILED
-
+
# forced mode - being run as preparations for other tests
if self.getMode() == Constants.forced:
result = PASSED
@@ -219,7 +216,7 @@
elif self.verifiedResumeMethod != methods[0]:
result = FAILED
return result
-
+
# otherwise, full test
result = PASSED
for source in [Constants.OSCommand, Constants.FunctionKey]:
@@ -233,21 +230,12 @@
self.markSummary(Constants.FAIL)
else:
self.markSummary(Constants.PASS)
-
+
self.closeOutput()
- return result
-
+ return result
+
if __name__ == "__main__":
test = SuspendTest()
returnValue = test.do(sys.argv)
sys.exit(returnValue)
-
-
-
-
-
-
-
-
-