summaryrefslogtreecommitdiff
path: root/psutil/tests/__init__.py
Commit message (Collapse)AuthorAgeFilesLines
* do not blackify __all__blackGiampaolo Rodola2022-10-211-0/+2
|
* update HISTORY + give CREDITS for @arossert, @smoofra, @mayeut for #2102, ↵Giampaolo Rodola2022-10-211-1/+1
| | | | #2156, #2010
* fix: disk usage report on macOS 12+ (#2152)Matthieu Darbois2022-10-051-1/+33
|
* resolve conflictsGiampaolo Rodola2022-09-191-2/+2
|\ | | | | | | Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
| * Fix typosKian-Meng Ang2022-01-271-2/+2
| |
* | Merge branch 'master' of github.com:giampaolo/psutilGiampaolo Rodola2022-07-261-1/+1
|\ \
| * | docs: fix simple typo, repeadetly -> repeatedly (#2123)Tim Gates2022-07-141-1/+1
| | |
* | | subprocess; avoid using shell=True during testsGiampaolo Rodola2022-07-101-3/+4
|/ /
* | add flake8-quotes pluginGiampaolo Rodola2022-05-251-3/+3
| | | | | | | | Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
* | Drop Python 2.6 support (#2099)Hugo van Kemenade2022-04-161-5/+6
| | | | | | Signed-off-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
* | rename test functionsGiampaolo Rodola2022-04-101-5/+5
|/ | | | Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
* Automatically sort imports (isort CLI tool) (#2033)Giampaolo Rodola2021-12-141-2/+4
|
* PSUTIL_DEBUG: print file + line number for C ext modules (#2005)Giampaolo Rodola2021-10-261-0/+9
|
* tests: move per-module imports at the top of the file(s)Giampaolo Rodola2021-10-141-3/+3
| | | | Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
* Remove Travis and Cirrus, use GH also for FreeBSD (#1880)Giampaolo Rodola2020-11-151-10/+11
|
* Rewrite Linux prlimit() with ctypes (Linux wheels) (#1879)Giampaolo Rodola2020-11-151-22/+157
|
* If the batery is not available set it to false (#1717)Tomáš Chvátal2020-08-131-1/+1
|
* give CREDITS for #1768 and #1781Giampaolo Rodola2020-07-051-2/+1
|
* update personal site URLGiampaolo Rodola2020-06-161-3/+2
|
* [macOS] Fix zombie leak detection on (#1766)Giampaolo Rodola2020-05-251-0/+3
|
* Wheels 3 (#1764)Giampaolo Rodola2020-05-231-7/+13
|
* memleak test: retries 10 times on CI instead of 5Giampaolo Rodola2020-05-181-2/+2
|
* Wheels2 (#1761)Giampaolo Rodola2020-05-181-12/+53
|
* Have GitHub build wheels on commit (#1758)Grzegorz Bokota2020-05-161-2/+5
|
* #1758: fix github failuresGiampaolo Rodola2020-05-151-1/+1
|
* shorter testfnGiampaolo Rodola2020-05-151-3/+1
|
* always execute python memleak tests on linux (just fewer times)Giampaolo Rodola2020-05-131-5/+7
|
* put fds test in mem leak classGiampaolo Rodola2020-05-131-65/+54
|
* remove dead codeGiampaolo Rodola2020-05-131-6/+0
|
* Memory leak test: take fluctuations into account (#1757)Giampaolo Rodola2020-05-131-76/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Preamble ======= We have a [memory leak test suite](https://github.com/giampaolo/psutil/blob/e1ea2bccf8aea404dca0f79398f36f37217c45f6/psutil/tests/__init__.py#L897), which calls a function many times and fails if the process memory increased. We do this in order to detect missing `free()` or `Py_DECREF` calls in the C modules. When we do, then we have a memory leak. The problem ========== A problem we've been having for probably over 10 years, is the false positives. That's because the memory fluctuates. Sometimes it may increase (or even decrease!) due to how the OS handles memory, the Python's garbage collector, the fact that RSS is an approximation and who knows what else. So thus far we tried to compensate that by using the following logic: - warmup (call fun 10 times) - call the function many times (1000) - if memory increased before/after calling function 1000 times, then keep calling it for another 3 secs - if it still increased at all (> 0) then fail This logic didn't really solve the problem, as we still had occasional false positives, especially lately on FreeBSD. The solution ========= This PR changes the internal algorithm so that in case of failure (mem > 0 after calling fun() N times) we retry the test for up to 5 times, increasing N (repetitions) each time, so we consider it a failure only if the memory **keeps increasing** between runs. So for instance, here's a legitimate failure: ``` psutil.tests.test_memory_leaks.TestModuleFunctionsLeaks.test_disk_partitions ... Run #1: extra-mem=696.0K, per-call=3.5K, calls=200 Run #2: extra-mem=1.4M, per-call=3.5K, calls=400 Run #3: extra-mem=2.1M, per-call=3.5K, calls=600 Run #4: extra-mem=2.7M, per-call=3.5K, calls=800 Run #5: extra-mem=3.4M, per-call=3.5K, calls=1000 FAIL ``` If, on the other hand, the memory increased on one run (say 200 calls) but decreased on the next run (say 400 calls), then it clearly means it's a false positive, because memory consumption may be > 0 on second run, but if it's lower than the previous run with less repetitions, then it cannot possibly represent a leak (just a fluctuation): ``` psutil.tests.test_memory_leaks.TestModuleFunctionsLeaks.test_net_connections ... Run #1: extra-mem=568.0K, per-call=2.8K, calls=200 Run #2: extra-mem=24.0K, per-call=61.4B, calls=400 OK ``` Note about mallinfo() ================ Aka #1275. `mallinfo()` on Linux is supposed to provide memory metrics about how many bytes gets allocated on the heap by `malloc()`, so it's supposed to be way more precise than RSS and also [USS](http://grodola.blogspot.com/2016/02/psutil-4-real-process-memory-and-environ.html). In another branch were I exposed it, I verified that fluctuations still occur even when using `mallinfo()` though, despite less often. So that means even `mallinfo()` would not grant 100% stability.
* Add new TestFdsLeak test class (#1752)Giampaolo Rodola2020-05-061-49/+93
|
* have mem leak test class check num of fds/handlesGiampaolo Rodola2020-05-041-1/+23
|
* Refactor tests calling all process methods (process_namespace class) (#1749)Giampaolo Rodola2020-05-041-4/+225
| | | Over the years I have accumulated different unit-tests which use dir() to get all process methods and test them in different circumstances. This produced a lot of code duplication. With this PR I introduce 2 new test classes (process_namespace and system_namespace) which declare all the method names and arguments in a single place, removing a lot cruft and code duplication.
* Process wait() improvements (#1747)Giampaolo Rodola2020-05-031-18/+20
| | | | | | | | | | | | | | | | | | | | | | * `Process.wait()` on POSIX now returns an `enum` showing the negative which was used to terminate the process: ```python >>> import psutil >>> p = psutil.Process(9891) >>> p.terminate() >>> p.wait() <Negsignal.SIGTERM: -15> ``` * the return value is cached so that the exit code can be retrieved on then next call, mimicking `subprocess.Popen.wait()` * `Process` object provides more `status` and `exitcode` additional info on `str()` and `repr()`: ``` >>> proc psutil.Process(pid=12739, name='python3', status='terminated', exitcode=<Negsigs.SIGTERM: -15>, started='15:08:20') ``` Extra: * improved `wait()` doc * reverted #1736: `psutil.Popen` uses original `subprocess.Popen.wait` method (safer)
* Refactor process test utils methods (#1745)Giampaolo Rodola2020-05-011-13/+14
| | | ...in order to accomodate Cygwin implementation.
* Revert #1736: Popen inheriting from subprocess (#1744)Giampaolo Rodola2020-05-011-15/+6
|
* Per-test file cleanup and new PsutilTestCase (#1743)Giampaolo Rodola2020-04-301-66/+73
| | | | | Test files/dirs are now removed after each test. when invoked via self.get_testfn(). Until now test files were stored in a global variable and were removed at process exit, via atexit.register(), but this didn't work with parallel tests because the fork()ed workers use os._exit(0), preventing cleanup functions to run. All test classes now inherit from PsutilTestCase class, which provides the most important methods requiring an automatic cleanup (get_test_subprocess() and others).
* Test sub-processes cleanup and ProcessTestCase class (#1739)Giampaolo Rodola2020-04-281-82/+114
|
* create_zombie_proc() make it return parent so that we can kill zombieGiampaolo Rodola2020-04-281-5/+8
|
* psutil.Popen: inherit from subprocess + support wait(timeout=...) parameter ↵Giampaolo Rodola2020-04-281-10/+29
| | | | (#1736)
* add new termina() test utilGiampaolo Rodola2020-04-271-56/+73
|
* Merge branch 'master' into devreap-childrenGiampaolo Rodola2020-04-261-3/+13
|\
| * Parallel tests (UNIX) (#1709)Giampaolo Rodola2020-04-261-3/+13
| |
* | rename varGiampaolo Rodola2020-04-261-2/+2
|/
* trick to execute atexit functions in case of SIGTERMGiampaolo Rodola2020-04-251-21/+34
|
* Get rid of TESTFN global variable (#1734)Giampaolo Rodola2020-04-241-72/+58
|
* Backport python 3 super() (#1733)Giampaolo Rodola2020-04-241-3/+3
|
* MemoryLeakTest class enhancements (#1731)Giampaolo Rodola2020-04-231-2/+119
|
* Git hook for renamed/added/deleted files + flake8 print() + tidelift (#1704)Giampaolo Rodola2020-02-211-1/+1
|
* Add support for PyPy on Windows (#1686)Giampaolo Rodola2020-02-111-2/+4
|