Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
giampaolo opened this issue May 23, 2014 · 9 comments
Closed

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

giampaolo opened this issue May 23, 2014 · 9 comments

Comments

@giampaolo
Copy link
Owner

From matrixhasu on August 26, 2011 21:39:54

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

Attachment: cpuinfo_armel cpuinfo_sparc

Original issue: http://code.google.com/p/psutil/issues/detail?id=200

@giampaolo
Copy link
Owner Author

From g.rodola on August 26, 2011 14:43:17

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.

Status: Accepted
Labels: OpSys-Linux Crash

@giampaolo
Copy link
Owner Author

From matrixhasu on August 26, 2011 16:54:07

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...

@giampaolo
Copy link
Owner Author

From matrixhasu on August 26, 2011 16:54:07

...__.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)

@giampaolo
Copy link
Owner Author

From g.rodola on August 27, 2011 10:26:22

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.

Status: FixedInSVN
Labels: Milestone-0.3.1

@giampaolo
Copy link
Owner Author

From matrixhasu on August 28, 2011 07:57:31

Thanks! I followed up the sparc get_connections() issue on 
https://code.google.com/p/psutil/issues/detail?id=201

@giampaolo
Copy link
Owner Author

From g.rodola on October 21, 2011 16:44:17

Labels: -Milestone-0.3.1

@giampaolo
Copy link
Owner Author

From g.rodola on October 21, 2011 16:45:27

Labels: Milestone-0.4.0

@giampaolo
Copy link
Owner Author

From g.rodola on October 28, 2011 20:44:14

Status: Fixed

@giampaolo
Copy link
Owner Author

From g.rodola on March 02, 2013 04:02:58

Updated csets after the SVN -> Mercurial migration: r1112 == revision 
a64119559e0d

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant