[oe-commits] [openembedded-core] 07/15: oeqa/runtime/rpm: ensure no user process running before deleting user

git at git.openembedded.org git at git.openembedded.org
Mon Jul 15 08:32:22 UTC 2019


This is an automated email from the git hooks/post-receive script.

rpurdie pushed a commit to branch master
in repository openembedded-core.

commit 9d398be42a69d25277b929d760aaed1679f3cd54
Author: Chen Qi <Qi.Chen at windriver.com>
AuthorDate: Fri Jul 12 16:55:27 2019 +0800

    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 at UID.service
    (e.g. user at 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.
    
    Signed-off-by: Chen Qi <Qi.Chen at windriver.com>
    Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
 meta/lib/oeqa/runtime/cases/rpm.py | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/meta/lib/oeqa/runtime/cases/rpm.py b/meta/lib/oeqa/runtime/cases/rpm.py
index d8cabd3..2b45d34 100644
--- a/meta/lib/oeqa/runtime/cases/rpm.py
+++ b/meta/lib/oeqa/runtime/cases/rpm.py
@@ -4,6 +4,7 @@
 
 import os
 import fnmatch
+import time
 
 from oeqa.runtime.case import OERuntimeTestCase
 from oeqa.core.decorator.depends import OETestDepends
@@ -77,7 +78,21 @@ class RpmInstallRemoveTest(OERuntimeTestCase):
             msg = 'status: %s. Cannot run rpm -qa: %s' % (status, output)
             self.assertEqual(status, 0, msg=msg)
 
+        def check_no_process_for_user(u):
+            _, output = self.target.run(self.tc.target_cmds['ps'])
+            if u + ' ' in output:
+                return False
+            else:
+                return True
+
         def unset_up_test_user(u):
+            # ensure no test1 process in running
+            timeout = time.time() + 30
+            while time.time() < timeout:
+                if check_no_process_for_user(u):
+                    break
+                else:
+                    time.sleep(1)
             status, output = self.target.run('userdel -r %s' % u)
             msg = 'Failed to erase user: %s' % output
             self.assertTrue(status == 0, msg=msg)

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Openembedded-commits mailing list