Skip to content
Snippets Groups Projects
Commit 8b215af8 authored by Brian O'Connor's avatar Brian O'Connor
Browse files

slight refactoring of util/vm/build.py to make it more extensible

parent 00c3238e
No related branches found
No related tags found
No related merge requests found
...@@ -781,6 +781,9 @@ def build( flavor='raring32server', tests=None, pre='', post='', memory=1024 ): ...@@ -781,6 +781,9 @@ def build( flavor='raring32server', tests=None, pre='', post='', memory=1024 ):
def runTests( vm, tests=None, pre='', post='', prompt=Prompt ): def runTests( vm, tests=None, pre='', post='', prompt=Prompt ):
"Run tests (list) in vm (pexpect object)" "Run tests (list) in vm (pexpect object)"
if Branch:
checkOutBranch( vm, branch=Branch )
vm.expect( prompt )
if not tests: if not tests:
tests = [] tests = []
if pre: if pre:
...@@ -811,8 +814,8 @@ def getMininetVersion( vm ): ...@@ -811,8 +814,8 @@ def getMininetVersion( vm ):
return version return version
def bootAndRunTests( image, tests=None, pre='', post='', prompt=Prompt, def bootAndRun( image, prompt=Prompt, memory=1024, outputFile=None,
memory=1024, outputFile=None ): runFunction=None, **runArgs ):
"""Boot and test VM """Boot and test VM
tests: list of tests to run tests: list of tests to run
pre: command line to run in VM before tests pre: command line to run in VM before tests
...@@ -840,11 +843,9 @@ def bootAndRunTests( image, tests=None, pre='', post='', prompt=Prompt, ...@@ -840,11 +843,9 @@ def bootAndRunTests( image, tests=None, pre='', post='', prompt=Prompt,
login( vm ) login( vm )
log( '* Waiting for prompt after login' ) log( '* Waiting for prompt after login' )
vm.expect( prompt ) vm.expect( prompt )
if Branch: # runFunction should begin with sendline and should eat its last prompt
checkOutBranch( vm, branch=Branch ) if runFunction:
vm.expect( prompt ) runFunction( vm, **runArgs )
runTests( vm, tests=tests, pre=pre, post=post )
# runTests eats its last prompt, but maybe it shouldn't...
log( '* Shutting down' ) log( '* Shutting down' )
vm.sendline( 'sudo shutdown -h now ' ) vm.sendline( 'sudo shutdown -h now ' )
log( '* Waiting for shutdown' ) log( '* Waiting for shutdown' )
...@@ -950,9 +951,8 @@ def parseArgs(): ...@@ -950,9 +951,8 @@ def parseArgs():
log( '* BUILD FAILED with exception: ', e ) log( '* BUILD FAILED with exception: ', e )
exit( 1 ) exit( 1 )
for image in args.image: for image in args.image:
bootAndRunTests( image, tests=args.test, pre=args.run, bootAndRun( image, runFunction=runTests, tests=args.test, pre=args.run,
post=args.post, memory=args.memory, post=args.post, memory=args.memory, outputFile=args.out )
outputFile=args.out )
if not ( args.depend or args.list or args.clean or args.flavor if not ( args.depend or args.list or args.clean or args.flavor
or args.image ): or args.image ):
parser.print_help() parser.print_help()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment