mirror of
https://gitlab.com/buildroot.org/buildroot.git
synced 2026-08-01 21:23:51 -09:00
support/testing: test_polkit.py: use assertRun{, Not}Ok()
Use the helpers to simplify the test. Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
This commit is contained in:
@@ -43,20 +43,16 @@ class TestPolkitSystemd(TestPolkitInfra):
|
||||
rule_file = "systemd-timesyncd-restart.rules"
|
||||
for rule_path in TestPolkitInfra.rule_paths:
|
||||
cmd = "su brtest -c '/bin/systemctl restart systemd-timesyncd.service'"
|
||||
_, exit_code = self.emulator.run(cmd, 10)
|
||||
self.assertNotEqual(exit_code, 0)
|
||||
self.assertRunNotOk(cmd, 10)
|
||||
|
||||
cmd = "cp /root/{file} {path}".format(file=rule_file, path=rule_path)
|
||||
_, exit_code = self.emulator.run(cmd, 10)
|
||||
self.assertEqual(exit_code, 0)
|
||||
self.assertRunOk(cmd, 10)
|
||||
|
||||
cmd = "su brtest -c '/bin/systemctl restart systemd-timesyncd.service'"
|
||||
_, exit_code = self.emulator.run(cmd, 10)
|
||||
self.assertEqual(exit_code, 0)
|
||||
self.assertRunOk(cmd, 10)
|
||||
|
||||
cmd = "rm {path}/{file}".format(file=rule_file, path=rule_path)
|
||||
_, exit_code = self.emulator.run(cmd, 10)
|
||||
self.assertEqual(exit_code, 0)
|
||||
self.assertRunOk(cmd, 10)
|
||||
|
||||
|
||||
class TestPolkitInitd(TestPolkitInfra):
|
||||
@@ -73,8 +69,7 @@ class TestPolkitInitd(TestPolkitInfra):
|
||||
self.assertEqual(output[0], "Error executing command as another user: Not authorized")
|
||||
|
||||
cmd = "cp /root/{file} {path}/{file}".format(file=rule_file, path=rule_path)
|
||||
_, exit_code = self.emulator.run(cmd, 10)
|
||||
self.assertEqual(exit_code, 0)
|
||||
self.assertRunOk(cmd, 10)
|
||||
|
||||
cmd = "su brtest -c 'pkexec hello-polkit'"
|
||||
output, exit_code = self.emulator.run(cmd, 10)
|
||||
@@ -82,5 +77,4 @@ class TestPolkitInitd(TestPolkitInfra):
|
||||
self.assertEqual(output[0], "Hello polkit!")
|
||||
|
||||
cmd = "rm {path}/{file}".format(file=rule_file, path=rule_path)
|
||||
_, exit_code = self.emulator.run(cmd, 10)
|
||||
self.assertEqual(exit_code, 0)
|
||||
self.assertRunOk(cmd, 10)
|
||||
|
||||
Reference in New Issue
Block a user