-
Notifications
You must be signed in to change notification settings - Fork 614
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
criu-ns: Add tests for criu-ns script (WIP)
These changes add test implementations for criu-ns script. Fixes: #1909 Signed-off-by: Dhanuka Warusadura <csx@tuta.io>
- Loading branch information
1 parent
e663060
commit a88fa8d
Showing
3 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
run: | ||
../../zdtm_ct run.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
#!/usr/bin/env python | ||
|
||
import os | ||
import shutil | ||
import signal | ||
import subprocess | ||
import sys | ||
|
||
CR_NS = "../../.././scripts/criu-ns" | ||
|
||
os.chdir(os.getcwd()) | ||
|
||
|
||
def check_dumpdir(): | ||
if os.access("dumpdir", os.X_OK): | ||
shutil.rmtree("dumpdir") | ||
os.mkdir("dumpdir", 0o755) | ||
|
||
|
||
check_dumpdir() | ||
|
||
# dump with --shell-job | ||
cmd = ["sleep", "inf"] | ||
print("Run: %s" % " ".join(cmd)) | ||
pid = subprocess.Popen(cmd).pid | ||
cmd = [CR_NS, "dump", "-D", "dumpdir", "-v4", "-o", "dump.log", | ||
"--shell-job", "-t", str(pid)] | ||
ret = subprocess.Popen(cmd).wait() | ||
if ret != 0: | ||
os.kill(pid, signal.SIGTERM) | ||
sys.exit(ret) | ||
|
||
# restore with --shell-job | ||
cmd = [CR_NS, "restore", "-D", "dumpdir", "-v4", "-o", "restore.log", | ||
"--shell-job"] | ||
ret = subprocess.Popen(cmd).wait() | ||
if ret != 0: | ||
sys.exit(ret) | ||
|
||
check_dumpdir() | ||
|
||
# dump without --shell-job | ||
cmd = ["setsid", "./test.sh"] | ||
print("Run: %s" % " ".join(cmd)) | ||
pid = subprocess.Popen(cmd, stdin=subprocess.DEVNULL, | ||
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL).pid | ||
cmd = [CR_NS, "dump", "-D", "dumpdir", "-v4", "-o", "dump.log", | ||
"-t", str(pid)] | ||
ret = subprocess.Popen(cmd).wait() | ||
if ret != 0: | ||
os.kill(pid, signal.SIGTERM) | ||
sys.exit(ret) | ||
|
||
# restore without --shell-job | ||
cmd = [CR_NS, "restore", "-D", "dumpdir", "-v4", "-o", "restore.log"] | ||
ret = subprocess.Popen(cmd).wait() | ||
if ret != 0: | ||
sys.exit(ret) | ||
|
||
check_dumpdir() | ||
|
||
# dump to test with --restore-detached | ||
cmd = ["setsid", "./test.sh"] | ||
print("Run: %s" % " ".join(cmd)) | ||
pid = subprocess.Popen(cmd, stdin=subprocess.DEVNULL, | ||
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL).pid | ||
cmd = [CR_NS, "dump", "-D", "dumpdir", "-v4", "-o", "dump.log", | ||
"-t", str(pid)] | ||
ret = subprocess.Popen(cmd).wait() | ||
if ret != 0: | ||
os.kill(pid, signal.SIGTERM) | ||
sys.exit(ret) | ||
|
||
# restore with --restore-detached | ||
cmd = [CR_NS, "restore", "-D", "dumpdir", "-v4", "-o", "restore.log", | ||
"--restore-detached"] | ||
ret = subprocess.Popen(cmd).wait() | ||
if ret != 0: | ||
sys.exit(ret) | ||
|
||
sys.exit(0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/sh | ||
|
||
while :; do | ||
sleep 1 | ||
date | ||
done | ||
EOF |