diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2015-08-07 13:56:40 +0200 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2015-08-07 13:56:40 +0200 |
commit | e346655a5b750d31854641cad0baa92264c51a41 (patch) | |
tree | a40db8e07a40e9686d662a1d687564b6efc58f7a | |
parent | 3226e941cebd784f75af9bbc0d5ad13f635a1695 (diff) | |
download | psutil-e346655a5b750d31854641cad0baa92264c51a41.tar.gz |
yet another test for rlimit
-rw-r--r-- | test/test_psutil.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/test/test_psutil.py b/test/test_psutil.py index 954481c0..f9cb90a7 100644 --- a/test/test_psutil.py +++ b/test/test_psutil.py @@ -1509,6 +1509,8 @@ class TestProcess(unittest.TestCase): p.rlimit(psutil.RLIMIT_FSIZE, (1024, hard)) with open(TESTFN, "wb") as f: f.write(b"X" * 1024) + # write() or flush() doesn't always cause the exception + # but close() will. with self.assertRaises(IOError) as exc: with open(TESTFN, "wb") as f: f.write(b"X" * 1025) @@ -1533,6 +1535,19 @@ class TestProcess(unittest.TestCase): p.rlimit(psutil.RLIMIT_FSIZE, (soft, hard)) self.assertEqual(p.rlimit(psutil.RLIMIT_FSIZE), (soft, hard)) + @unittest.skipUnless(LINUX and RLIMIT_SUPPORT, + "only available on Linux >= 2.6.36") + def test_rlimit_infinity_value(self): + # RLIMIT_FSIZE should be RLIM_INFINITY, which will be a really + # big number on a platform with large file support. On these + # platforms we need to test that the get/setrlimit functions + # properly convert the number to a C long long and that the + # conversion doesn't raise an error. + p = psutil.Process() + soft, hard = p.rlimit(psutil.RLIMIT_FSIZE) + self.assertEqual(psutil.RLIM_INFINITY, hard) + p.rlimit(psutil.RLIMIT_FSIZE, (soft, hard)) + def test_num_threads(self): # on certain platforms such as Linux we might test for exact # thread number, since we always have with 1 thread per process, |