Saggi Mizrahi has uploaded a new change for review.
Change subject: Sometimes the FD number can be reused in the child process
......................................................................
Sometimes the FD number can be reused in the child process
This makes sure that the fd is the file that we expected to be closed child
process
Change-Id: I7044936fba8923297c76d9a2123215ec2b793548
Signed-off-by: Saggi Mizrahi <smizrahi(a)redhat.com>
---
M tests/betterPopenTests.py
1 file changed, 7 insertions(+), 6 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/91/9591/1
diff --git a/tests/betterPopenTests.py b/tests/betterPopenTests.py
index 6347460..eb129f4 100644
--- a/tests/betterPopenTests.py
+++ b/tests/betterPopenTests.py
@@ -59,8 +59,9 @@
def testCloseFDs(self):
fds = os.pipe()
+ rpath = os.path.realpath("/proc/%d/fds/%d" % (os.getpid(), fds[1]))
try:
- self._subTest("fds", [str(fds[1])], close_fds=True)
+ self._subTest("fds", [str(fds[1]), rpath], close_fds=True)
finally:
os.close(fds[0])
os.close(fds[1])
@@ -154,11 +155,11 @@
if __name__ == "__main__":
cmd = sys.argv[1]
if cmd == "fds":
- try:
- os.close(int(sys.argv[2]))
- print "False"
- except:
- print "True"
+ fdpath = "/proc/%d/fds/%d" % (os.getpid(), int(sys.argv[2]))
+ if not os.path.exists(fdpath):
+ print True
+ else:
+ print (open(fdpath).read().strip() == sys.argv[3])
elif cmd == "nofds":
try:
--
To view, visit
http://gerrit.ovirt.org/9591
To unsubscribe, visit
http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I7044936fba8923297c76d9a2123215ec2b793548
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Saggi Mizrahi <smizrahi(a)redhat.com>