Openembedded Core Discussions
 help / color / mirror / Atom feed
* [PATCH 0/2] rpm.py: two fixes
@ 2019-07-12  8:55 Chen Qi
  2019-07-12  8:55 ` [PATCH 1/2] rpm.py: ensure no user process running before deleting user Chen Qi
  2019-07-12  8:55 ` [PATCH 2/2] rpm.py: move test_rpm_query_nonroot test case to RpmBasicTest Chen Qi
  0 siblings, 2 replies; 3+ messages in thread
From: Chen Qi @ 2019-07-12  8:55 UTC (permalink / raw)
  To: openembedded-core

The following changes since commit 80ab79168ede2786868cbd354f0950c949f73527:

  gnome-themes-standard: remove (2019-07-11 09:32:50 +0100)

are available in the git repository at:

  git://git.pokylinux.org/poky-contrib ChenQi/runtime-rpm
  http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=ChenQi/runtime-rpm

Chen Qi (2):
  rpm.py: ensure no user process running before deleting user
  rpm.py: move test_rpm_query_nonroot test case to RpmBasicTest

 meta/lib/oeqa/runtime/cases/rpm.py | 74 +++++++++++++++++++++++---------------
 1 file changed, 45 insertions(+), 29 deletions(-)

-- 
1.9.1



^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] rpm.py: ensure no user process running before deleting user
  2019-07-12  8:55 [PATCH 0/2] rpm.py: two fixes Chen Qi
@ 2019-07-12  8:55 ` Chen Qi
  2019-07-12  8:55 ` [PATCH 2/2] rpm.py: move test_rpm_query_nonroot test case to RpmBasicTest Chen Qi
  1 sibling, 0 replies; 3+ messages in thread
From: Chen Qi @ 2019-07-12  8:55 UTC (permalink / raw)
  To: openembedded-core

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.

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
---
 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)
-- 
1.9.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] rpm.py: move test_rpm_query_nonroot test case to RpmBasicTest
  2019-07-12  8:55 [PATCH 0/2] rpm.py: two fixes Chen Qi
  2019-07-12  8:55 ` [PATCH 1/2] rpm.py: ensure no user process running before deleting user Chen Qi
@ 2019-07-12  8:55 ` Chen Qi
  1 sibling, 0 replies; 3+ messages in thread
From: Chen Qi @ 2019-07-12  8:55 UTC (permalink / raw)
  To: openembedded-core

The test_rpm_query_nonroot test case was in RpmInstallRemoveTest.
But it should logically belong to RpmBasicTest. So move it there.

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
---
 meta/lib/oeqa/runtime/cases/rpm.py | 59 +++++++++++++++++++-------------------
 1 file changed, 30 insertions(+), 29 deletions(-)

diff --git a/meta/lib/oeqa/runtime/cases/rpm.py b/meta/lib/oeqa/runtime/cases/rpm.py
index 2b45d34..8e18b42 100644
--- a/meta/lib/oeqa/runtime/cases/rpm.py
+++ b/meta/lib/oeqa/runtime/cases/rpm.py
@@ -30,35 +30,6 @@ class RpmBasicTest(OERuntimeTestCase):
         msg = 'status and output: %s and %s' % (status, output)
         self.assertEqual(status, 0, msg=msg)
 
-class RpmInstallRemoveTest(OERuntimeTestCase):
-
-    @classmethod
-    def setUpClass(cls):
-        pkgarch = cls.td['TUNE_PKGARCH'].replace('-', '_')
-        rpmdir = os.path.join(cls.tc.td['DEPLOY_DIR'], 'rpm', pkgarch)
-        # Pick base-passwd-doc as a test file to get installed, because it's small
-        # and it will always be built for standard targets
-        rpm_doc = 'base-passwd-doc-*.%s.rpm' % pkgarch
-        if not os.path.exists(rpmdir):
-            return
-        for f in fnmatch.filter(os.listdir(rpmdir), rpm_doc):
-            cls.test_file = os.path.join(rpmdir, f)
-        cls.dst = '/tmp/base-passwd-doc.rpm'
-
-    @OETestDepends(['rpm.RpmBasicTest.test_rpm_query'])
-    def test_rpm_install(self):
-        self.tc.target.copyTo(self.test_file, self.dst)
-        status, output = self.target.run('rpm -ivh /tmp/base-passwd-doc.rpm')
-        msg = 'Failed to install base-passwd-doc package: %s' % output
-        self.assertEqual(status, 0, msg=msg)
-        self.tc.target.run('rm -f %s' % self.dst)
-
-    @OETestDepends(['rpm.RpmInstallRemoveTest.test_rpm_install'])
-    def test_rpm_remove(self):
-        status,output = self.target.run('rpm -e base-passwd-doc')
-        msg = 'Failed to remove base-passwd-doc package: %s' % output
-        self.assertEqual(status, 0, msg=msg)
-
     @OETestDepends(['rpm.RpmBasicTest.test_rpm_query'])
     def test_rpm_query_nonroot(self):
 
@@ -105,6 +76,36 @@ class RpmInstallRemoveTest(OERuntimeTestCase):
         finally:
             unset_up_test_user(tuser)
 
+
+class RpmInstallRemoveTest(OERuntimeTestCase):
+
+    @classmethod
+    def setUpClass(cls):
+        pkgarch = cls.td['TUNE_PKGARCH'].replace('-', '_')
+        rpmdir = os.path.join(cls.tc.td['DEPLOY_DIR'], 'rpm', pkgarch)
+        # Pick base-passwd-doc as a test file to get installed, because it's small
+        # and it will always be built for standard targets
+        rpm_doc = 'base-passwd-doc-*.%s.rpm' % pkgarch
+        if not os.path.exists(rpmdir):
+            return
+        for f in fnmatch.filter(os.listdir(rpmdir), rpm_doc):
+            cls.test_file = os.path.join(rpmdir, f)
+        cls.dst = '/tmp/base-passwd-doc.rpm'
+
+    @OETestDepends(['rpm.RpmBasicTest.test_rpm_query'])
+    def test_rpm_install(self):
+        self.tc.target.copyTo(self.test_file, self.dst)
+        status, output = self.target.run('rpm -ivh /tmp/base-passwd-doc.rpm')
+        msg = 'Failed to install base-passwd-doc package: %s' % output
+        self.assertEqual(status, 0, msg=msg)
+        self.tc.target.run('rm -f %s' % self.dst)
+
+    @OETestDepends(['rpm.RpmInstallRemoveTest.test_rpm_install'])
+    def test_rpm_remove(self):
+        status,output = self.target.run('rpm -e base-passwd-doc')
+        msg = 'Failed to remove base-passwd-doc package: %s' % output
+        self.assertEqual(status, 0, msg=msg)
+
     @OETestDepends(['rpm.RpmInstallRemoveTest.test_rpm_remove'])
     def test_check_rpm_install_removal_log_file_size(self):
         """
-- 
1.9.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-07-12  8:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-07-12  8:55 [PATCH 0/2] rpm.py: two fixes Chen Qi
2019-07-12  8:55 ` [PATCH 1/2] rpm.py: ensure no user process running before deleting user Chen Qi
2019-07-12  8:55 ` [PATCH 2/2] rpm.py: move test_rpm_query_nonroot test case to RpmBasicTest Chen Qi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox