support/testing: use .assertRunOk() when possible
The BRTest() class implements an assertRunOk() method that does the very common work of running a command inside the emulator, and checking that it is successful. This commit changes all locations where this .assertRunOk() method can be used, instead of open-coding the same logic. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com> Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
This commit is contained in:
committed by
Yann E. MORIN
parent
f579afc393
commit
afc1ed4d51
@@ -22,11 +22,9 @@ class TestSudo(infra.basetest.BRTest):
|
||||
# -h set home directory
|
||||
# -H don't create home directory
|
||||
# -s set shell
|
||||
_, exit_code = self.emulator.run("adduser -D -h /tmp -H -s /bin/sh sudotest")
|
||||
self.assertEqual(exit_code, 0)
|
||||
self.assertRunOk("adduser -D -h /tmp -H -s /bin/sh sudotest")
|
||||
|
||||
_, exit_code = self.emulator.run("echo 'sudotest ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers")
|
||||
self.assertEqual(exit_code, 0)
|
||||
self.assertRunOk("echo 'sudotest ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers")
|
||||
|
||||
output, exit_code = self.emulator.run("su - sudotest -c 'echo hello world'")
|
||||
self.assertEqual(output, ["hello world"])
|
||||
|
||||
Reference in New Issue
Block a user