Skip to content

Instantly share code, notes, and snippets.

@ricarkol
Last active May 16, 2018 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ricarkol/0cef066f51fa018c77ac5b1486f19c1f to your computer and use it in GitHub Desktop.
Save ricarkol/0cef066f51fa018c77ac5b1486f19c1f to your computer and use it in GitHub Desktop.
import argparse
import pexpect
import os
import time
parser = argparse.ArgumentParser()
parser.add_argument('--cmd', dest='cmd', help='unikernel command', default='echo hi', type=str)
parser.add_argument('--show', dest='show', help='show output', default=False, type=bool)
parser.add_argument('--num', dest='num', help='number of runs', default=10, type=int)
parser.add_argument('--timeout', dest='timeout', help='timeout', default=30, type=int)
args = parser.parse_args()
for i in range(0, args.num):
t0 = time.time()
vm = pexpect.spawn(args.cmd, timeout=args.timeout)
try:
vm.expect('Running')
t1 = time.time()
print(t1 - t0)
finally:
vm.close()
if args.show:
print vm.before
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment