diff options
author | Edwin Plauchu <edwin.plauchu.camacho@intel.com> | 2016-09-08 19:16:04 -0500 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-09-13 15:18:43 +0100 |
commit | d1a80ac434bb798634bbb792ff7df59148ec26be (patch) | |
tree | 7704b4f3999c8070822590119fd41b150b81f8d0 /meta | |
parent | 936eb9aac055f1d4f41bb351477a0f5bebf76a0e (diff) | |
download | openembedded-core-d1a80ac434bb798634bbb792ff7df59148ec26be.tar.gz openembedded-core-d1a80ac434bb798634bbb792ff7df59148ec26be.tar.bz2 openembedded-core-d1a80ac434bb798634bbb792ff7df59148ec26be.zip |
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]
Signed-off-by: Edwin Plauchu <edwin.plauchu.camacho@intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Diffstat (limited to 'meta')
-rw-r--r-- | meta/lib/oeqa/runtime/rpm.py | 32 |
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): @testcase(1096) @skipUnlessPassed('test_ssh') def test_rpm_query_nonroot(self): - (status, output) = self.target.run('useradd test1') - self.assertTrue(status == 0, msg="Failed to create new user: " + output) - (status, output) = self.target.run('su -c id test1') - self.assertTrue('(test1)' in output, msg="Failed to execute as new user") - (status, output) = self.target.run('su -c "rpm -qa" test1 ') - self.assertEqual(status, 0, msg="status: %s. Cannot run rpm -qa: %s" % (status, output)) + + def set_up_test_user(u): + (status, output) = self.target.run("id -u %s" % u) + if status == 0: + pass + else: + (status, output) = self.target.run("useradd %s" % u) + self.assertTrue(status == 0, msg="Failed to create new user: " + output) + + def exec_as_test_user(u): + (status, output) = self.target.run("su -c id %s" % u) + self.assertTrue("({0})".format(u) in output, msg="Failed to execute as new user") + (status, output) = self.target.run("su -c \"rpm -qa\" %s " % u) + self.assertEqual(status, 0, msg="status: %s. Cannot run rpm -qa: %s" % (status, output)) + + def unset_up_test_user(u): + (status, output) = self.target.run("userdel -r %s" % u) + self.assertTrue(status == 0, msg="Failed to erase user: %s" % output) + + tuser = 'test1' + + try: + set_up_test_user(tuser) + exec_as_test_user(tuser) + finally: + unset_up_test_user(tuser) @testcase(195) @skipUnlessPassed('test_rpm_install') |