def wait_status(self): self.print_start() # Start and wait for the process self.proc_.communicate() with codecs.open('{}/log_stdout.log'.format(self.path_), encoding='utf-8', errors='replace') as log_stdout: self.output_.append(log_stdout.read()) with codecs.open('{}/log_stderr.log'.format(self.path_), encoding='utf-8', errors='replace') as log_stderr: self.output_.append(log_stderr.read()) if self.proc_.returncode == 0: print pretty.PASS_INLINE() else: print pretty.FAIL_INLINE() print pretty.INFO("Process stdout") print pretty.DATA(self.output_[0]) print pretty.INFO("Process stderr") print pretty.DATA(self.output_[1]) return self.proc_.returncode
def DHCP_test(trigger_line): global num_assigned_clients num_assigned_clients += 1 print(color.INFO("<Test.py>"), "Client got IP") ip_string = vm.readline() print(color.INFO("<Test.py>"), "Assigned address: ", ip_string) print(color.INFO("<Test.py>"), "Trying to ping") time.sleep(1) try: command = [ "ping", "-c", str(ping_count), "-i", "0.2", ip_string.rstrip() ] print(color.DATA(" ".join(command))) print(subprocess.check_output(command, timeout=thread_timeout)) print(color.INFO("<Test.py>"), "Number of ping tests passed: ", str(num_assigned_clients)) if num_assigned_clients == 3: vm.exit( 0, "<Test.py> Ping test for all 3 clients passed. Process returned 0 exit status" ) except Exception as e: print(color.FAIL("<Test.py> Ping FAILED Process threw exception:")) print(e) return False
def start_icmp_test(trigger_line): global num_successes # 1 Ping: Checking output from callback in service.cpp print(color.INFO("<Test.py>"), "Performing ping6 test") output_data = "" for x in range(0, 9): output_data += vm.readline() print(output_data) if "Received packet from gateway" in output_data and \ "Identifier: 0" in output_data and \ "Sequence number: 0" in output_data and \ "Source: fe80:0:0:0:e823:fcff:fef4:83e7" in output_data and \ "Destination: fe80:0:0:0:e823:fcff:fef4:85bd" in output_data and \ "Type: ECHO REPLY (129)" in output_data and \ "Code: DEFAULT (0)" in output_data and \ "Checksum: " in output_data and \ "Data: INCLUDEOS12345ABCDEFGHIJKLMNOPQRSTUVWXYZ12345678" in output_data: num_successes += 1 print(color.INFO("<Test.py>"), "Ping test succeeded") else: print(color.FAIL("<Test.py>"), "Ping test FAILED") vm.exit(1, "Ping test failed") if num_successes == 1: vm.exit( 0, "<Test.py> All ICMP tests succeeded. Process returned 0 exit status" )
def run_dhclient(trigger_line): route_output = subprocess.check_output(["route"]) if "10.0.0.0" not in route_output: subprocess32.call([ "sudo", "ifconfig", "bridge43", "10.0.0.1", "netmask", "255.255.0.0", "up" ], timeout=thread_timeout) time.sleep(1) if "10.200.0.0" not in route_output: subprocess32.call([ "sudo", "route", "add", "-net", "10.200.0.0", "netmask", "255.255.0.0", "dev", "bridge43" ], timeout=thread_timeout) print color.INFO("<Test.py>"), "Route added to bridge43, 10.200.0.0" print color.INFO("<Test.py>"), "Running dhclient" try: dhclient = subprocess32.Popen( ["sudo", "dhclient", "bridge43", "-4", "-n", "-v"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, timeout=thread_timeout) # timeout on dhclient process kill_proc = lambda p: p.kill() timer = Timer(20, kill_proc, [dhclient]) timer.start() process_output, _ = dhclient.communicate() print color.INFO("<dhclient>") print process_output check_dhclient_output(process_output) except (OSError, subprocess.CalledProcessError) as exception: cleanup() print color.FAIL("<Test.py> dhclient FAILED threw exception:") print str(exception) timer.cancel() vm.exit(1, "<Test.py> dhclient test failed") finally: timer.cancel() ping_test() if ping_passed and num_messages == 4: vm.exit( 0, "<Test.py> DHCP process and ping test completed successfully. Process returned 0 exit status" ) else: vm.exit(1, "<Test.py> DHCP process or ping test failed")
def check_vitals(string): print color.INFO("Checking vital signs") mem = get_mem() diff = mem - memuse_at_start pages = diff / PAGE_SIZE print color.INFO("Memory use at test end:"), mem, "bytes" print color.INFO("Memory difference from test start:"), memuse_at_start, "bytes (Diff:",diff, "b == ",pages, "pages)" sock_mem.close() vm.stop() wait_for_tw() return True
def wait_for_tw(): print color.INFO("Waiting for sockets to clear TIME_WAIT stage") socket_limit = 11500 time_wait_proc = 30000 while time_wait_proc > socket_limit: output = subprocess.check_output(('netstat', '-anlt')) output = output.split('\n') time_wait_proc = 0 for line in output: if "TIME_WAIT" in line: time_wait_proc += 1 print color.INFO("There are {0} sockets in use, waiting for value to drop below {1}".format(time_wait_proc, socket_limit)) time.sleep(7)
def check_exit(line, n = "0"): global T T += 1 print(color.INFO("test.py"), "received: ", line) status = line.split(" ")[-1].lstrip().rstrip() as_expected = status == n if as_expected: print(color.INFO("test.py"), "Exit status is ", status, "as expected") vm.exit(0, "Test " + str(T) + "/" + str(N) + " passed", keep_running = True) return as_expected else: print(color.WARNING("test.py"), "Exit status is", status, "expected", n) return as_expected
def DHCP_test(trigger_line): print color.INFO("<Test.py>"),"Got IP" ip_string = vm.readline() print color.INFO("<Test.py>"), "Assigned address: ", ip_string print color.INFO("<Test.py>"), "Trying to ping" time.sleep(1) try: command = ["ping", ip_string.rstrip(), "-c", str(ping_count), "-i", "0.2"] print color.DATA(" ".join(command)) print subprocess32.check_output(command, timeout=thread_timeout) vm.exit(0,"<Test.py> Ping test passed. Process returned 0 exit status") except Exception as e: print color.FAIL("<Test.py> Ping FAILED Process threw exception:") print e return False
def wait_status(self): self.print_start() # Start and wait for the process self.output_ = self.proc_.communicate() if self.proc_.returncode == 0: print pretty.PASS_INLINE() else: print pretty.FAIL_INLINE() print pretty.INFO("Process stdout") print pretty.DATA(self.output_[0]) print pretty.INFO("Process stderr") print pretty.DATA(self.output_[1]) return self.proc_.returncode
def fire_bursts(func, sub_test_name, lead_out=3): name_tag = "<" + sub_test_name + ">" print color.HEADER(test_name + " initiating " + sub_test_name) membase_start = func() mem_base = membase_start # Track heap behavior increases = 0 decreases = 0 constant = 0 for i in range(0, BURST_COUNT): print color.INFO(name_tag), " Run ", i + 1 memi = func() if memi > mem_base: memincrease = memi - mem_base increases += 1 elif memi == mem_base: memincrease = 0 constant += 1 else: memincrease = 0 decreases += 1 # We want to know how much each burst increases memory relative to the last burst mem_base = memi if memincrease > acceptable_increase: print color.WARNING( name_tag), "Memory increased by ", memincrease, "b, ", float( memincrease) / BURST_SIZE, "pr. packet \n" else: print color.OK(name_tag), "Memory increase ", memincrease, "b \n" # Memory can decrease, we don't care about that # if memincrease > 0: # mem_base += memincrease print color.INFO( name_tag ), "Heap behavior: ", "+", increases, ", -", decreases, ", ==", constant print color.INFO(name_tag), "Done. Checking for liveliness" if memory_increase(lead_out, membase_start) > acceptable_increase: print color.FAIL(sub_test_name + " failed ") return False print color.PASS(sub_test_name + " succeeded ") return True
def check_vitals(string): print color.INFO("Checking vital signs") mem = get_mem() diff = mem - memuse_at_start pages = diff / PAGE_SIZE if diff % PAGE_SIZE != 0: print color.WARNING("Memory increase was not a multple of page size.") wait_for_tw() return False print color.INFO("Memory use at test end:"), mem, "bytes" print color.INFO( "Memory difference from test start:" ), memuse_at_start, "bytes (Diff:", diff, "b == ", pages, "pages)" sock_mem.close() vm.stop() wait_for_tw() return True
def ping_test(): global ping_passed print color.INFO("<Test.py>"), "Assigned address: ", assigned_ip print color.INFO("<Test.py>"), "Trying to ping" time.sleep(1) try: command = ["ping", assigned_ip, "-c", str(ping_count), "-i", "0.2"] print color.DATA(" ".join(command)) print subprocess.check_output(command) ping_passed = True except Exception as e: print color.FAIL("<Test.py> Ping FAILED Process threw exception:") print e cleanup() vm.exit(1, "<Test.py> Ping test failed") finally: cleanup()
def filter_tests(all_tests, arguments): """ Will figure out which tests are to be run Arguments: all_tests (list of Test obj): all processed test objects arguments (argument object): Contains arguments from argparse returns: list: All Test objects that are to be run """ print pretty.HEADER("Filtering tests") # Strip trailing slashes from paths add_args = [ x.rstrip("/") for x in arguments.tests ] skip_args = [ x.rstrip("/") for x in arguments.skip ] print pretty.INFO("Tests to run"), ", ".join(add_args) # 1) Add tests to be run # If no tests specified all are run if not add_args: tests_added = [ x for x in all_tests if x.type_ in test_types ] else: tests_added = [ x for x in all_tests if x.type_ in add_args or x.category_ in add_args or x.name_ in add_args ] # 2) Remove tests defined by the skip argument print pretty.INFO("Tests marked skip on command line"), ", ".join(skip_args) skipped_tests = [ x for x in tests_added if x.type_ in skip_args or x.category_ in skip_args or x.name_ in skip_args or x.skip_] # Print all the skipped tests print_skipped(skipped_tests) fin_tests = [ x for x in tests_added if x not in skipped_tests ] print pretty.INFO("Accepted tests"), ", ".join([x.name_ for x in fin_tests]) return fin_tests
def Slaac_test(trigger_line): print(color.INFO("<Test.py>"), "Got IP") vm_string = vm.readline() wlist = vm_string.split() ip_string = wlist[-1].split("/")[0] print(color.INFO("<Test.py>"), "Assigned address: ", ip_string) print(color.INFO("<Test.py>"), "Trying to ping") time.sleep(1) try: command = [ "ping6", "-I", "bridge43", ip_string.rstrip(), "-c", str(ping_count) ] print(color.DATA(" ".join(command))) print(subprocess.check_output(command)) vm.exit(0, "<Test.py> Ping test passed. Process returned 0 exit status") except Exception as e: print(color.FAIL("<Test.py> Ping FAILED Process threw exception:")) print(e) return False
def run_dhclient(trigger_line): route_output = subprocess.check_output(["route"]).decode("utf-8") if "10.0.0.0" not in route_output: subprocess.call(["sudo", "ip", "link", "set", "dev", "bridge43", "up"], timeout=thread_timeout) time.sleep(1) if "10.200.0.0" not in route_output: subprocess.call(["sudo", "ip", "route", "add", "10.200.0.0/16", "dev", "bridge43"], timeout=thread_timeout) print(color.INFO("<Test.py>"), "Route added to bridge43, 10.200.0.0") print(color.INFO("<Test.py>"), "Running dhclient") try: dhclient = subprocess.check_output( ["sudo", "dhclient", "bridge43", "-4", "-n", "-v"], stderr=subprocess.STDOUT, timeout=thread_timeout ) print(color.INFO("<dhclient>")) print(dhclient) # gets ip of dhclient used to ping check_dhclient_output(dhclient.decode("utf-8")) except subprocess.CalledProcessError as exception: print(color.FAIL("<Test.py> dhclient FAILED threw exception:")) print(exception.output) vm.exit(1, "<Test.py> dhclient test failed") return False ping_test() if ping_passed and num_messages == 4: vm.exit(0, "<Test.py> DHCP process and ping test completed successfully. Process returned 0 exit status") else: vm.exit(1, "<Test.py> DHCP process or ping test failed")
def crash_test(string): print(color.INFO("Opening persistent TCP connection for diagnostics")) sock_mem.connect((HOST, PORT_MEM)) mem_before = get_mem_start() if mem_before <= 0: print(color.FAIL("Initial memory reported as " + str(mem_before))) return False if not heap_verified: print(color.FAIL("Heap behavior was not verified as expected. ")) return False print(color.HEADER("Initial crash test")) burst_size = BURST_SIZE * 10 ARP_burst(burst_size, 0) UDP_burst(burst_size, 0) ICMP_flood(burst_size, 0) httperf(burst_size, 0) time.sleep(BURST_INTERVAL) mem_after = get_mem() print(color.INFO("Crash test complete. Memory in use: "), mem_after) return mem_after >= memuse_at_start
def crash_test(string): print color.INFO("Opening persistent TCP connection for diagnostics") sock_mem.connect((HOST, PORT_MEM)) get_mem_start() print color.HEADER("Initial crash test") burst_size = BURST_SIZE * 10 ARP_burst(burst_size, 0) UDP_burst(burst_size, 0) ICMP_flood(burst_size, 0) httperf(burst_size, 0) time.sleep(BURST_INTERVAL) return get_mem()
def get_mem(): name_tag = "<" + test_name + "::get_mem>" try: # We expect this socket to allready be opened time.sleep(1) sock_mem.send("memsize\n") received = sock_mem.recv(1000).rstrip() except Exception as e: print color.FAIL(name_tag), "Python socket failed while getting memsize: ", e return False print color.INFO(name_tag),"Current VM memory usage reported as ", received return int(received)
def check_exit(line, n="0"): global T T += 1 print "Python received: ", line status = line.split(" ")[-1].lstrip().rstrip() as_expected = status == n if as_expected: print color.INFO("test.py"), "Exit status is ", status, "as expected" vm.exit(0, "Test " + str(T) + "/" + str(N) + " passed") return as_expected else: print color.WARNING( "test.py"), "Exit status is", status, "expected", as_expected "expected " + n return as_expected
def memory_increase(lead_time, expected_memuse = memuse_at_start): name_tag = "<" + test_name + "::memory_increase>" if lead_time: print color.INFO(name_tag),"Checking for memory increase after a lead time of ",lead_time,"s." # Give the VM a chance to free up resources before asking time.sleep(lead_time) use = get_mem() increase = use - expected_memuse percent = 0.0; if (increase): percent = float(increase) / expected_memuse if increase > acceptable_increase: print color.WARNING(name_tag), "Memory increased by ", percent, "%." print "(" , expected_memuse, "->", use, ",", increase,"b increase, but no increase expected.)" else: print color.OK(name_tag + "Memory constant, no leak detected") return increase
def heap_ok(line): global heap_verified heap_verified = True print(color.INFO("Stresstest::heap_ok"), "VM reports heap is increasing and decreasing as expected")
color.INFO( "There are {0} sockets in use, waiting for value to drop below {1}" .format(time_wait_proc, socket_limit))) time.sleep(7) # Add custom event-handlers vm.on_output("Heap functioning as expected", heap_ok) vm.on_output("Ready to start", crash_test) vm.on_output("Ready for ARP", ARP) vm.on_output("Ready for UDP", UDP) vm.on_output("Ready for ICMP", ICMP) vm.on_output("Ready for TCP", TCP) vm.on_output("Ready to end", check_vitals) if len(sys.argv) > 1: thread_timeout = int(sys.argv[1]) if len(sys.argv) > 3: BURST_COUNT = int(sys.argv[2]) BURST_SIZE = int(sys.argv[3]) print(color.HEADER(test_name + " initializing")) print(color.INFO(name_tag), "configured for ", BURST_COUNT, "bursts of", BURST_SIZE, "packets each") if len(sys.argv) > 4: vm.boot(timeout=thread_timeout, image_name=str(sys.argv[4])) else: vm.cmake().boot(thread_timeout).clean()
def start_icmp_test(trigger_line): global num_successes # Installing hping3 on linux subprocess.call(["sudo", "apt-get", "update"]) subprocess.call(["sudo", "apt-get", "-y", "install", "hping3"]) # Installing hping3 on macOS # subprocess.call(["brew", "install", "hping"]) # 1 Ping: Checking output from callback in service.cpp print color.INFO("<Test.py>"), "Performing ping test" output_data = "" for x in range(0, 11): output_data += vm.readline() print output_data if "Received packet from gateway" in output_data and \ "Identifier: 0" in output_data and \ "Sequence number: 0" in output_data and \ "Source: 10.0.0.1" in output_data and \ "Destination: 10.0.0.45" in output_data and \ "Type: ECHO REPLY (0)" in output_data and \ "Code: DEFAULT (0)" in output_data and \ "Checksum: " in output_data and \ "Data: INCLUDEOS12345ABCDEFGHIJKLMNOPQRSTUVWXYZ12345678" in output_data and \ "No reply received from 10.0.0.42" in output_data and \ "No reply received from 10.0.0.43" in output_data: num_successes += 1 print color.INFO("<Test.py>"), "Ping test succeeded" else: print color.FAIL("<Test.py>"), "Ping test FAILED" # 2 Port unreachable print color.INFO( "<Test.py>"), "Performing Destination Unreachable (port) test" # Sending 1 udp packet to 10.0.0.45 to port 8080 udp_port_output = subprocess32.check_output( ["sudo", "hping3", "10.0.0.45", "--udp", "-p", "8080", "-c", "1"], timeout=thread_timeout) print udp_port_output # Validate content in udp_port_output: if "ICMP Port Unreachable from ip=10.0.0.45" in udp_port_output: print color.INFO("<Test.py>"), "Port Unreachable test succeeded" num_successes += 1 else: print color.FAIL("<Test.py>"), "Port Unreachable test FAILED" # 3 Protocol unreachable print color.INFO( "<Test.py>"), "Performing Destination Unreachable (protocol) test" # Sending 1 raw ip packet to 10.0.0.45 with protocol 16 rawip_protocol_output = subprocess32.check_output([ "sudo", "hping3", "10.0.0.45", "-d", "20", "-0", "--ipproto", "16", "-c", "1" ], timeout=thread_timeout) print rawip_protocol_output # Validate content in rawip_protocol_output: if "ICMP Protocol Unreachable from ip=10.0.0.45" in rawip_protocol_output: print color.INFO("<Test.py>"), "Protocol Unreachable test succeeded" num_successes += 1 else: print color.FAIL("<Test.py>"), "Protocol Unreachable test FAILED" # 4 Check result of tests if num_successes == 3: vm.exit( 0, "<Test.py> All ICMP tests succeeded. Process returned 0 exit status" ) else: num_fails = 3 - num_successes res = "<Test.py> " + str(num_fails) + " ICMP test(s) failed" vm.exit(1, res)
os.getcwd(), os.path.dirname(__file__))).split('/test')[0]) sys.path.insert(0, includeos_src) from vmrunner import vmrunner from vmrunner.prettify import color GUEST = 'fe80:0:0:0:e823:fcff:fef4:85bd%bridge43' HOST = 'fe80:0:0:0:e823:fcff:fef4:83e7%bridge43' TEST1 = 8081 TEST2 = 8082 TEST3 = 8083 TEST4 = 8084 TEST5 = 8085 INFO = color.INFO("<test.py>") def connect(port): addr = (GUEST, port) res = socket.getaddrinfo(addr[0], addr[1], socket.AF_INET6, socket.SOCK_STREAM, socket.SOL_TCP) af, socktype, proto, canonname, sa = res[0] sock = socket.socket(af, socktype, proto) print INFO, 'connecting to %s' % res sock.connect(sa) bytes_received = 0 try: while True: data = sock.recv(1024) bytes_received += len(data)
def filter_tests(all_tests, arguments): """ Will figure out which tests are to be run Arguments: all_tests (list of Test obj): all processed test objects arguments (argument object): Contains arguments from argparse returns: tuple: (All Test objects that are to be run, skipped_tests) """ print pretty.HEADER("Filtering tests") # Strip trailing slashes from paths add_args = [x.rstrip("/") for x in arguments.tests] skip_args = [x.rstrip("/") for x in arguments.skip] print pretty.INFO("Tests to run"), ", ".join(add_args) # 1) Add tests to be run # If no tests specified all are run if not add_args: tests_added = [x for x in all_tests if x.type_ in test_types] else: tests_added = [ x for x in all_tests if x.type_ in add_args or x.category_ in add_args or x.name_ in add_args ] # Deal with specific properties add_properties = list( set(add_args).intersection(all_tests[0].properties_.keys())) for test in all_tests: for argument in add_properties: if test.properties_[argument] and test not in tests_added: tests_added.append(test) # 2) Remove tests defined by the skip argument print pretty.INFO("Tests marked skip on command line"), ", ".join( skip_args) skipped_tests = [ x for x in tests_added if x.type_ in skip_args or x.category_ in skip_args or x.name_ in skip_args or x.skip_ ] # Deal with specific properties skip_properties = list( set(skip_args).intersection(all_tests[0].properties_.keys())) for test in tests_added: for argument in skip_properties: if test.properties_[argument] and test not in skipped_tests: test.skip_ = True test.skip_reason_ = "Test marked skip on command line" skipped_tests.append(test) # Print all the skipped tests print_skipped(skipped_tests) fin_tests = [x for x in tests_added if x not in skipped_tests] print pretty.INFO("Accepted tests"), ", ".join( [x.name_ for x in fin_tests]) return (fin_tests, skipped_tests)
def integration_tests(tests): """ Function that runs the tests that are passed to it. Filters out any invalid tests before running Arguments: tests: List containing test objects to be run Returns: integer: Number of tests that failed """ if len(tests) == 0: return 0 time_sensitive_tests = [ x for x in tests if x.properties_["time_sensitive"] ] tests = [x for x in tests if x not in time_sensitive_tests] # Print info before starting to run print pretty.HEADER("Starting " + str(len(tests)) + " integration test(s)") for test in tests: print pretty.INFO("Test"), "starting", test.name_ if time_sensitive_tests: print pretty.HEADER("Then starting " + str(len(time_sensitive_tests)) + " time sensitive integration test(s)") for test in time_sensitive_tests: print pretty.INFO("Test"), "starting", test.name_ processes = [] fail_count = 0 global test_count test_count += len(tests) + len(time_sensitive_tests) # Find number of cpu cores if args.parallel: num_cpus = args.parallel else: num_cpus = multiprocessing.cpu_count() # Collect test results print pretty.HEADER( "Collecting integration test results, on {0} cpu(s)".format(num_cpus)) # Run a maximum number of parallell tests equal to cpus available while tests or processes: # While there are tests or processes left try: processes.append( tests.pop(0).start()) # Remove test from list after start except IndexError: pass # All tests done while (len(processes) == num_cpus) or not tests: # While there are a maximum of num_cpus to process # Or there are no more tests left to start we wait for them for p in list(processes): # Iterate over copy of list if p.proc_.poll() is not None: fail_count += 1 if p.wait_status() else 0 processes.remove(p) time.sleep(1) if not processes and not tests: break # Exit early if any tests failed if fail_count and args.fail: print pretty.FAIL(str(fail_count) + "integration tests failed") sys.exit(fail_count) # Start running the time sensitive tests for test in time_sensitive_tests: process = test.start() fail_count += 1 if process.wait_status() else 0 if fail_count and args.fail: print pretty.FAIL(str(fail_count) + "integration tests failed") sys.exit(fail_count) return fail_count
def cleanup(): # Remove leases-file print color.INFO("<Test.py>"), "Removing /var/lib/dhcp/dhclient.leases" subprocess.call(["sudo", "rm", "/var/lib/dhcp/dhclient.leases"]) # Kill dhclient process: subprocess.call(["sudo", "dhclient", "bridge43", "-4", "-x", "-n", "-v"])
"There are {0} sockets in use, waiting for value to drop below {1}" .format(time_wait_proc, socket_limit)) time.sleep(7) # Add custom event-handlers vm.on_output("Heap functioning as expected", heap_ok) vm.on_output("Ready to start", crash_test) vm.on_output("Ready for ARP", ARP) vm.on_output("Ready for UDP", UDP) vm.on_output("Ready for ICMP", ICMP) vm.on_output("Ready for TCP", TCP) vm.on_output("Ready to end", check_vitals) # Boot the VM, taking a timeout as parameter timeout = BURST_COUNT * 20 if len(sys.argv) > 1: timeout = int(sys.argv[1]) if len(sys.argv) > 3: BURST_COUNT = int(sys.argv[2]) BURST_SIZE = int(sys.argv[3]) print color.HEADER(test_name + " initializing") print color.INFO( name_tag ), "configured for ", BURST_COUNT, "bursts of", BURST_SIZE, "packets each" vm.cmake().boot(timeout).clean()
time_wait_proc += 1 print color.INFO( "There are {0} sockets in use, waiting for value to drop below {1}" .format(time_wait_proc, socket_limit)) time.sleep(7) # Add custom event-handlers vm.on_output("Ready to start", crash_test) vm.on_output("Ready for ARP", ARP) vm.on_output("Ready for UDP", UDP) vm.on_output("Ready for ICMP", ICMP) vm.on_output("Ready for TCP", TCP) vm.on_output("Ready to end", check_vitals) # Boot the VM, taking a timeout as parameter timeout = BURST_COUNT * 20 if len(sys.argv) > 1: timeout = int(sys.argv[1]) if len(sys.argv) > 3: BURST_COUNT = int(sys.argv[2]) BURST_SIZE = int(sys.argv[3]) print color.HEADER(test_name + " initializing") print color.INFO( name_tag), "Doing", BURST_COUNT, "bursts of", BURST_SIZE, "packets each" vm.cmake().boot(timeout).clean()