New: [rhinstaller/anaconda/pulls/246 rhel7-branch] Really fix unexpected exits in execReadlines
by dashea
Due to the asynchronous nature of signal delivery, it's possible to
check on the execReadlines child process at a point where output has
been closed but the process is still, technically, alive. This situation
appeared in particular when running the nosetests on a system with one
CPU. To make the behavior of reading a line from an exiting process
deterministic, wait for the process to finish when output is complete.
The consequence of this is that processes that runs forever will cause
execReadlines to block forever, and the answer is to not run such a
process with execReadlines.
This commit also combines the fix for the bad use of WIFSIGNALED in
2275dfc76f4417cbe1b620d19b6558ec007d3bdc and the change in
807aa60ccb3cc0bc74581b58f04d0777d7b35985 to make the exit behavior make
more sense. The tests were already looking for the exceptions raised by
the latter commit, and sometimes they found them.
(cherry picked from commit 807aa60ccb3cc0bc74581b58f04d0777d7b35985)
Related: rhbz#1188287
--
To view this pull request on github, visit https://github.com/rhinstaller/anaconda/pull/246
8 years, 10 months
[PATCH pyparted] Use addCleanup instead of tearDown for removing temp-device.
by Chris Lumens
If something fails in setUp, tearDown will not be called. However, addCleanup
will always be called. We should use this to make sure no /tmp/temp-device-*
files stay around.
---
tests/baseclass.py | 23 +++++++++++++++--------
tests/test__ped_partition.py | 4 ++--
2 files changed, 17 insertions(+), 10 deletions(-)
diff --git a/tests/baseclass.py b/tests/baseclass.py
index 617382e..4f48b87 100644
--- a/tests/baseclass.py
+++ b/tests/baseclass.py
@@ -27,13 +27,16 @@ import unittest
# Base class for any test case that requires a temp device node
class RequiresDeviceNode(unittest.TestCase):
def setUp(self):
+ self.addCleanup(self.removeTempDevice)
+
(fd, self.path) = tempfile.mkstemp(prefix="temp-device-")
f = os.fdopen(fd)
f.seek(140000)
os.write(fd, b"0")
- def tearDown(self):
- os.unlink(self.path)
+ def removeTempDevice(self):
+ if self.path and os.path.exists(self.path):
+ os.unlink(self.path)
# Base class for any test case that requires a _ped.Device or parted.Device
# object first.
@@ -46,6 +49,8 @@ class RequiresDevice(RequiresDeviceNode):
# Base class for any test case that requires a filesystem on a device.
class RequiresFileSystem(unittest.TestCase):
def setUp(self):
+ self.addCleanup(self.removeTempDevice)
+
self._fileSystemType = {}
ty = _ped.file_system_type_get_next()
self._fileSystemType[ty.name] = ty
@@ -68,8 +73,9 @@ class RequiresFileSystem(unittest.TestCase):
self._device = _ped.device_get(self.path)
self._geometry = _ped.Geometry(self._device, 0, self._device.length - 1)
- def tearDown(self):
- os.unlink(self.path)
+ def removeTempDevice(self):
+ if self.path and os.path.exists(self.path):
+ os.unlink(self.path)
# Base class for certain alignment tests that require a _ped.Device
class RequiresDeviceAlignment(RequiresDevice):
@@ -139,6 +145,7 @@ class RequiresDisk(RequiresDevice):
# Base class for any test case that requires a filesystem made and mounted.
class RequiresMount(RequiresDevice):
def setUp(self):
+ self.addCleanup(self.removeMountpoint)
RequiresDevice.setUp(self)
self.mountpoint = None
@@ -149,10 +156,10 @@ class RequiresMount(RequiresDevice):
self.mountpoint = tempfile.mkdtemp()
os.system("mount -o loop %s %s" % (self.path, self.mountpoint))
- def tearDown(self):
- os.system("umount %s" % self.mountpoint)
- os.rmdir(self.mountpoint)
- RequiresDevice.tearDown(self)
+ def removeMountpoint(self):
+ if self.mountpoint and os.path.exists(self.mountpoint):
+ os.system("umount %s" % self.mountpoint)
+ os.rmdir(self.mountpoint)
# Base class for any test case that requires a _ped.Partition.
class RequiresPartition(RequiresDisk):
diff --git a/tests/test__ped_partition.py b/tests/test__ped_partition.py
index 1d9b225..7110545 100755
--- a/tests/test__ped_partition.py
+++ b/tests/test__ped_partition.py
@@ -184,6 +184,7 @@ class PartitionGetNameTestCase(RequiresPartition):
class PartitionIsBusyTestCase(RequiresPartition):
def setUp(self):
+ self.addCleanup(self.removeMountpoint)
RequiresPartition.setUp(self)
self.mountpoint = None
@@ -194,11 +195,10 @@ class PartitionIsBusyTestCase(RequiresPartition):
def mkfs(self):
os.system("mkfs.ext2 -F -q %s" % self.path)
- def tearDown(self):
+ def removeMountpoint(self):
if self.mountpoint:
os.system("umount %s" % self.mountpoint)
os.rmdir(self.mountpoint)
- RequiresPartition.tearDown(self)
def runTest(self):
# partitions aren't busy until they're mounted.
--
2.4.3
8 years, 11 months
[PATCH] Use sys.exit instead of os._exit.
by Chris Lumens
The former ensures atexit handlers get run, and pocketlint uses that to delete
the XDG_RUNTIME_DIR it drops.
---
tests/pylint/runpylint.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tests/pylint/runpylint.py b/tests/pylint/runpylint.py
index 410dd8d..bd97783 100755
--- a/tests/pylint/runpylint.py
+++ b/tests/pylint/runpylint.py
@@ -1,6 +1,6 @@
#!/usr/bin/python3
-import os
+import sys
from pocketlint import FalsePositive, PocketLintConfig, PocketLinter
@@ -29,4 +29,4 @@ if __name__ == "__main__":
conf = AnacondaLintConfig()
linter = PocketLinter(conf)
rc = linter.run()
- os._exit(rc)
+ sys.exit(rc)
--
2.4.3
8 years, 11 months