public inbox for openembedded-core@lists.openembedded.org
 help / color / mirror / Atom feed
* [PATCH] oeqa: Remove linux user utilized for rpm test.
@ 2016-09-08  1:26 Edwin Plauchu
  2016-09-08 10:38 ` Burton, Ross
  2016-09-08 11:01 ` Burton, Ross
  0 siblings, 2 replies; 3+ messages in thread
From: Edwin Plauchu @ 2016-09-08  1:26 UTC (permalink / raw)
  To: openembedded-core; +Cc: Edwin Plauchu

From: Edwin Plauchu <edwin.plauchu.camacho@intel.com>

When trying to re-test smart rpm tests. A fail arises
due to a linux user previously created upon the image.
W've added a few lines to delete such user and his home dir
when finishing test.

[YOCTO #9204]

Signed-off-by: Edwin Plauchu <edwin.plauchu.camacho@intel.com>
---
 meta/lib/oeqa/runtime/rpm.py | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/meta/lib/oeqa/runtime/rpm.py b/meta/lib/oeqa/runtime/rpm.py
index 4d03ecb..285f39b 100644
--- a/meta/lib/oeqa/runtime/rpm.py
+++ b/meta/lib/oeqa/runtime/rpm.py
@@ -51,12 +51,15 @@ class RpmInstallRemoveTest(oeRuntimeTest):
     @testcase(1096)
     @skipUnlessPassed('test_ssh')
     def test_rpm_query_nonroot(self):
-        (status, output) = self.target.run('useradd test1')
+        test_user = 'test1'
+        (status, output) = self.target.run("useradd %s" % test_user)
         self.assertTrue(status == 0, msg="Failed to create new user: " + output)
-        (status, output) = self.target.run('su -c id test1')
+        (status, output) = self.target.run("su -c id %s" % test_user)
         self.assertTrue('(test1)' in output, msg="Failed to execute as new user")
-        (status, output) = self.target.run('su -c "rpm -qa" test1 ')
+        (status, output) = self.target.run("su -c \"rpm -qa\" %s " % test_user)
         self.assertEqual(status, 0, msg="status: %s. Cannot run rpm -qa: %s" % (status, output))
+        (status, output) = self.target.run("userdel -r %s" % test_user)
+        self.assertTrue(status == 0, msg="Failed to erase user: %s" % output)
 
     @testcase(195)
     @skipUnlessPassed('test_rpm_install')
-- 
2.9.3



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

* Re: [PATCH] oeqa: Remove linux user utilized for rpm test.
  2016-09-08  1:26 [PATCH] oeqa: Remove linux user utilized for rpm test Edwin Plauchu
@ 2016-09-08 10:38 ` Burton, Ross
  2016-09-08 11:01 ` Burton, Ross
  1 sibling, 0 replies; 3+ messages in thread
From: Burton, Ross @ 2016-09-08 10:38 UTC (permalink / raw)
  To: Edwin Plauchu; +Cc: Edwin Plauchu, OE-core

[-- Attachment #1: Type: text/plain, Size: 1180 bytes --]

On 8 September 2016 at 02:26, Edwin Plauchu <
edwin.plauchu.camacho@linux.intel.com> wrote:

>      def test_rpm_query_nonroot(self):
> -        (status, output) = self.target.run('useradd test1')
> +        test_user = 'test1'
> +        (status, output) = self.target.run("useradd %s" % test_user)
>          self.assertTrue(status == 0, msg="Failed to create new user: " +
> output)
> -        (status, output) = self.target.run('su -c id test1')
> +        (status, output) = self.target.run("su -c id %s" % test_user)
>          self.assertTrue('(test1)' in output, msg="Failed to execute as
> new user")
> -        (status, output) = self.target.run('su -c "rpm -qa" test1 ')
> +        (status, output) = self.target.run("su -c \"rpm -qa\" %s " %
> test_user)
>          self.assertEqual(status, 0, msg="status: %s. Cannot run rpm -qa:
> %s" % (status, output))
> +        (status, output) = self.target.run("userdel -r %s" % test_user)
> +        self.assertTrue(status == 0, msg="Failed to erase user: %s" %
> output)
>

The user removal should be in a try/finally block around the test so that
it always executes even if the test fails.

Ross

[-- Attachment #2: Type: text/html, Size: 1800 bytes --]

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

* Re: [PATCH] oeqa: Remove linux user utilized for rpm test.
  2016-09-08  1:26 [PATCH] oeqa: Remove linux user utilized for rpm test Edwin Plauchu
  2016-09-08 10:38 ` Burton, Ross
@ 2016-09-08 11:01 ` Burton, Ross
  1 sibling, 0 replies; 3+ messages in thread
From: Burton, Ross @ 2016-09-08 11:01 UTC (permalink / raw)
  To: Edwin Plauchu; +Cc: Edwin Plauchu, OE-core

[-- Attachment #1: Type: text/plain, Size: 417 bytes --]

On 8 September 2016 at 02:26, Edwin Plauchu <
edwin.plauchu.camacho@linux.intel.com> wrote:

> When trying to re-test smart rpm tests. A fail arises
> due to a linux user previously created upon the image.
> W've added a few lines to delete such user and his home dir
> when finishing test.
>

Also as part of a belt-and-brances approach the test should not create a
new user if it already exists.

Ross

[-- Attachment #2: Type: text/html, Size: 844 bytes --]

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

end of thread, other threads:[~2016-09-08 11:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-08  1:26 [PATCH] oeqa: Remove linux user utilized for rpm test Edwin Plauchu
2016-09-08 10:38 ` Burton, Ross
2016-09-08 11:01 ` Burton, Ross

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