aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/bpf/tcp_client.py
diff options
context:
space:
mode:
authorJeremy Cline <jcline@redhat.com>2018-07-24 15:53:34 -0400
committerDaniel Borkmann <daniel@iogearbox.net>2018-07-25 07:46:48 +0200
commite66565f3bee141748d2c3b2ed0d4ecd455f634fa (patch)
tree1c93844b2b0a9d4d06bcd36f6ef7acb6e087ebb2 /tools/testing/selftests/bpf/tcp_client.py
parentbpf: btf: fix inconsistent IS_ERR and PTR_ERR (diff)
downloadlinux-dev-e66565f3bee141748d2c3b2ed0d4ecd455f634fa.tar.xz
linux-dev-e66565f3bee141748d2c3b2ed0d4ecd455f634fa.zip
bpf: Add Python 3 support to selftests scripts for bpf
Adjust tcp_client.py and tcp_server.py to work with Python 3 by using the print function, marking string literals as bytes, and using the newer exception syntax. This should be functionally equivalent and supports Python 3+. Signed-off-by: Jeremy Cline <jcline@redhat.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Diffstat (limited to 'tools/testing/selftests/bpf/tcp_client.py')
-rwxr-xr-xtools/testing/selftests/bpf/tcp_client.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/tools/testing/selftests/bpf/tcp_client.py b/tools/testing/selftests/bpf/tcp_client.py
index 481dccdf140c..7f8200a8702b 100755
--- a/tools/testing/selftests/bpf/tcp_client.py
+++ b/tools/testing/selftests/bpf/tcp_client.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python2
+#!/usr/bin/env python3
#
# SPDX-License-Identifier: GPL-2.0
#
@@ -9,11 +9,11 @@ import subprocess
import select
def read(sock, n):
- buf = ''
+ buf = b''
while len(buf) < n:
rem = n - len(buf)
try: s = sock.recv(rem)
- except (socket.error), e: return ''
+ except (socket.error) as e: return b''
buf += s
return buf
@@ -22,7 +22,7 @@ def send(sock, s):
count = 0
while count < total:
try: n = sock.send(s)
- except (socket.error), e: n = 0
+ except (socket.error) as e: n = 0
if n == 0:
return count;
count += n
@@ -39,10 +39,10 @@ try:
except socket.error as e:
sys.exit(1)
-buf = ''
+buf = b''
n = 0
while n < 1000:
- buf += '+'
+ buf += b'+'
n += 1
sock.settimeout(1);