1import time 2import utils 3 4print "Testing a simple ls command with no timeout" 5result = utils.run('ls -d /etc') 6output = result.stdout.rstrip() 7if output == '/etc': 8 print "Passed" 9else: 10 raise "Failed" 11 12print 13 14print "Testing system_output" 15output = utils.run("ls -d /etc").stdout.strip() 16if output == '/etc': 17 print "Passed" 18else: 19 raise "Failed" 20 21print 22 23print "Testing sleep 2 with timeout of 5" 24start = time.time() 25result = utils.run('sleep 2', timeout=5) 26print "time: %f" % (time.time() - start) 27if result.exit_status == 0: 28 print "Passed" 29else: 30 raise "Failed" 31 32print 33 34print "Testing sleep 10 with timeout of 5" 35start = time.time() 36result = utils.run('sleep 10', timeout=5) 37t = time.time() - start 38print "time: %f" % t 39if t < 10: 40 print "Passed" 41else: 42 raise "Failed" 43 44