slight refactoring of util/vm/build.py to make it more extensible
This commit is contained in:
+10
-10
@@ -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 ):
|
|||||||
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,
|
|||||||
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():
|
|||||||
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()
|
||||||
|
|||||||
Reference in New Issue
Block a user