summaryrefslogtreecommitdiff
path: root/psutil/tests
Commit message (Collapse)AuthorAgeFilesLines
* fix typos and some other minor bugs (#2253)HEADmastercui fliter2023-05-092-3/+3
| | | Signed-off-by: cui fliter <imcusg@gmail.com>
* skip who CLI related test if necessaryGiampaolo Rodola2023-05-021-1/+2
|
* SunOS: fix some C compilation warningsGiampaolo Rodola2023-04-222-8/+10
| | | | Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
* fix failing users() test; update HISTORY; give CREDITS to @0-wiz-0 for #2241Giampaolo Rodola2023-04-201-2/+9
| | | | Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
* C refact: remove useless cmdline / cwd / environ layers. Call direct functionsGiampaolo Rodola2023-04-181-0/+0
|
* Add CI testing for OpenBSD and NetBSD (#2240)Giampaolo Rodola2023-04-171-0/+1
|
* Fix #2239 / proc name(): don't fail with ZombieProcess on cmdline()Giampaolo Rodola2023-04-171-2/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A recent failure observed on OpenBSD led me to an interesting consideration. ``` ====================================================================== ERROR: psutil.tests.test_process.TestProcess.test_long_name ---------------------------------------------------------------------- Traceback (most recent call last): File "/vagrant/psutil/psutil/_psbsd.py", line 566, in wrapper return fun(self, *args, **kwargs) File "/vagrant/psutil/psutil/_psbsd.py", line 684, in cmdline return cext.proc_cmdline(self.pid) ProcessLookupError: [Errno 3] No such process During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/vagrant/psutil/psutil/tests/test_process.py", line 751, in test_long_name self.assertEqual(p.name(), os.path.basename(testfn)) File "/vagrant/psutil/psutil/__init__.py", line 628, in name cmdline = self.cmdline() File "/vagrant/psutil/psutil/__init__.py", line 681, in cmdline return self._proc.cmdline() File "/vagrant/psutil/psutil/_psbsd.py", line 569, in wrapper raise ZombieProcess(self.pid, self._name, self._ppid) psutil.ZombieProcess: PID still exists but it's a zombie (pid=48379) ---------------------------------------------------------------------- ``` The exception above occurs sporadically. It originates from `sysctl (KERN_PROC_ARGV)`: https://github.com/giampaolo/psutil/blob/0a81fa089fd4b25b4b7ee71ed39213b83f73c052/psutil/arch/openbsd/proc.c#L149 The error per se does not represent a bug in the OpenBSD `cmdline ()` implemention because the process **really** is a zombie at that point (I'm not sure why it's a zombie - this seems only to occur only on OpenBSD for this specific test case - but that's not the point). The interesting thing is that the test calls process `name()` (which succeeds, despite it's a zombie process), but since the process name is too long it gets truncated to 15 chars (this is a UNIX thing) so psutil tries to guess the remaining characters from the process `cmdline()`, which fails: https://github.com/giampaolo/psutil/blob/0a81fa089fd4b25b4b7ee71ed39213b83f73c052/psutil/__init__.py#L623-L630 The problem to fix here is that, if `name()` succeeds but `cmdline()` fails, we should not raise `ZombieProcess`: we should simply return the (truncated) process `name()` instead, because that is better than nothing. Not on OpenBSD but on all platforms. Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
* fix #2238 if cwd() cannot be determined always return "" instead of NoneGiampaolo Rodola2023-04-172-13/+10
|
* Fix #2237, OpenBSD, cwd(): return None instead of FileNotFoundErrorGiampaolo Rodola2023-04-162-3/+2
|
* fix NetBSD test failure + add test for cached memGiampaolo Rodola2023-04-131-0/+12
| | | | Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
* OpenBSD: rewrite net_connections() from scratch (#2230)Giampaolo Rodola2023-04-132-21/+6
|
* Get Windows percent swap usage from performance counters (#2160)Daniel Widdis2023-04-131-0/+21
| | | Signed-off-by: Daniel Widdis <widdis@gmail.com>
* fix users() test on OpenBSDGiampaolo Rodola2023-04-121-5/+7
| | | | Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
* fix some tests on BSD platformsGiampaolo Rodola2023-04-124-5/+14
|
* [POSIX] psutil.users() loses precision for "started" attribute #2225 (#2226)Giampaolo Rodola2023-04-111-6/+34
|
* Fix Linux test: allow '-dirty' or other version postfixes (#2221)Mark Asselstine2023-04-051-1/+1
| | | | | | | | | | | | | | | | | It is possible that 'free -V' will return a version that includes a postfix such as '-dirty'. For example procps-ng will explicitly add this when building from git: https://gitlab.com/procps-ng/procps/-/blob/master/local/git-version-gen#L154 Process the version string to drop these string postfixes from the version tuple, failing to do so will result in the test failing File ".../psutil/tests/test_linux.py", line 204, in get_free_version_info return tuple(map(int, out.split()[-1].split('.'))) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ValueError: invalid literal for int() with base 10: '3-dirty' Signed-off-by: Mark Asselstine <mark.asselstine@windriver.com>
* Fix pylint warnings / cleanup (#2218)Giampaolo Rodola2023-04-0112-96/+53
|
* [Linux] guess `available` virtual_memory() if kernel says it's 0 (#2052)Giampaolo Rodola2023-03-291-36/+64
| | | Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
* fix linux testsGiampaolo Rodola2023-03-281-3/+0
|
* When raising warning, always use stacklevel=2Giampaolo Rodola2023-03-271-2/+2
| | | | | | | | | | B028: No explicit stacklevel argument found. The warn method from the warnings module uses a stacklevel of 1 by default. This will only show a stack trace for the line on which the warn method is called. It is therefore recommended to use a stacklevel of 2 or greater to provide more information to the user. Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
* Win: fix running tests in a virtual environment (#2216)Matthieu Darbois2023-03-274-18/+30
| | | | | | | | | | | | On windows, starting with python 3.7, virtual environments use a venvlauncher startup process This does not play well when counting spawned processes or when relying on the pid of the spawned process to do some checks e.g. connection check per pid This commit detects this situation and uses the base python executable to spawn processes when required. Signed-off-by: mayeut <mayeut@users.noreply.github.com>
* CI: fix TestScripts tests failing due to ambiguous SCRIPTS_DIR (#2211)Matthieu Darbois2023-03-181-1/+4
| | | | | | | | | | | | Tests are being run with psutil installed in a virtual environment within cibuildwheel builds. The scripts folder is not being found in this installation & thus, those tests are skipped. This commit allows to pass the path of the scripts folder through an environment variable & re-enables those tests. Signed-off-by: mayeut <mayeut@users.noreply.github.com>
* disable flaky test + small Makefile refactGiampaolo Rodola2023-01-241-11/+9
|
* fix make test-coverage targetGiampaolo Rodola2022-12-302-1/+4
|
* write extensive test suite for @memoize decoratorGiampaolo Rodola2022-12-151-2/+104
|
* #2164: fix compilation failures on linux < 2.6.27 / CentOS 5 (#2171)Giampaolo Rodola2022-11-101-1/+1
|
* add windows test for free physical mem #2074Giampaolo Rodola2022-10-211-0/+39
|
* fix OSX tests broken by accidentGiampaolo Rodola2022-10-211-2/+2
|
* update HISTORY + give CREDITS for @arossert, @smoofra, @mayeut for #2102, ↵Giampaolo Rodola2022-10-212-3/+3
| | | | #2156, #2010
* fix: linter issues from #2146 (#2155)Matthieu Darbois2022-10-183-3/+6
| | | Signed-off-by: mayeut <mayeut@users.noreply.github.com>
* chore: skip test_cpu_freq on macOS arm64 (#2146)Matthieu Darbois2022-10-184-0/+12
|
* fix: race condition in test_posix.TestProcess.test_cmdline (#2153)Matthieu Darbois2022-10-081-0/+6
|
* fix: disk usage report on macOS 12+ (#2152)Matthieu Darbois2022-10-053-3/+43
|
* #2084: document limitations of environ() on macOS Big SurGiampaolo Rodola2022-09-201-2/+3
|
* #2104 / TestFetchAllProcesses: don't use process pool on CI (fix deadlock)Giampaolo Rodola2022-09-201-4/+15
|
* remove fix_flake8.py re-introduced by accidentGiampaolo Rodola2022-09-191-1/+1
| | | | Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
* resolve conflictsGiampaolo Rodola2022-09-195-7/+7
|\ | | | | | | Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
| * Fix typosKian-Meng Ang2022-01-276-9/+9
| |
* | net_if_stats() -> flags: do not return unicode on Python 2 (#2142)Matthieu Darbois2022-09-191-0/+9
| | | | | | | | | | | | Do not use unicode string for network interface flags on Python 2 Update network interface flags tests to work on CentOS 6 (CI tests are currently failing) Signed-off-by: mayeut <mayeut@users.noreply.github.com>
* | add ifconfig test case for NIC flags re. to #2037Giampaolo Rodola2022-09-061-0/+21
| |
* | Add in support for network interface flags. (#2037)Chris Lalancette2022-09-061-1/+2
| | | | | | | | Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
* | fix venvrelease-5.9.2Giampaolo Rodola2022-09-041-1/+1
| |
* | linux: skip test if ifconfig CLI is not installedGiampaolo Rodola2022-07-261-0/+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-252-4/+4
| | | | | | | | Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
* | introduce flake8-bugbear code checkerGiampaolo Rodola2022-05-251-1/+1
| | | | | | | | Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
* | [Linux] Speedup `Process.full_memory_info()` (#2108)Giampaolo Rodola2022-05-181-22/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `Process.memory_full_info()` (reporting proecss USS/PSS/Swap memory) now reads ``/proc/pid/smaps_rollup`` instead of ``/proc/pids/smaps`` which makes it 5 times faster. Without patch: ``` ~/svn/psutil {linux-smaps-rollup}$ python3 -m timeit -s "import psutil; p = psutil.Process()" "p.memory_full_info()" 500 loops, best of 5: 518 usec per loop ``` With patch (5 times faster): ``` ~/svn/psutil {linux-smaps-rollup}$ python3 -m timeit -s "import psutil; p = psutil.Process()" "p.memory_full_info()" 2000 loops, best of 5: 111 usec per loop ``` ---- `make test-memleaks` suite, who heavily rely on `Process.memory_full_info()`, also received a nice speedup: Before patch: ``` $ make test-memleaks ---------------------------------------------------------------------- Ran 99 tests in 1.646s OK (skipped=9) SUCCESS ``` After patch: ``` $ make test-memleaks ---------------------------------------------------------------------- Ran 99 tests in 1.195s OK (skipped=9) SUCCESS ```
* | Drop Python 2.6 support (#2099)Hugo van Kemenade2022-04-1616-20/+21
| | | | | | Signed-off-by: Hugo van Kemenade <hugovk@users.noreply.github.com>