bobber6467 / python-nose

Automatically exported from code.google.com/p/python-nose
0 stars 0 forks source link

nose misidentifies files as executable on some OSes (Solaris, AIX) #423

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Run nosetests on solaris 10 sparc or AIX 7.l

What is the expected output? What do you see instead?
I expect the tests to run (they run on other operating systems).
Instead nose runs 0 tests, and only running them with --exe works, although 
they do not have execute permissions.

Actually, as it turns out, only tests that HAS execute permissions are run.

As Kumar Mcmillan suggested, I ran the following
>>> import os
>>> os.access("test_something.py", os.X_OK)
True

and that's probably the root cause of the bug.

What version of the product are you using? On what operating system?
python 2.6.2
nose 1.0.0

Noticed this bug both on Solaris 10 sparc and on AIX 7.1
Maybe there are more OSes that behave that way.

Original issue reported on code.google.com by yoni...@gmail.com on 27 May 2011 at 7:47

GoogleCodeExporter commented 8 years ago
What is the output of ls -l test_something.py on the Solaris machine?

Also, do you know the Python code for checking if a file is executable on 
Solaris?

Original comment by kumar.mcmillan on 29 May 2011 at 4:21

GoogleCodeExporter commented 8 years ago
OK something additional info I noticed:
When running nosetests test_something.py directly, it runs the tests well.
Only when running nosetests . (recursively), it skips the file.

Maybe it makes sense because only this way skipping executable works, but maybe 
it isn't - just letting you know.

Now, about ls -l:
-rw-r--r--   1 root     root        7120 May 11 09:30 test_something.py

About determining if file is executable in solaris:

>>> import os
>>> import stat
>>> def is_executable(file):
...     st = os.stat(file)
...     return bool(st.st_mode & stat.S_IXUSR)
... 

Original comment by yoni...@gmail.com on 30 May 2011 at 6:50

GoogleCodeExporter commented 8 years ago
This is a bug in Python and only occurs when Python is executed as root.

Original comment by adiroi...@gmail.com on 2 May 2012 at 10:46

GoogleCodeExporter commented 8 years ago
No. This is an OS implementation issue as using access(2) with root will always 
return == 0 for R_OK/W_OK/X_OK if root is accessing a path (this is a 
bug/feature I discovered after I brought up the topic here: 
http://freebsd.1045724.n5.nabble.com/Chasing-down-bugs-with-access-2-td4206969.h
tml ). Only Linux consistently seems to do what one might expect by returning 
non-zero for non-executable scripts.

Original comment by yaneg...@gmail.com on 15 Oct 2012 at 8:50