Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
criu
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhul
criu
Commits
33b6cff4
Commit
33b6cff4
authored
Jun 01, 2018
by
Andrei Vagin
Committed by
Pavel Emelyanov
Jul 09, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test: make crit-recode.py python2/python3 compatible
Signed-off-by:
Andrei Vagin
<
avagin@virtuozzo.com
>
parent
841edaf3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
20 deletions
+23
-20
crit-recode.py
test/crit-recode.py
+23
-20
No files found.
test/crit-recode.py
View file @
33b6cff4
#!/bin/env python2
#!/usr/bin/env python
# vim: noet ts=8 sw=8 sts=8
import
pycriu
import
pycriu
import
sys
import
sys
import
os
import
os
import
subprocess
import
subprocess
import
json
find
=
subprocess
.
Popen
([
'find'
,
'test/dump/'
,
'-size'
,
'+0'
,
'-name'
,
'*.img'
],
find
=
subprocess
.
Popen
([
'find'
,
'test/dump/'
,
'-size'
,
'+0'
,
'-name'
,
'*.img'
],
stdout
=
subprocess
.
PIPE
)
stdout
=
subprocess
.
PIPE
)
...
@@ -14,20 +16,21 @@ def recode_and_check(imgf, o_img, pretty):
...
@@ -14,20 +16,21 @@ def recode_and_check(imgf, o_img, pretty):
try
:
try
:
pb
=
pycriu
.
images
.
loads
(
o_img
,
pretty
)
pb
=
pycriu
.
images
.
loads
(
o_img
,
pretty
)
except
pycriu
.
images
.
MagicException
as
me
:
except
pycriu
.
images
.
MagicException
as
me
:
print
"
%
s magic
%
x error"
%
(
imgf
,
me
.
magic
)
print
(
"
%
s magic
%
x error"
%
(
imgf
,
me
.
magic
)
)
return
False
return
False
except
:
except
Exception
as
e
:
print
"
%
s
%
sdecode fails"
%
(
imgf
,
pretty
and
'pretty '
or
''
)
print
(
"
%
s
%
sdecode fails:
%
s"
%
(
imgf
,
pretty
and
'pretty '
or
''
,
e
)
)
return
False
return
False
try
:
try
:
r_img
=
pycriu
.
images
.
dumps
(
pb
)
r_img
=
pycriu
.
images
.
dumps
(
pb
)
except
:
except
Exception
as
e
:
print
"
%
s
%
sencode fails"
%
(
imgf
,
pretty
and
'pretty '
or
''
)
r_img
=
pycriu
.
images
.
dumps
(
pb
)
print
(
"
%
s
%
s encode fails:
%
s"
%
(
imgf
,
pretty
and
'pretty '
or
''
,
e
))
return
False
return
False
if
o_img
!=
r_img
:
if
o_img
!=
r_img
:
print
"
%
s
%
srecode mismatch"
%
(
imgf
,
pretty
and
'pretty '
or
''
)
print
(
"
%
s
%
s recode mismatch"
%
(
imgf
,
pretty
and
'pretty '
or
''
)
)
return
False
return
False
return
True
return
True
...
@@ -37,28 +40,28 @@ for imgf in find.stdout.readlines():
...
@@ -37,28 +40,28 @@ for imgf in find.stdout.readlines():
imgf
=
imgf
.
strip
()
imgf
=
imgf
.
strip
()
imgf_b
=
os
.
path
.
basename
(
imgf
)
imgf_b
=
os
.
path
.
basename
(
imgf
)
if
imgf_b
.
startswith
(
'pages-'
):
if
imgf_b
.
startswith
(
b
'pages-'
):
continue
continue
if
imgf_b
.
startswith
(
'iptables-'
):
if
imgf_b
.
startswith
(
b
'iptables-'
):
continue
continue
if
imgf_b
.
startswith
(
'ip6tables-'
):
if
imgf_b
.
startswith
(
b
'ip6tables-'
):
continue
continue
if
imgf_b
.
startswith
(
'route-'
):
if
imgf_b
.
startswith
(
b
'route-'
):
continue
continue
if
imgf_b
.
startswith
(
'route6-'
):
if
imgf_b
.
startswith
(
b
'route6-'
):
continue
continue
if
imgf_b
.
startswith
(
'ifaddr-'
):
if
imgf_b
.
startswith
(
b
'ifaddr-'
):
continue
continue
if
imgf_b
.
startswith
(
'tmpfs-'
):
if
imgf_b
.
startswith
(
b
'tmpfs-'
):
continue
continue
if
imgf_b
.
startswith
(
'netns-ct-'
):
if
imgf_b
.
startswith
(
b
'netns-ct-'
):
continue
continue
if
imgf_b
.
startswith
(
'netns-exp-'
):
if
imgf_b
.
startswith
(
b
'netns-exp-'
):
continue
continue
if
imgf_b
.
startswith
(
'rule-'
):
if
imgf_b
.
startswith
(
b
'rule-'
):
continue
continue
o_img
=
open
(
imgf
)
.
read
()
o_img
=
open
(
imgf
.
decode
(),
"rb"
)
.
read
()
if
not
recode_and_check
(
imgf
,
o_img
,
False
):
if
not
recode_and_check
(
imgf
,
o_img
,
False
):
test_pass
=
False
test_pass
=
False
if
not
recode_and_check
(
imgf
,
o_img
,
True
):
if
not
recode_and_check
(
imgf
,
o_img
,
True
):
...
@@ -67,7 +70,7 @@ for imgf in find.stdout.readlines():
...
@@ -67,7 +70,7 @@ for imgf in find.stdout.readlines():
find
.
wait
()
find
.
wait
()
if
not
test_pass
:
if
not
test_pass
:
print
"FAIL"
print
(
"FAIL"
)
sys
.
exit
(
1
)
sys
.
exit
(
1
)
print
"PASS"
print
(
"PASS"
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment