mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-07-22 01:31:34 +00:00
When Python 2 is not installed we assume that /usr/bin/python refers to version 3 of Python and the executable /usr/bin/python2 does not exist. This commit also resolves a compatibility issue with Popen where in Py2 file descriptors will be inherited by the child process and in Py3 they will be closed by default. Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
62 lines
1.2 KiB
Python
62 lines
1.2 KiB
Python
#!/usr/bin/env python
|
|
|
|
import sys, os
|
|
import hashlib
|
|
from subprocess import Popen, PIPE
|
|
|
|
str2 = "test_test" * (1 << 20)
|
|
str1 = "Test_Test!"
|
|
|
|
src = os.getenv("TCP_SRC", "127.0.0.1")
|
|
dst = os.getenv("TCP_DST", "127.0.0.1")
|
|
sport = os.getenv("TCP_SPORT", "12345")
|
|
dport = os.getenv("TCP_DPORT", "54321")
|
|
|
|
print(sys.argv[1])
|
|
args = [
|
|
sys.argv[1], "--addr", src, "--port", sport, "--seq", "555", "--next",
|
|
"--addr", dst, "--port", dport, "--seq", "666", "--reverse", "--",
|
|
"./tcp-test.py"
|
|
]
|
|
|
|
p1 = Popen(args + ["dst"], stdout=PIPE, stdin=PIPE)
|
|
|
|
args.remove("--reverse")
|
|
|
|
p2 = Popen(args + ["src"], stdout=PIPE, stdin=PIPE)
|
|
|
|
p1.stdout.read(5)
|
|
p2.stdout.read(5)
|
|
p1.stdin.write("start")
|
|
p2.stdin.write("start")
|
|
|
|
p1.stdin.write(str1)
|
|
p1.stdin.close()
|
|
p2.stdin.write(str2)
|
|
p2.stdin.close()
|
|
|
|
s = p1.stdout.read()
|
|
m = hashlib.md5()
|
|
m.update(str2)
|
|
str2 = m.hexdigest()
|
|
|
|
if str2 != eval(s):
|
|
print("FAIL", repr(str2), repr(s))
|
|
sys.exit(5)
|
|
|
|
s = p1.stdout.read()
|
|
m = hashlib.md5()
|
|
m.update(str1)
|
|
str1 = m.hexdigest()
|
|
|
|
s = p2.stdout.read()
|
|
if str1 != eval(s):
|
|
print("FAIL", repr(str1), s)
|
|
sys.exit(5)
|
|
|
|
if p1.wait():
|
|
sys.exit(1)
|
|
if p2.wait():
|
|
sys.exit(1)
|
|
|
|
print("PASS")
|