-
Notifications
You must be signed in to change notification settings - Fork 334
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
avocado.main(): avoid an infinite fork loop bomb [v2] #977
Conversation
Because the current implementation of avocado.main() creates a job and runs "sys.argv[0]" to implement standalone mode, it ends up running itself over and over. This simple proposed fix, prevents avocado.main() from running itself again if called from itself. Since they are on different processes, the mechanism chosen to do this is to set an environment variable, that will be seen by the next process. This adresses issue avocado-framework#961. Signed-off-by: Cleber Rosa <crosa@redhat.com>
Looks great. |
Well actually even without the error code return it fails. What is more interesting is, that I get 2 different results when running broken test:
vs.
I like the second, but the first one is really confusing and even worst |
Strange, what's your This is my test code:
And then running it:
It PASSes. |
OK, I accidentally used to version with Anyway I think the a.py: #!/usr/bin/env python
from avocado import main
from avocado import Test
'''
class Passtest(Test):
def tst(self):
pass
'''
if __name__ == "__main__":
main() |
@ldoktor btw, the different behavior regarding
|
@clebergnu I think the fix has the side effect of showing all standalone tests with their full paths in the avocado UI. |
Well the fix also might influence the remote runner, but I haven tested it... anyway lets just create a BUG card and deal with it separately... |
Thinking about the problem @ldoktor found out, there's the possibility that somewhere in the code we're changing the current working directory and not resetting it. I'd look for suspicious |
I was git grepping and found out:
I still need to see if this gets executed in normal paths. |
This is used only if
|
@apahim yep, my first guess was dead on the water - Apparently the cwd is correct, sorry about that. I'll spend a few more minutes trying to figure out the bug. |
No dice. There's something I'm missing here. The only fix that actually worked was the one proposed by @clebergnu (using abspath). And by the way, it does not affect the display of the file path in the avocado UI:
I remember we had a discussion about this a long time ago, but maybe the assumptions all changed and using the abspath is fine. I don't have much extra time to work on this, so please help. |
Closing in favor of #985 |
Because the current implementation of avocado.main() creates a job
and runs "sys.argv[0]" to implement standalone mode, it ends up
running itself over and over.
This simple proposed fix, prevents avocado.main() from running
itself again if called from itself. Since they are on different
processes, the mechanism chosen to do this is to set an environment
variable, that will be seen by the next process.
This adresses issue #961.
Signed-off-by: Cleber Rosa crosa@redhat.com
Changes from v1: