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

Failing tests on OS X #175

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

Failing tests on OS X #175

giampaolo opened this issue May 23, 2014 · 12 comments

Comments

@giampaolo
Copy link
Owner

From jcscoob...@gmail.com on June 23, 2011 01:44:15

What steps will reproduce the problem?  
1. python setup.py build
2. python test/test_psutil.py 

What is the expected output?  


What do you see instead?  
I expect all implemented OS X tests to pass while running on OS X but instead I 
see that the following tests are failing for methods that are not new:

* test_get_connections_all
* test_phymem_usage

I also see this test is failing but it is related to Issue 125 where per-cpu 
times is not implemented on OS X yet:

* test_sys_per_cpu_times2

Note: Issue 125 has a patch submitted to implement per-cpu times and yet 
test_sys_per_cpu_times2 still fails.  It seems that the timeout in between 
gathering per-cpu tests needs to be greater to give a better chance for 
difference. 

What version of psutil are you using? What Python version?  
I'm using trunk ( r1041 ). 

On what operating system? Is it 32bit or 64bit version?  
OS X 10.6.7 (64-bit) Please provide any additional information below.

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

@giampaolo
Copy link
Owner Author

From jcscoob...@gmail.com on June 22, 2011 16:53:11

Attached is a patch that fixes test_phymem_usage and test_sys_per_cpu_times2.  
I will look into test_get_connections_all next.

Note: Even after all this work is done there will be two failing tests on OS X: 
test_disk_partitions and test_disk_usage.  The work for these is actually being 
tracked in Issue 174 and Issue 172 respectively.

Attachment: fix_tests_on_osx.patch

@giampaolo
Copy link
Owner Author

From jcscoob...@gmail.com on June 22, 2011 21:17:35

I have test_get_connections_all passing on OS X.  It seems that when you use 0 
or '' for the host or port for socket.bind(tuple) Python resorts to the OS to 
dictate how it connects.  While your test checks for "::1" for the local IP 
(127.0.0.1 in IPv4), on OS X 10.6.7 it's listening on "::" (0.0.0.0 in IPv4).  
The simple change would be to check that the local address is in ["::", "::1"] 
for the TCP and UDP tests for IPv6 support.  That being said, I have this fixed 
locally but since I have two patches in limbo already, I'll hold off on 
submitting any other diff to avoid change collision.

@giampaolo
Copy link
Owner Author

From g.rodola on June 27, 2011 01:16:39

Hi and thanks for the interest.
In r1043 I tried to fix test_phymem_usage and test_sys_per_cpu_times2.
I haven't checked though, since I got no OSX to test against at the moment.
Feel free to provide a patch for test_connections.

Status: Started

@giampaolo
Copy link
Owner Author

From jcscoob...@gmail.com on June 27, 2011 09:07:01

I'm trying to rerun the tests and I think the fix disk usage committed is 
causing an issue.

python test/test_psutil.py
Traceback (most recent call last):
  File "test/test_psutil.py", line 29, in <module>
    import psutil
  File 
"/Users/jwhitlock/development/python/psutil/build/lib.macosx-10.6-universal-2.6/psutil/__init__.py",
 line 85, in <module>
    TOTAL_PHYMEM = _psplatform.phymem_usage()[0]
  File 
"/Users/jwhitlock/development/python/psutil/build/lib.macosx-10.6-universal-2.6/psutil/_psosx.py",
 line 32, in phymem_usage
    return ntuple_sysmeminfo(total, used, free, percent)
NameError: global name 'percent' is not defined

I'll commit a fix with my next patch.

@giampaolo
Copy link
Owner Author

From jcscoob...@gmail.com on June 27, 2011 09:14:36

Attached is a patch that fixes the  test_get_connections_all and the broken 
phymem_usage for OS X.  I notice that test_sys_per_cpu_times2 is still failing 
because 0.1s is not enough time for CPU variance to differ by 0.5%.  I can only 
assume this is related to the system having multiple CPUs and maybe one of the 
CPUs hasn't differed much.  I attached a patch earlier that changed the sleep 
timeout to allow for more variance but it wasn't committed.  I went ahead an 
changed the time.sleep in test_sys_per_cpu_times2 so that tests pass locally 
other than the new API for partition information.

Attachment: fix_phymem_and_connections_all2_tests.patch

@giampaolo
Copy link
Owner Author

From jcscoob...@gmail.com on June 27, 2011 09:18:41

I lied, I didn't change test_sys_per_cpu_times2 to have a longer sleep time but 
you should get the idea.  I have a new i7 with 4 real cores and 8 total 
virtual.  (I say 8 virtual because OS X reports 8 CPUs in Activity Monitor due 
to the i7 supporting Hyper-Threading ( http://support.apple.com/kb/HT4180 ).  I 
think that since this system has so many reported CPUs, maybe one/more of the 
CPUs aren't changing much or at all in the 0.1 sleep.

@giampaolo
Copy link
Owner Author

From g.rodola on June 27, 2011 09:32:44

Ok I managed to install OSX on virtual box.
In r1045 I fixed the NameError exception and the connections-related test.

> I notice that test_sys_per_cpu_times2 is still failing because 0.1s 
> is not enough time for CPU variance to differ by 0.5

What thereshold is working for you? 
time.sleep(10) is way too much time to wait.
Does this change work for you?

- if not difference >= 0.05:
+ if not difference >= 0.01:

@giampaolo
Copy link
Owner Author

From jcscoob...@gmail.com on June 27, 2011 09:42:09

Okay, I looked into this more and 0.5 will fix test_sys_cpu_times2.  Where the 
problem lies is that in test_sys_per_cpu_times2, it's probably good but not all 
cores are differing by 0.05% which is why the test fails.  What if we bumped 
the sleep to 0.5 and in test_sys_per_cpu_times2 we test that at least one CPU 
varies by 0.05% instead of requiring all CPUs vary by that much?

@giampaolo
Copy link
Owner Author

From g.rodola on June 27, 2011 09:46:16

What about now ( r1046 )?

@giampaolo
Copy link
Owner Author

From jcscoob...@gmail.com on June 27, 2011 09:48:52

That seemed to do it.

@giampaolo
Copy link
Owner Author

From g.rodola on June 27, 2011 10:00:45

Cool. Closing out as fixed.

Status: Fixed

@giampaolo
Copy link
Owner Author

From g.rodola on March 02, 2013 04:01:17

Updated csets after the SVN -> Mercurial migration: r1041 == revision 
d2eb417fbb07 r1043 == revision 11ffad66d82d r1045 == revision c27ef22ba263 
r1046 == revision 1301c7d413ae

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