summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa
diff options
context:
space:
mode:
authorEdwin Plauchu <edwin.plauchu.camacho@intel.com>2016-09-08 19:16:04 -0500
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-09-14 22:22:07 +0100
commit2c7849fdcb381ef3450d2baea3d6848795469176 (patch)
treeeffc0c2ea8bd920424c973b7bae372842e9ba554 /meta/lib/oeqa
parent0736079dc614da90b548236ba81679ae25adc3b2 (diff)
downloadpoky-2c7849fdcb381ef3450d2baea3d6848795469176.tar.gz
oeqa: Remove linux user utilized for rpm test.
When trying to re-test smart rpm tests. A fail arises due to a linux user previously created upon the image. We've added a few lines to delete such user and his home dir when finishing test. [YOCTO #9204] (From OE-Core rev: d1a80ac434bb798634bbb792ff7df59148ec26be) Signed-off-by: Edwin Plauchu <edwin.plauchu.camacho@intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa')
-rw-r--r--meta/lib/oeqa/runtime/rpm.py32
1 files changed, 26 insertions, 6 deletions
diff --git a/meta/lib/oeqa/runtime/rpm.py b/meta/lib/oeqa/runtime/rpm.py
index 4d03ecbf4a..7f514ca00c 100644
--- a/meta/lib/oeqa/runtime/rpm.py
+++ b/meta/lib/oeqa/runtime/rpm.py
@@ -51,12 +51,32 @@ class RpmInstallRemoveTest(oeRuntimeTest):
51 @testcase(1096) 51 @testcase(1096)
52 @skipUnlessPassed('test_ssh') 52 @skipUnlessPassed('test_ssh')
53 def test_rpm_query_nonroot(self): 53 def test_rpm_query_nonroot(self):
54 (status, output) = self.target.run('useradd test1') 54
55 self.assertTrue(status == 0, msg="Failed to create new user: " + output) 55 def set_up_test_user(u):
56 (status, output) = self.target.run('su -c id test1') 56 (status, output) = self.target.run("id -u %s" % u)
57 self.assertTrue('(test1)' in output, msg="Failed to execute as new user") 57 if status == 0:
58 (status, output) = self.target.run('su -c "rpm -qa" test1 ') 58 pass
59 self.assertEqual(status, 0, msg="status: %s. Cannot run rpm -qa: %s" % (status, output)) 59 else:
60 (status, output) = self.target.run("useradd %s" % u)
61 self.assertTrue(status == 0, msg="Failed to create new user: " + output)
62
63 def exec_as_test_user(u):
64 (status, output) = self.target.run("su -c id %s" % u)
65 self.assertTrue("({0})".format(u) in output, msg="Failed to execute as new user")
66 (status, output) = self.target.run("su -c \"rpm -qa\" %s " % u)
67 self.assertEqual(status, 0, msg="status: %s. Cannot run rpm -qa: %s" % (status, output))
68
69 def unset_up_test_user(u):
70 (status, output) = self.target.run("userdel -r %s" % u)
71 self.assertTrue(status == 0, msg="Failed to erase user: %s" % output)
72
73 tuser = 'test1'
74
75 try:
76 set_up_test_user(tuser)
77 exec_as_test_user(tuser)
78 finally:
79 unset_up_test_user(tuser)
60 80
61 @testcase(195) 81 @testcase(195)
62 @skipUnlessPassed('test_rpm_install') 82 @skipUnlessPassed('test_rpm_install')