[CRIU] [PATCH 11/11] zdtm.py: Check how user-mode works
Pavel Emelyanov
xemul at parallels.com
Tue Dec 15 11:26:48 PST 2015
There are several restrictions:
1. Onlu dump is checked (--norst) for now
2. Only host flavor as tests has to start themselves in non-root mode
3. Only non-suid tests
4. TCP doesn't work too, should be manually excluded :\
Signed-off-by: Pavel Emelyanov <xemul at parallels.com>
---
test/zdtm.py | 34 ++++++++++++++++++++++++++++++----
1 file changed, 30 insertions(+), 4 deletions(-)
diff --git a/test/zdtm.py b/test/zdtm.py
index d58c621..a7e48e5 100755
--- a/test/zdtm.py
+++ b/test/zdtm.py
@@ -321,6 +321,7 @@ class zdtm_test:
env = self._env
env['ZDTM_THREAD_BOMB'] = "5"
if not test_flag(self.__desc, 'suid'):
+ # Numbers should match those in criu_cli
env['ZDTM_UID'] = "18943"
env['ZDTM_GID'] = "58467"
env['ZDTM_GROUPS'] = "27495 48244"
@@ -570,6 +571,7 @@ class criu_cli:
self.__fault = (opts['fault'])
self.__sat = (opts['sat'] and True or False)
self.__dedup = (opts['dedup'] and True or False)
+ self.__user = (opts['user'] and True or False)
def logs(self):
return self.__dump_path
@@ -597,14 +599,19 @@ class criu_cli:
return os.path.join(self.__dump_path, "%d" % self.__iter)
@staticmethod
- def __criu(action, args, fault = None, strace = []):
+ def __criu(action, args, fault = None, strace = [], preexec = None):
env = None
if fault:
print "Forcing %s fault" % fault
env = dict(os.environ, CRIU_FAULT = fault)
- cr = subprocess.Popen(strace + [criu_bin, action] + args, env = env)
+ cr = subprocess.Popen(strace + [criu_bin, action] + args, env = env, preexec_fn = preexec)
return cr.wait()
+ def set_user_id(self):
+ # Numbers should match those in zdtm_test
+ os.setresgid(58467, 58467, 58467)
+ os.setresuid(18943, 18943, 18943)
+
def __criu_act(self, action, opts, log = None):
if not log:
log = action + ".log"
@@ -624,7 +631,9 @@ class criu_cli:
strace += [ '-f' ]
s_args += [ '--action-script', os.getcwd() + '/../scripts/fake-restore.sh' ]
- ret = self.__criu(action, s_args, self.__fault, strace)
+ preexec = self.__user and self.set_user_id or None
+
+ ret = self.__criu(action, s_args, self.__fault, strace, preexec)
grep_errors(os.path.join(self.__ddir(), log))
if ret != 0:
if self.__fault or self.__test.blocking() or (self.__sat and action == 'restore'):
@@ -635,6 +644,7 @@ class criu_cli:
def dump(self, action, opts = []):
self.__iter += 1
os.mkdir(self.__ddir())
+ os.chmod(self.__ddir(), 0777)
a_opts = ["-t", self.__test.getpid()]
if self.__prev_dump_iter:
@@ -866,7 +876,8 @@ class launcher:
self.__show_progress()
nd = ('nocr', 'norst', 'pre', 'iters', 'page_server', 'sibling', \
- 'fault', 'keep_img', 'report', 'snaps', 'sat', 'dedup', 'sbs')
+ 'fault', 'keep_img', 'report', 'snaps', 'sat', \
+ 'dedup', 'sbs', 'user')
arg = repr((name, desc, flavor, { d: self.__opts[d] for d in nd }))
if self.__max > 1 and self.__total > 1:
@@ -1034,6 +1045,10 @@ def run_tests(opts):
l.skip(t, "self")
continue
+ if opts['user'] and test_flag(tdesc, 'suid'):
+ l.skip(t, "suid test in user mode")
+ continue
+
test_flavs = tdesc.get('flavor', 'h ns uns').split()
opts_flavs = (opts['flavor'] or 'h,ns,uns').split(',')
if opts_flavs != ['best']:
@@ -1047,6 +1062,16 @@ def run_tests(opts):
# don't worry if uns isn't in run_flavs
pass
+ if opts['user']:
+ # FIXME -- probably uns will make sense
+ try:
+ run_flavs.remove("ns")
+ except KeyError:
+ pass
+ try:
+ run_flavs.remove("uns")
+ except KeyError:
+ pass
if run_flavs:
l.run_test(t, tdesc, run_flavs)
@@ -1219,6 +1244,7 @@ rp.add_argument("--iters", help = "Do CR cycle several times before check (n[:pa
rp.add_argument("--fault", help = "Test fault injection")
rp.add_argument("--sat", help = "Generate criu strace-s for sat tool (restore is fake, images are kept)", action = 'store_true')
rp.add_argument("--sbs", help = "Do step-by-step execution, asking user for keypress to continue", action = 'store_true')
+rp.add_argument("--user", help = "Run CRIU as regular user", action = 'store_true')
rp.add_argument("--page-server", help = "Use page server dump", action = 'store_true')
rp.add_argument("-p", "--parallel", help = "Run test in parallel")
--
1.9.3
More information about the CRIU
mailing list