diff options
author | Chen Qi <Qi.Chen@windriver.com> | 2019-07-12 16:55:27 +0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2019-07-15 09:29:59 +0100 |
commit | d0d4c079d1d6c8903ab1b8f9bac83965debca030 (patch) | |
tree | bc54cca6f183320fd03fe0570e786477f5dbc019 /meta/lib | |
parent | d692ff5c893bfc55dcd94500edfeaf657022f5e5 (diff) | |
download | poky-d0d4c079d1d6c8903ab1b8f9bac83965debca030.tar.gz |
oeqa/runtime/rpm: ensure no user process running before deleting user
In case of systemd, `su -c 'xxx' test1' via ssh will create
several processes owned by test1, e.g. /lib/system/systemd --user.
These processes are actually managed by user@UID.service
(e.g. user@1000.service). And such service is managed
automatically by systemd. In other words, it will be cleaned
up by systemd automatically.
So we need to wait for systemd to clean it up before trying to
use `userdel' to delete the user.
(From OE-Core rev: 9d398be42a69d25277b929d760aaed1679f3cd54)
Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib')
-rw-r--r-- | meta/lib/oeqa/runtime/cases/rpm.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/meta/lib/oeqa/runtime/cases/rpm.py b/meta/lib/oeqa/runtime/cases/rpm.py index d8cabd3640..2b45d34e2e 100644 --- a/meta/lib/oeqa/runtime/cases/rpm.py +++ b/meta/lib/oeqa/runtime/cases/rpm.py | |||
@@ -4,6 +4,7 @@ | |||
4 | 4 | ||
5 | import os | 5 | import os |
6 | import fnmatch | 6 | import fnmatch |
7 | import time | ||
7 | 8 | ||
8 | from oeqa.runtime.case import OERuntimeTestCase | 9 | from oeqa.runtime.case import OERuntimeTestCase |
9 | from oeqa.core.decorator.depends import OETestDepends | 10 | from oeqa.core.decorator.depends import OETestDepends |
@@ -77,7 +78,21 @@ class RpmInstallRemoveTest(OERuntimeTestCase): | |||
77 | msg = 'status: %s. Cannot run rpm -qa: %s' % (status, output) | 78 | msg = 'status: %s. Cannot run rpm -qa: %s' % (status, output) |
78 | self.assertEqual(status, 0, msg=msg) | 79 | self.assertEqual(status, 0, msg=msg) |
79 | 80 | ||
81 | def check_no_process_for_user(u): | ||
82 | _, output = self.target.run(self.tc.target_cmds['ps']) | ||
83 | if u + ' ' in output: | ||
84 | return False | ||
85 | else: | ||
86 | return True | ||
87 | |||
80 | def unset_up_test_user(u): | 88 | def unset_up_test_user(u): |
89 | # ensure no test1 process in running | ||
90 | timeout = time.time() + 30 | ||
91 | while time.time() < timeout: | ||
92 | if check_no_process_for_user(u): | ||
93 | break | ||
94 | else: | ||
95 | time.sleep(1) | ||
81 | status, output = self.target.run('userdel -r %s' % u) | 96 | status, output = self.target.run('userdel -r %s' % u) |
82 | msg = 'Failed to erase user: %s' % output | 97 | msg = 'Failed to erase user: %s' % output |
83 | self.assertTrue(status == 0, msg=msg) | 98 | self.assertTrue(status == 0, msg=msg) |