Blame 9e4119f03f57eec67b97dddbf09d363b638791dc.patch

56910d
From 9e4119f03f57eec67b97dddbf09d363b638791dc Mon Sep 17 00:00:00 2001
56910d
From: Wojtek Kaniewski <wojtekka@toxygen.net>
56910d
Date: Fri, 18 Sep 2020 20:36:19 +0200
56910d
Subject: [PATCH] Move test script to Python 3
56910d
56910d
---
56910d
 test.py | 14 +++++++-------
56910d
 1 file changed, 7 insertions(+), 7 deletions(-)
56910d
56910d
diff --git a/test.py b/test.py
56910d
index c56feca..4a754bd 100755
56910d
--- a/test.py
56910d
+++ b/test.py
56910d
@@ -1,4 +1,4 @@
56910d
-#!/usr/bin/env python
56910d
+#!/usr/bin/env python3
56910d
 
56910d
 import os
56910d
 import socket
56910d
@@ -8,7 +8,7 @@
56910d
 (SUCCESS, COMMAND_FAIL, CONNECT_FAIL, DISCONNECT, ACCEPT_FAIL, DATA_MISMATCH) = range(6)
56910d
 labels = ["success", "command fail", "connection fail", "disconnection", "accept fail", "data mismatch"]
56910d
 
56910d
-def test(expect, client_af, server_af, from_ip, to_ip, args="", client_sends_first="NICK nick\r\n", server_receives="NICK nick\r\n", app_responds="", app_inserts="", server_sends_then=":localhost 001 nick :Welcome\r\n"):
56910d
+def test(expect, client_af, server_af, from_ip, to_ip, args="", client_sends_first=b"NICK nick\r\n", server_receives=b"NICK nick\r\n", app_responds=b"", app_inserts=b"", server_sends_then=b":localhost 001 nick :Welcome\r\n"):
56910d
     # Open and close a socket to get random port available
56910d
 
56910d
     client_sock = socket.socket(client_af, socket.SOCK_STREAM, 0)
56910d
@@ -26,7 +26,7 @@ def test(expect, client_af, server_af, from_ip, to_ip, args="", client_sends_fir
56910d
     server_port = server_sock.getsockname()[1]
56910d
 
56910d
     all_args = "-1 %s %d %s %d" % (args, client_port, to_ip, server_port)
56910d
-    print "Running with %s" % all_args
56910d
+    print ("Running with %s" % all_args)
56910d
     if os.system("./6tunnel " + all_args) != 0:
56910d
         if expect != COMMAND_FAIL:
56910d
             raise Exception("expected %s yet command failed" % labels[expect])
56910d
@@ -139,11 +139,11 @@ def test(expect, client_af, server_af, from_ip, to_ip, args="", client_sends_fir
56910d
 
56910d
 # Test IRC password options
56910d
 
56910d
-test(SUCCESS, socket.AF_INET, socket.AF_INET6, '127.0.0.1', '::1', '-I password', app_inserts="PASS password\r\n")
56910d
+test(SUCCESS, socket.AF_INET, socket.AF_INET6, '127.0.0.1', '::1', '-I password', app_inserts=b"PASS password\r\n")
56910d
 
56910d
-test(ACCEPT_FAIL, socket.AF_INET, socket.AF_INET6, '127.0.0.1', '::1', '-i password', client_sends_first="NICK nick\r\n")
56910d
+test(ACCEPT_FAIL, socket.AF_INET, socket.AF_INET6, '127.0.0.1', '::1', '-i password', client_sends_first=b"NICK nick\r\n")
56910d
 
56910d
-test(ACCEPT_FAIL, socket.AF_INET, socket.AF_INET6, '127.0.0.1', '::1', '-i password', client_sends_first="PASS invalid\r\nNICK nick\r\n", app_responds=":6tunnel 464 * :Password incorrect\r\n")
56910d
+test(ACCEPT_FAIL, socket.AF_INET, socket.AF_INET6, '127.0.0.1', '::1', '-i password', client_sends_first=b"PASS invalid\r\nNICK nick\r\n", app_responds=b":6tunnel 464 * :Password incorrect\r\n")
56910d
 
56910d
-test(SUCCESS, socket.AF_INET, socket.AF_INET6, '127.0.0.1', '::1', '-i password', client_sends_first="PASS password\r\nNICK nick\r\n")
56910d
+test(SUCCESS, socket.AF_INET, socket.AF_INET6, '127.0.0.1', '::1', '-i password', client_sends_first=b"PASS password\r\nNICK nick\r\n")
56910d