summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa
diff options
context:
space:
mode:
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')