nikademus79 / psutil

Automatically exported from code.google.com/p/psutil
Other
0 stars 0 forks source link

New _get_num_cpus doesn't work on amrel/sparc #200

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hi,
in psutil 0.3.0 _get_num_cpus has changed in a way that's not working anymore 
on architectures with a different format of /proc/cpuinfo, in my case (Debian) 
they are armel and sparc. That makes the testsuite failing.

You can find the reference for the failed tests at: 
https://buildd.debian.org/status/package.php?p=python-psutil (just look at the 
mentioned archs).

I'm attaching an example of cpuinfo on those archs, in order to let you find 
the proper solution.

Thanks,
Sandro

Original issue reported on code.google.com by matrixhasu on 26 Aug 2011 at 7:39

Attachments:

GoogleCodeExporter commented 8 years ago
This is similar to issue 188.
By looking at your attachments, it seems /proc/cpuinfo on those architectures 
is different every time and does not provide a reliable form to parse it.

Previous version (0.2.1) wasn't failing because None was returned instead of 
RuntimeError.

Another way to determine the number of CPUs could be reading /proc/stat and 
searching for lines starting with "cpu#" where "#" is a number.  I did this 
change in r1112.
Could you plese tell me if this fixed the problem?
Also, I'd like to know how tests goes on such architectures.
Could you please attach the output of the test suite by doing:

$ python setup.py install
$ python test/test_psutil.py

...?
Thanks in advance.

Original comment by g.rodola on 26 Aug 2011 at 9:43

GoogleCodeExporter commented 8 years ago
The test has passed, some other failed, but please note that the tests weren't 
run as root.

Here's the output for sparc:

