[RESEND,v2,3/5] zdtm: add reset_pid() function

Submitted by Adrian Reber on May 23, 2017, 9:42 a.m.

Details

Message ID 1495532535-22405-3-git-send-email-adrian@lisas.de
State New
Series "Series without cover letter"
Headers show

Commit Message

Adrian Reber May 23, 2017, 9:42 a.m.
From: Adrian Reber <areber@redhat.com>

In preparation for the zdtm option '--check-only' a new helper function
reset_pid() is added which writes to ns_last_pid to avoid PID collisions
during check-only restore and the real restore.

Signed-off-by: Adrian Reber <areber@redhat.com>
---
 test/zdtm.py | 7 +++++++
 1 file changed, 7 insertions(+)

Patch hide | download patch | download mbox

diff --git a/test/zdtm.py b/test/zdtm.py
index 26b8939..19fbec2 100755
--- a/test/zdtm.py
+++ b/test/zdtm.py
@@ -336,6 +336,13 @@  def wait_pid_die(pid, who, tmo = 30):
 def test_flag(tdesc, flag):
 	return flag in tdesc.get('flags', '').split()
 
+
+def reset_pid(pid = 1):
+	fd = open('/proc/sys/kernel/ns_last_pid', 'w')
+	fd.write('%s' % pid)
+	fd.close()
+
+
 #
 # Exception thrown when something inside the test goes wrong,
 # e.g. test doesn't start, criu returns with non zero code or