[CRIU] [PATCH] tests: more python3 compatibility

Andrei Vagin avagin at gmail.com
Thu Nov 1 19:52:20 MSK 2018


Applied, thanks!

On Mon, Oct 29, 2018 at 05:05:48PM +0100, Adrian Reber wrote:
> From: Adrian Reber <areber at redhat.com>
> 
> This makes two zdtm test scripts python3 compatible to run
> zdtm on a system without python2.
> 
> Signed-off-by: Adrian Reber <areber at redhat.com>
> ---
>  test/zdtm/static/file_locks06.checkskip    |  6 +++---
>  test/zdtm/static/socket-tcp-fin-wait1.hook | 10 +++++-----
>  2 files changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/test/zdtm/static/file_locks06.checkskip b/test/zdtm/static/file_locks06.checkskip
> index e5a4775f8..06ab58521 100755
> --- a/test/zdtm/static/file_locks06.checkskip
> +++ b/test/zdtm/static/file_locks06.checkskip
> @@ -1,4 +1,4 @@
> -#!/usr/bin/env python2
> +#!/usr/bin/env python
>  import fcntl
>  import tempfile
>  import struct
> @@ -12,8 +12,8 @@ try:
>  		fcntl.fcntl(fd.fileno(), F_OFD_SETLK, flock)
>  except IOError as e:
>  	if e.errno == errno.EINVAL:
> -		print "I/O error({0}): {1}".format(e.errno, e.strerror)
> -		print "OFD locks are not supported."
> +		print("I/O error({0}): {1}".format(e.errno, e.strerror))
> +		print("OFD locks are not supported.")
>  		exit(1)
>  
>  exit(0)
> diff --git a/test/zdtm/static/socket-tcp-fin-wait1.hook b/test/zdtm/static/socket-tcp-fin-wait1.hook
> index 9630e0d74..9504557da 100755
> --- a/test/zdtm/static/socket-tcp-fin-wait1.hook
> +++ b/test/zdtm/static/socket-tcp-fin-wait1.hook
> @@ -1,4 +1,4 @@
> -#!/usr/bin/env python2
> +#!/usr/bin/env python
>  import sys
>  
>  sys.path.append("../crit")
> @@ -13,13 +13,13 @@ if sys.argv[1] in ["--pre-dump", "--post-restore"]:
>      pid = os.getenv("ZDTM_TEST_PID")
>      try:
>          subprocess.Popen(["nsenter", "-t", pid, "-n", "ss", "-t", "-a", "-n"]).wait()
> -    except OSError, e:
> +    except OSError as e:
>          pass
>  
>  if sys.argv[1] != "--post-restore":
>      sys.exit(0)
>  
> -print "Check TCP images"
> +print("Check TCP images")
>  
>  def get_sockets(image_dir):
>      fname = os.path.join(image_dir, "inetsk.img")
> @@ -34,7 +34,7 @@ def get_sockets(image_dir):
>          f = open(os.path.join(image_dir, "inetsk.img"))
>          ids = pycriu.images.load(f)
>          tcp_img = os.path.join(image_dir, "tcp-stream-%x.img" % int(s["ino"]))
> -        print tcp_img
> +        print(tcp_img)
>          if os.access(tcp_img, os.F_OK):
>              f = open(tcp_img)
>              tcp = pycriu.images.load(f)
> @@ -65,6 +65,6 @@ for d in os.listdir(path):
>      sockets_str = json.dumps(sockets, sys.stdout, indent=8, sort_keys=True)
>      prev_str = json.dumps(prev, sys.stdout, indent=8, sort_keys=True)
>  
> -    print "\n".join(difflib.unified_diff(prev_str.split("\n"), sockets_str.split("\n")))
> +    print("\n".join(difflib.unified_diff(prev_str.split("\n"), sockets_str.split("\n"))))
>  
>  sys.exit(exit_code)
> -- 
> 2.19.1
> 
> _______________________________________________
> CRIU mailing list
> CRIU at openvz.org
> https://lists.openvz.org/mailman/listinfo/criu


More information about the CRIU mailing list