morph@smetana:~/psutil-read-only$ PYTHONPATH=build/lib.linux-sparc64-2.6/ 
python test/test_psutil.py
test_BOOT_TIME (__main__.TestCase) ... ok
test_Popen (__main__.TestCase) ... ok
test_TOTAL_PHYMEM (__main__.TestCase) ... ok
test__str__ (__main__.TestCase) ... ok
test_cmdline (__main__.TestCase) ... ok
test_connection_fromfd (__main__.TestCase) ... FAIL
test_cpu_percent (__main__.TestCase) ... ok
test_cpu_times (__main__.TestCase) ... ok
test_cpu_times2 (__main__.TestCase) ... ok
test_create_time (__main__.TestCase) ... ok
test_deprecated_memory_functions (__main__.TestCase) ... ok
test_disk_partitions (__main__.TestCase) ... ok
test_disk_usage (__main__.TestCase) ... ok
test_eq (__main__.TestCase) ... ok
test_exe (__main__.TestCase) ... ok
test_fetch_all (__main__.TestCase) ... ok
test_get_children (__main__.TestCase) ... ok
test_get_connections (__main__.TestCase) ... FAIL
test_get_connections_all (__main__.TestCase) ... ERROR
test_get_io_counters (__main__.TestCase) ... ok
test_get_memory_info (__main__.TestCase) ... ok
test_get_memory_percent (__main__.TestCase) ... ok
test_get_num_threads (__main__.TestCase) ... ok
test_get_open_files (__main__.TestCase) ... ok
test_get_open_files2 (__main__.TestCase) ... ok
test_get_pid_list (__main__.TestCase) ... ok
test_get_process_list (__main__.TestCase) ... ok
test_get_set_ionice (__main__.TestCase) ... ok
test_get_threads (__main__.TestCase) ... ok
test_getcwd (__main__.TestCase) ... ok
test_getcwd_2 (__main__.TestCase) ... ok
test_gids (__main__.TestCase) ... ok
test_invalid_pid (__main__.TestCase) ... ok
test_is_running (__main__.TestCase) ... ok
test_kill (__main__.TestCase) ... ok
test_name (__main__.TestCase) ... FAIL
test_nice (__main__.TestCase) ... ERROR
test_parent_ppid (__main__.TestCase) ... ok
test_phymem_buffers (__main__.TestCase) ... ok
test_phymem_usage (__main__.TestCase) ... ok
test_pid (__main__.TestCase) ... ok
test_pid_0 (__main__.TestCase) ... ok
test_pid_exists (__main__.TestCase) ... ok
test_pid_exists_2 (__main__.TestCase) ... ok
test_process_iter (__main__.TestCase) ... ok
test_send_signal (__main__.TestCase) ... ok
test_status (__main__.TestCase) ... ok
test_suspend_resume (__main__.TestCase) ... ok
test_sys_cpu_percent (__main__.TestCase) ... ok
test_sys_cpu_percent_compare (__main__.TestCase) ... ok
test_sys_cpu_times (__main__.TestCase) ... ok
test_sys_cpu_times2 (__main__.TestCase) ... ok
test_sys_per_cpu_percent (__main__.TestCase) ... ok
test_sys_per_cpu_times (__main__.TestCase) ... ok
test_sys_per_cpu_times2 (__main__.TestCase) ... ok
test_terminal (__main__.TestCase) ... ok
test_terminate (__main__.TestCase) ... ok
test_test (__main__.TestCase) ... ok
test_uids (__main__.TestCase) ... ok
test_username (__main__.TestCase) ... ok
test_virtmem_usage (__main__.TestCase) ... ok
test_wait (__main__.TestCase) ... ok
test_wait_non_children (__main__.TestCase) ... ok
test_wait_timeout_0 (__main__.TestCase) ... ok
test_zombie_process (__main__.TestCase) ... ok
test_get_pids (_posix.PosixSpecificTestCase) ... ok
test_process_cmdline (_posix.PosixSpecificTestCase) ... ok
test_process_exe (_posix.PosixSpecificTestCase) ... ok
test_process_gid (_posix.PosixSpecificTestCase) ... ok
test_process_name (_posix.PosixSpecificTestCase) ... ok
test_process_parent_pid (_posix.PosixSpecificTestCase) ... ok
test_process_rss_memory (_posix.PosixSpecificTestCase) ... ok
test_process_uid (_posix.PosixSpecificTestCase) ... ok
test_process_username (_posix.PosixSpecificTestCase) ... ok
test_process_vsz_memory (_posix.PosixSpecificTestCase) ... ok
test_cached_phymem (_linux.LinuxSpecificTestCase) ... ok
test_disks (_linux.LinuxSpecificTestCase) ... ok
test_phymem_buffers (_linux.LinuxSpecificTestCase) ... ok

======================================================================
ERROR: test_get_connections_all (__main__.TestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test/test_psutil.py", line 147, in inner
    return fun(self, *args, **kwargs)
  File "test/test_psutil.py", line 1101, in test_get_connections_all
    s.bind((conn.local_address[0], 0))
  File "<string>", line 1, in bind
error: [Errno 49] Cannot assign requested address

======================================================================
ERROR: test_nice (__main__.TestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test/test_psutil.py", line 837, in test_nice
    p.nice = first_nice
  File "/home/morph/psutil-read-only/build/lib.linux-sparc64-2.6/psutil/__init__.py", line 210, in nice
    return self._platform_impl.set_process_nice(value)
  File "/home/morph/psutil-read-only/build/lib.linux-sparc64-2.6/psutil/_pslinux.py", line 270, in wrapper
    raise AccessDenied(self.pid, self._process_name)
AccessDenied: (pid=32688)

======================================================================
FAIL: test_connection_fromfd (__main__.TestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test/test_psutil.py", line 147, in inner
    return fun(self, *args, **kwargs)
  File "test/test_psutil.py", line 1002, in test_connection_fromfd
    self.assertEqual(dupsock.getsockname(), conn.local_address)
AssertionError: ('127.0.0.1', 41449) != ('1.0.0.127', 41449)

======================================================================
FAIL: test_get_connections (__main__.TestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test/test_psutil.py", line 147, in inner
    return fun(self, *args, **kwargs)
  File "test/test_psutil.py", line 974, in test_get_connections
    self.assertEqual(ip, '127.0.0.1')
AssertionError: '1.0.0.127' != '127.0.0.1'

======================================================================
FAIL: test_name (__main__.TestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test/test_psutil.py", line 795, in test_name
    os.path.basename(sys.executable))
AssertionError: 'python2.6' != 'python'

----------------------------------------------------------------------
Ran 78 tests in 4.062s

FAILED (failures=3, errors=2)
/usr/lib/python2.6/atexit.py:24: RuntimeWarning: Couldn't run limited user 
tests (super-user privileges are required)
  func(*targs, **kargs)

(nice the 127.0.0.1 -> 1.0.0.127 :))

And here's the one for armel:

morph@abel:~/psutil-read-only$ PYTHONPATH=build/lib.linux-armv5tel-2.6/ python 
test/test_psutil.py
test_BOOT_TIME (__main__.TestCase) ... ok
test_Popen (__main__.TestCase) ... ok
test_TOTAL_PHYMEM (__main__.TestCase) ... ok
test__str__ (__main__.TestCase) ... ok
test_cmdline (__main__.TestCase) ... ok
test_connection_fromfd (__main__.TestCase) ... ok
test_cpu_percent (__main__.TestCase) ... ok
test_cpu_times (__main__.TestCase) ... ok
test_cpu_times2 (__main__.TestCase) ... ok
test_create_time (__main__.TestCase) ... ok
test_deprecated_memory_functions (__main__.TestCase) ... ok
test_disk_partitions (__main__.TestCase) ... ok
test_disk_usage (__main__.TestCase) ... ok
test_eq (__main__.TestCase) ... ok
test_exe (__main__.TestCase) ... ok
test_fetch_all (__main__.TestCase) ... ok
test_get_children (__main__.TestCase) ... ok
test_get_connections (__main__.TestCase) ... ok
test_get_connections_all (__main__.TestCase) ... ok
test_get_io_counters (__main__.TestCase) ... ok
test_get_memory_info (__main__.TestCase) ... ok
test_get_memory_percent (__main__.TestCase) ... ok
test_get_num_threads (__main__.TestCase) ... ok
test_get_open_files (__main__.TestCase) ... ok
test_get_open_files2 (__main__.TestCase) ... ok
test_get_pid_list (__main__.TestCase) ... ok
test_get_process_list (__main__.TestCase) ... ok
test_get_set_ionice (__main__.TestCase) ... ok
test_get_threads (__main__.TestCase) ... ok
test_getcwd (__main__.TestCase) ... ok
test_getcwd_2 (__main__.TestCase) ... ok
test_gids (__main__.TestCase) ... ok
test_invalid_pid (__main__.TestCase) ... ok
test_is_running (__main__.TestCase) ... ok
test_kill (__main__.TestCase) ... ok
test_name (__main__.TestCase) ... FAIL
test_nice (__main__.TestCase) ... ERROR
test_parent_ppid (__main__.TestCase) ... ok
test_phymem_buffers (__main__.TestCase) ... ok
test_phymem_usage (__main__.TestCase) ... ok
test_pid (__main__.TestCase) ... ok
test_pid_0 (__main__.TestCase) ... ok
test_pid_exists (__main__.TestCase) ... ok
test_pid_exists_2 (__main__.TestCase) ... ok
test_process_iter (__main__.TestCase) ... ok
test_send_signal (__main__.TestCase) ... ok
test_status (__main__.TestCase) ... ok
test_suspend_resume (__main__.TestCase) ... ok
test_sys_cpu_percent (__main__.TestCase) ... ok
test_sys_cpu_percent_compare (__main__.TestCase) ... ok
test_sys_cpu_times (__main__.TestCase) ... ok
test_sys_cpu_times2 (__main__.TestCase) ... ok
test_sys_per_cpu_percent (__main__.TestCase) ... ok
test_sys_per_cpu_times (__main__.TestCase) ... ok
test_sys_per_cpu_times2 (__main__.TestCase) ... ok
test_terminal (__main__.TestCase) ... ok
test_terminate (__main__.TestCase) ... ok
test_test (__main__.TestCase) ... ok
test_uids (__main__.TestCase) ... ok
test_username (__main__.TestCase) ... ok
test_virtmem_usage (__main__.TestCase) ... ok
test_wait (__main__.TestCase) ... ok
test_wait_non_children (__main__.TestCase) ... ok
test_wait_timeout_0 (__main__.TestCase) ... ok
test_zombie_process (__main__.TestCase) ... ok
test_get_pids (_posix.PosixSpecificTestCase) ... ok
test_process_cmdline (_posix.PosixSpecificTestCase) ... ok
test_process_exe (_posix.PosixSpecificTestCase) ... ok
test_process_gid (_posix.PosixSpecificTestCase) ... ok
test_process_name (_posix.PosixSpecificTestCase) ... ok
test_process_parent_pid (_posix.PosixSpecificTestCase) ... ok
test_process_rss_memory (_posix.PosixSpecificTestCase) ... ok
test_process_uid (_posix.PosixSpecificTestCase) ... ok
test_process_username (_posix.PosixSpecificTestCase) ... ok
test_process_vsz_memory (_posix.PosixSpecificTestCase) ... ok
test_cached_phymem (_linux.LinuxSpecificTestCase) ... ok
test_disks (_linux.LinuxSpecificTestCase) ... ok
test_phymem_buffers (_linux.LinuxSpecificTestCase) ... ok

======================================================================
ERROR: test_nice (__main__.TestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test/test_psutil.py", line 837, in test_nice
    p.nice = first_nice
  File "/home/morph/psutil-read-only/build/lib.linux-armv5tel-2.6/psutil/__init__.py", line 210, in nice
    return self._platform_impl.set_process_nice(value)
  File "/home/morph/psutil-read-only/build/lib.linux-armv5tel-2.6/psutil/_pslinux.py", line 270, in wrapper
    raise AccessDenied(self.pid, self._process_name)
AccessDenied: (pid=25758)

======================================================================
FAIL: test_name (__main__.TestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test/test_psutil.py", line 795, in test_name
    os.path.basename(sys.executable))
AssertionError: 'python2.6' != 'python'

----------------------------------------------------------------------
Ran 78 tests in 6.285s

FAILED (failures=1, errors=1)
/usr/lib/python2.6/atexit.py:24: RuntimeWarning: Couldn't run limited user 
tests (super-user privileges are required)
  func(*targs, **kargs)

Original comment by matrixhasu on 26 Aug 2011 at 11:54

GoogleCodeExporter commented 8 years ago
It seems Process.get_connections() is broken on sparc, reporting a reversed IP 
address.
I think I cannot do anything unless I put hands on a sparc box.
As for now I'm labeling this out as fixed.
Thanks for the report.

Original comment by g.rodola on 27 Aug 2011 at 5:26

GoogleCodeExporter commented 8 years ago
Thanks! I followed up the sparc get_connections() issue on 
http://code.google.com/p/psutil/issues/detail?id=201

Original comment by matrixhasu on 28 Aug 2011 at 2:57

GoogleCodeExporter commented 8 years ago

Original comment by g.rodola on 21 Oct 2011 at 11:44

GoogleCodeExporter commented 8 years ago

Original comment by g.rodola on 21 Oct 2011 at 11:45

GoogleCodeExporter commented 8 years ago

Original comment by g.rodola on 29 Oct 2011 at 3:44

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Updated csets after the SVN -> Mercurial migration:
r1112 == revision a64119559e0d

Original comment by g.rodola on 2 Mar 2013 at 12:02