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

avocado.main(): avoid an infinite fork loop bomb [v4] #991

Merged
merged 1 commit into from
Jan 28, 2016

Conversation

clebergnu
Copy link
Contributor

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.

Also, by exiting from main() with an error code, the test first
level test will fail. This will let the user know that the chosen
approach (SIMPLE tests written in Python and calling main()) are
not worthy of a PASS.

The functional tests make use of Python's standard library utilities
(subprocess module) directly for running Avocado because of current
issues with Avocado's own process utility module.

This adresses issue #961.

Signed-off-by: Cleber Rosa crosa@redhat.com


Changes from v3:

  • Use Python subprocess module for running the avocado command line in the functional test, and clean up progress (group) if it doesn't finish properly

Changes from v2:

  • Return an error code to signal that the used approach (calling main() is not ideal from a SIMPLE test).

Changes from v1:

  • Add error message to STDERR, warning that main() will exit to avoid a loop.

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.

Also, by exiting from main() with an error code, the test first
level test will fail. This will let the user know that the chosen
approach (SIMPLE tests written in Python and calling main()) are
not worthy of a PASS.

The functional tests make use of Python's standard library utilities
(subprocess module) directly for running Avocado because of current
issues with Avocado's own process utility module.

This adresses issue avocado-framework#961.

Signed-off-by: Cleber Rosa <crosa@redhat.com>
@lmr
Copy link
Member

lmr commented Jan 28, 2016

Looks good to me. I'm going to merge this.

lmr added a commit that referenced this pull request Jan 28, 2016
avocado.main(): avoid an infinite fork loop bomb [v4]
@lmr lmr merged commit d863c0d into avocado-framework:master Jan 28, 2016
@lmr lmr removed the in progress label Jan 28, 2016
@clebergnu clebergnu deleted the avoid_fork_bomb_v4 branch May 4, 2016 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants