diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2021-10-05 20:24:20 +0200 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2021-10-05 20:24:20 +0200 |
commit | 5b4ee076dd570454eee99fb41cb09989501220ed (patch) | |
tree | f0ff07bc521ff2336ebae362e4183fad950cc84c | |
parent | 741c143ea371ef3ecf83254341f443182a9547f1 (diff) | |
download | psutil-5b4ee076dd570454eee99fb41cb09989501220ed.tar.gz |
move/rename tests re. to #1955
Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
-rw-r--r-- | HISTORY.rst | 2 | ||||
-rwxr-xr-x | psutil/tests/test_linux.py | 35 |
2 files changed, 14 insertions, 23 deletions
diff --git a/HISTORY.rst b/HISTORY.rst index ccc5c829..cd27633f 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -35,7 +35,7 @@ XXXX-XX-XX - 1919_: [Linux] sensors_battery() can raise TypeError on PureOS. - 1921_: [Windows] psutil.swap_memory() shows committed memory instead of swap - 1940_: [Linux] psutil does not handle ENAMETOOLONG when accessing process - file descriptors in procfs + file descriptors in procfs. (patch by Nikita Radchenko) - 1948_: Process' memoize_when_activated decorator was not thread-safe. (patch by Xuehai Pan) - 1953_: [Windows] disk_partitions() crashes due to insufficient buffer len. diff --git a/psutil/tests/test_linux.py b/psutil/tests/test_linux.py index 3fda7874..6c01edbd 100755 --- a/psutil/tests/test_linux.py +++ b/psutil/tests/test_linux.py @@ -1446,25 +1446,6 @@ class TestMisc(PsutilTestCase): assert psutil.pid_exists(os.getpid()) assert m.called - def test_get_proc_inodes_fd_broken(self): - # Simulate a case where /proc/{pid}/fd/{fd} symlink - # points to a file with full path longer than PATH_MAX - - def get_inodes(): - connections = psutil._pslinux.Connections() - connections._procfs_path = psutil._common.get_procfs_path() - return connections.get_proc_inodes(os.getpid()) - - p = psutil.Process() - files = p.open_files() - with open(self.get_testfn(), 'w'): - # give the kernel some time to see the new file - call_until(p.open_files, "len(ret) != %i" % len(files)) - patch_point = 'psutil._pslinux.os.readlink' - with mock.patch(patch_point, - side_effect=OSError(errno.ENAMETOOLONG, "")) as m: - assert not get_inodes() - assert m.called # ===================================================================== # --- sensors @@ -1849,10 +1830,10 @@ class TestProcess(PsutilTestCase): assert not files assert m.called - def test_open_files_fd_broken(self): + def test_open_files_enametoolong(self): # Simulate a case where /proc/{pid}/fd/{fd} symlink - # points to a file with full path longer than PATH_MAX - + # points to a file with full path longer than PATH_MAX, see: + # https://github.com/giampaolo/psutil/issues/1940 p = psutil.Process() files = p.open_files() with open(self.get_testfn(), 'w'): @@ -2100,6 +2081,16 @@ class TestProcess(PsutilTestCase): self.assertEqual(gids.saved, 1006) self.assertEqual(p._proc._get_eligible_cpus(), list(range(0, 8))) + def test_connections_enametoolong(self): + # Simulate a case where /proc/{pid}/fd/{fd} symlink points to + # a file with full path longer than PATH_MAX, see: + # https://github.com/giampaolo/psutil/issues/1940 + with mock.patch('psutil._pslinux.os.readlink', + side_effect=OSError(errno.ENAMETOOLONG, "")) as m: + p = psutil.Process() + assert not p.connections() + assert m.called + @unittest.skipIf(not LINUX, "LINUX only") class TestProcessAgainstStatus(PsutilTestCase): |