Nir Soffer has uploaded a new change for review.
Change subject: tests: Remove cPopenTests.py
......................................................................
tests: Remove cPopenTests.py
We kept an old and broken version of cpopen tests in vdsm when cpopen
was separated into a standalone project. People who like to test cpopen
are invited to send patches that that project.
For reference, here are CPopen tests:
https://github.com/oVirt/cpopen/blob/master/tests/tests.py
Change-Id: I9dc384d6e84ce5f09573be32ea6247c6ef834836
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
M tests/Makefile.am
M tests/README
D tests/cPopenTests.py
3 files changed, 4 insertions(+), 178 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/07/65407/1
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 7e88898..e566463 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -44,7 +44,6 @@
blockVolumeTests.py \
bridgeTests.py \
bulk_sampling_test.py \
- cPopenTests.py \
capsTests.py \
clientifTests.py \
cmdutilsTests.py \
@@ -168,7 +167,6 @@
blocksdTests.py \
bridgeTests.py \
bulk_sampling_test.py \
- cPopenTests.py \
clientifTests.py \
deviceTests.py \
devices/parsing/complex_vm_tests.py \
diff --git a/tests/README b/tests/README
index 2e771c0..bf0d99d 100644
--- a/tests/README
+++ b/tests/README
@@ -13,9 +13,10 @@
From within an installed directory:
./run_tests.sh *.py
-Individual files or test cases can be specified:
- ./run_tests.sh cPopenTests.py
- ./run_tests.sh cPopenTests.py:TestCPopen.testEcho
+Individual files, test cases class or test function can be specified:
+ ./run_tests.sh foo_test.py
+ ./run_tests.sh foo_test:TestBar
+ ./run_tests.sh foo_test:TestBar.test_baz
Enabling slow tests:
-------------------
diff --git a/tests/cPopenTests.py b/tests/cPopenTests.py
deleted file mode 100644
index 0648fba..0000000
--- a/tests/cPopenTests.py
+++ /dev/null
@@ -1,173 +0,0 @@
-#
-# Copyright 2012 Red Hat, Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# 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.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-#
-# Refer to the README and COPYING files for full details of the license
-#
-from __future__ import print_function
-import os
-import sys
-import subprocess
-from nose.plugins.skip import SkipTest
-
-from testlib import VdsmTestCase as TestCaseBase
-
-EXT_ECHO = "/bin/echo"
-
-if __name__ != "__main__":
- # This will not be available when we use this module as a subprocess
- from cpopen import CPopen
-
-
-class TestCPopen(TestCaseBase):
- def testEcho(self):
- data = "Hello"
- p = CPopen([EXT_ECHO, "-n", data])
- p.wait()
- self.assertTrue(p.returncode == 0,
- "Process failed: %s" % os.strerror(p.returncode))
- self.assertEquals(p.stdout.read(), data)
-
- def testCat(self):
- path = "/etc/passwd"
- p = CPopen(["cat", path])
- p.wait()
- self.assertTrue(p.returncode == 0,
- "Process failed: %s" % os.strerror(p.returncode))
- with open(path, "r") as f:
- self.assertEquals(p.stdout.read(), f.read())
-
- def _subTest(self, name, params, *args, **kwargs):
- p = CPopen(["python", __file__, name] + params, *args, **kwargs)
- p.wait()
- self.assertTrue(p.returncode == 0,
- "Process failed: %s" % os.strerror(p.returncode))
- self.assertEquals(p.stdout.read().strip(), "True")
-
- def testCloseFDs(self):
- fds = os.pipe()
- try:
- self._subTest("fds", [str(fds[1])], close_fds=True)
- finally:
- os.close(fds[0])
- os.close(fds[1])
-
- def testNoCloseFds(self):
- fds = os.pipe()
- try:
- self._subTest("nofds", [str(fds[1])], close_fds=False)
- finally:
- os.close(fds[0])
- os.close(fds[1])
-
- def testEnv(self):
- env = os.environ.copy()
- env["TEST"] = "True"
- self._subTest("env", [], env=env)
-
- def testCwd(self):
- cwd = "/proc"
- p = CPopen(["python", "-c", "import os; print
os.getcwd()"], cwd=cwd)
- p.wait()
- self.assertTrue(p.returncode == 0,
- "Process failed: %s" % os.strerror(p.returncode))
- self.assertEquals(p.stdout.read().strip(), cwd)
-
- def testRunNonExecutable(self):
- self.assertRaises(OSError, CPopen, ["/tmp"])
-
- def testBadCwd(self):
- self.assertRaises(OSError, CPopen, ["echo", "hello"],
- cwd="/~~~~~dasdas~~~~")
-
- def testUnicodeArg(self):
- data = u'hello'
- cmd = [EXT_ECHO, "-n", data]
-
- p = CPopen(cmd)
- p.wait()
- p2 = subprocess.Popen(cmd, stdin=subprocess.PIPE,
- stdout=subprocess.PIPE, stderr=subprocess.PIPE)
- p2.wait()
- self.assertEquals(p.stdout.read(), p2.stdout.read())
-
- def testNonASCIIUnicodeArg(self):
- data = u'\u05e9\u05dc\u05d5\u05dd'
- # If the default encoding is not utf-8 the test *should* fail as non
- # ascii conversion shouldn't work
- if sys.getfilesystemencoding() != "UTF-8":
- raise SkipTest("The default encoding isn't unicode")
-
- cmd = [EXT_ECHO, "-n", data]
-
- p = CPopen(cmd)
- p.wait()
- p2 = subprocess.Popen(cmd, stdin=subprocess.PIPE,
- stdout=subprocess.PIPE, stderr=subprocess.PIPE)
- p2.wait()
- self.assertEquals(p.stdout.read(), p2.stdout.read())
-
- def testStdin(self):
- data = "Hello World"
- p = CPopen(["cat"])
- p.stdin.write(data)
- p.stdin.flush()
- p.stdin.close()
- p.wait()
- self.assertTrue(p.returncode == 0,
- "Process failed: %s" % os.strerror(p.returncode))
-
- self.assertEquals(p.stdout.read(), data)
-
- def testStdinEpoll(self):
- import select
-
- data = "Hello World"
- p = CPopen(["cat"])
- ep = select.epoll()
- ep.register(p.stdin, select.EPOLLOUT)
- fd, ev = ep.poll(1)[0]
- ep.close()
- os.write(fd, data)
- p.stdin.close()
- p.wait()
- self.assertTrue(p.returncode == 0,
- "Process failed: %s" % os.strerror(p.returncode))
-
- self.assertEquals(p.stdout.read(), data)
-
-
-if __name__ == "__main__":
- cmd = sys.argv[1]
- if cmd == "fds":
- try:
- os.close(int(sys.argv[2]))
- print("False")
- except:
- print("True")
-
- elif cmd == "nofds":
- try:
- os.close(int(sys.argv[2]))
- print("True")
- except:
- print("False")
-
- elif cmd == "env":
- try:
- print(os.environ.get("TEST", "False"))
- except:
- print("False")
--
To view, visit
https://gerrit.ovirt.org/65407
To unsubscribe, visit
https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I9dc384d6e84ce5f09573be32ea6247c6ef834836
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer(a)redhat.com>