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 ARP_burst(burst_size = BURST_SIZE, burst_interval = BURST_INTERVAL): # Note: Arping requires sudo, and we expect the bridge 'bridge43' to be present command = ["sudo", "arping", "-q","-w", str(100), "-I", "bridge43", "-c", str(burst_size * 10), HOST] print color.DATA(" ".join(command)) time.sleep(0.5) res = subprocess32.check_call(command, timeout=thread_timeout); time.sleep(burst_interval) return get_mem()
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 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 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 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