diff --git a/test/linux.uts b/test/linux.uts index 22414465d56aa43b3b33d0979fb0a1eacfc12e78..2706f35f4c93f835c92888f850f1ddd1f529ef2b 100644 --- a/test/linux.uts +++ b/test/linux.uts @@ -12,10 +12,13 @@ ~ automaton netaccess linux needs_root * This test retries on failure because it often fails +from __future__ import print_function import os import time import signal +from scapy.modules.six.moves import range + def handler(signum, stack_frame): raise Exception("Timer expired !") @@ -28,12 +31,12 @@ IPTABLE_RULE = "iptables -%c INPUT -s %s -p tcp --sport 80 -j DROP" assert(os.system(IPTABLE_RULE % ('A', SECDEV_IP4)) == 0) success = False -for i in xrange(10): +for i in range(10): tmp = signal.alarm(5) try: r, w = os.pipe() t = TCP_client(SECDEV_IP4, 80, external_fd={ "tcp": (r,w) }) - tmp = os.write(w, "HEAD / HTTP/1.0\r\n\r\n") + tmp = os.write(w, b"HEAD / HTTP/1.0\r\n\r\n") t.runbg() time.sleep(0.5) response = os.read(r, 4096) @@ -41,13 +44,13 @@ for i in xrange(10): t.stop() os.close(r) os.close(w) - if response.startswith("HTTP/1.1 200 OK"): + if response.startswith(b"HTTP/1.1 200 OK"): success = True break else: time.sleep(0.5) except Exception as e: - print e + print(e) # Remove the iptables rule assert(os.system(IPTABLE_RULE % ('D', SECDEV_IP4)) == 0)