Fix _FunctionalBase.test_run_as

This test was comparing strings and bytes, and had no chance of ever
passing. It is skipped if not run as root, which is probably why the
failure does not show up often.

We now cast everything to integers, since that is what we are ultimately
interested in.

Change-Id: Ia23e687cf13439c15b562de909455324bba99dbb
This commit is contained in:
Cyril Roelandt 2024-08-30 15:54:24 +02:00
parent c42ef394dd
commit 3bb398bbfe

View File

@ -111,11 +111,11 @@ later_install_cmd: CommandFilter, %s, root
# Should run as 'nobody'
code, out, err = self.execute(['id', '-u'])
self.assertEqual('%s\n' % pwd.getpwnam('nobody').pw_uid, out)
self.assertEqual(pwd.getpwnam('nobody').pw_uid, int(out.strip()))
# Should run as 'root'
code, out, err = self.execute(['sh', '-c', 'id -u'])
self.assertEqual('0\n', out)
self.assertEqual(0, int(out.strip()))
class RootwrapTest(_FunctionalBase, testtools.TestCase):