diff --git a/soccr/test/run.py b/soccr/test/run.py index 446584a71..1ffe58a58 100644 --- a/soccr/test/run.py +++ b/soccr/test/run.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python import sys, os import hashlib diff --git a/test/check_actions.py b/test/check_actions.py index ae909e668..4973e3938 100755 --- a/test/check_actions.py +++ b/test/check_actions.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python import sys import os diff --git a/test/others/ext-tty/run.py b/test/others/ext-tty/run.py index b1dcb4a5a..2c0bacc84 100755 --- a/test/others/ext-tty/run.py +++ b/test/others/ext-tty/run.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python import subprocess import os, sys, time, signal, pty diff --git a/test/others/mounts/mounts.sh b/test/others/mounts/mounts.sh index a9a1cc80c..19116d0cf 100755 --- a/test/others/mounts/mounts.sh +++ b/test/others/mounts/mounts.sh @@ -20,7 +20,7 @@ for i in `cat /proc/self/mounts | awk '{ print $2 }'`; do umount -l $i done -python2 mounts.py +python mounts.py kill $INMNTNS_PID while :; do sleep 10 diff --git a/test/others/rpc/config_file.py b/test/others/rpc/config_file.py index 3579ac76f..e4b395e31 100755 --- a/test/others/rpc/config_file.py +++ b/test/others/rpc/config_file.py @@ -1,4 +1,4 @@ -#!/usr/bin/python2 +#!/usr/bin/python import os import socket @@ -15,10 +15,15 @@ does_not_exist = 'does-not.exist' def setup_swrk(): print('Connecting to CRIU in swrk mode.') - css = socket.socketpair(socket.AF_UNIX, socket.SOCK_SEQPACKET) - swrk = subprocess.Popen(['./criu', "swrk", "%d" % css[0].fileno()]) - css[0].close() - return swrk, css[1] + s1, s2 = socket.socketpair(socket.AF_UNIX, socket.SOCK_SEQPACKET) + + kwargs = {} + if sys.version_info.major == 3: + kwargs["pass_fds"] = [s1.fileno()] + + swrk = subprocess.Popen(['./criu', "swrk", "%d" % s1.fileno()], **kwargs) + s1.close() + return swrk, s2 def setup_config_file(content): diff --git a/test/others/rpc/errno.py b/test/others/rpc/errno.py index 49cb622de..01a6eee7b 100755 --- a/test/others/rpc/errno.py +++ b/test/others/rpc/errno.py @@ -1,4 +1,4 @@ -#!/usr/bin/python2 +#!/usr/bin/python # Test criu errno import socket, os, errno diff --git a/test/others/rpc/ps_test.py b/test/others/rpc/ps_test.py index d16efd3f6..b51357d42 100755 --- a/test/others/rpc/ps_test.py +++ b/test/others/rpc/ps_test.py @@ -1,4 +1,4 @@ -#!/usr/bin/python2 +#!/usr/bin/python import socket, os, sys, errno import rpc_pb2 as rpc diff --git a/test/others/rpc/restore-loop.py b/test/others/rpc/restore-loop.py index c81567426..84a2ce56d 100755 --- a/test/others/rpc/restore-loop.py +++ b/test/others/rpc/restore-loop.py @@ -1,4 +1,4 @@ -#!/usr/bin/python2 +#!/usr/bin/python import socket, os, sys import rpc_pb2 as rpc diff --git a/test/others/rpc/test.py b/test/others/rpc/test.py index 9a35e0e97..80f6338f4 100755 --- a/test/others/rpc/test.py +++ b/test/others/rpc/test.py @@ -1,4 +1,4 @@ -#!/usr/bin/python2 +#!/usr/bin/python import socket, os, sys import rpc_pb2 as rpc diff --git a/test/others/rpc/version.py b/test/others/rpc/version.py index f978c6c37..3b8f1b961 100755 --- a/test/others/rpc/version.py +++ b/test/others/rpc/version.py @@ -1,4 +1,4 @@ -#!/usr/bin/python2 +#!/usr/bin/python import socket import sys @@ -7,11 +7,14 @@ import subprocess print('Connecting to CRIU in swrk mode to check the version:') -css = socket.socketpair(socket.AF_UNIX, socket.SOCK_SEQPACKET) -swrk = subprocess.Popen(['./criu', "swrk", "%d" % css[0].fileno()]) -css[0].close() +s1, s2 = socket.socketpair(socket.AF_UNIX, socket.SOCK_SEQPACKET) -s = css[1] +kwargs = {} +if sys.version_info.major == 3: + kwargs["pass_fds"] = [s2.fileno()] + +swrk = subprocess.Popen(['./criu', "swrk", "%d" % s2.fileno()], **kwargs) +s2.close() # Create criu msg, set it's type to dump request # and set dump options. Checkout more options in protobuf/rpc.proto @@ -19,12 +22,12 @@ req = rpc.criu_req() req.type = rpc.VERSION # Send request -s.send(req.SerializeToString()) +s1.send(req.SerializeToString()) # Recv response resp = rpc.criu_resp() MAX_MSG_SIZE = 1024 -resp.ParseFromString(s.recv(MAX_MSG_SIZE)) +resp.ParseFromString(s1.recv(MAX_MSG_SIZE)) if resp.type != rpc.VERSION: print('RPC: Unexpected msg type') diff --git a/test/others/shell-job/run.py b/test/others/shell-job/run.py index bd5c42509..a59945d6a 100755 --- a/test/others/shell-job/run.py +++ b/test/others/shell-job/run.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python import os, pty, sys, subprocess import termios, fcntl, time @@ -9,11 +9,11 @@ os.chdir(os.getcwd()) def create_pty(): (fd1, fd2) = pty.openpty() - return (os.fdopen(fd1, "w+"), os.fdopen(fd2, "w+")) + return (os.fdopen(fd1, "wb"), os.fdopen(fd2, "wb")) if not os.access("work", os.X_OK): - os.mkdir("work", 0755) + os.mkdir("work", 0o755) open("running", "w").close() m, s = create_pty()