[Buildroot] [PATCH] support/testing: use .assertRunOk() when possible

Romain Naour romain.naour at gmail.com
Sun Aug 22 15:00:17 UTC 2021


Thomas, Yann, All,

Le 26/06/2021 à 17:42, Yann E. MORIN a écrit :
> Thomas, All,
> 
> On 2021-06-26 15:32 +0200, Thomas Petazzoni spake thusly:
>> 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 at bootlin.com>
> 
> Applied to master, thanks.
> 
> Regards,
> Yann E. MORIN.
> 
>> ---
>>  support/testing/tests/fs/test_f2fs.py         |  3 +--
>>  support/testing/tests/fs/test_jffs2.py        |  3 +--
>>  support/testing/tests/fs/test_squashfs.py     |  3 +--
>>  support/testing/tests/init/base.py            |  6 ++----
>>  support/testing/tests/init/test_none.py       |  3 +--
>>  support/testing/tests/init/test_systemd.py    |  3 +--
>>  support/testing/tests/package/test_atop.py    |  6 ++----
>>  .../testing/tests/package/test_bmap_tools.py  |  3 +--
>>  .../tests/package/test_docker_compose.py      |  3 +--
>>  .../testing/tests/package/test_dropbear.py    |  6 ++----
>>  support/testing/tests/package/test_lua.py     |  3 +--
>>  support/testing/tests/package/test_netdata.py |  3 +--
>>  support/testing/tests/package/test_openssh.py |  6 ++----
>>  support/testing/tests/package/test_opkg.py    | 12 ++++-------
>>  support/testing/tests/package/test_perl.py    |  3 +--
>>  support/testing/tests/package/test_python.py  | 12 ++++-------
>>  .../tests/package/test_python_pytest.py       |  3 +--
>>  .../package/test_python_pytest_asyncio.py     |  3 +--
>>  support/testing/tests/package/test_redis.py   |  3 +--
>>  support/testing/tests/package/test_rust.py    |  6 ++----
>>  support/testing/tests/package/test_s6_rc.py   | 21 +++++++++----------
>>  support/testing/tests/package/test_sudo.py    |  6 ++----
>>  .../testing/tests/package/test_syslog_ng.py   | 10 ++++-----
>>  support/testing/tests/package/test_tmux.py    | 12 ++++-------
>>  24 files changed, 51 insertions(+), 91 deletions(-)
>>

[...]

>> diff --git a/support/testing/tests/init/base.py b/support/testing/tests/init/base.py
>> index 75cfbe9c59..80f7731ba3 100644
>> --- a/support/testing/tests/init/base.py
>> +++ b/support/testing/tests/init/base.py
>> @@ -39,10 +39,8 @@ class InitSystemBase(infra.basetest.BRTest):
>>  
>>      def check_init(self, path):
>>          cmd = "cmp /proc/1/exe {}".format(path)
>> -        _, exit_code = self.emulator.run(cmd)
>> -        self.assertEqual(exit_code, 0)
>> +        self.assertRunOk(cmd)
>>  
>>      def check_network(self, interface, exitCode=0):
>>          cmd = "ip addr show {} |grep inet".format(interface)
>> -        _, exit_code = self.emulator.run(cmd)
>> -        self.assertEqual(exit_code, exitCode)
>> +        self.assertRunOk(cmd)

What about exitCode argument?

Theses two tests are expecting check_network() failing (exitCode = 1)
tests.init.test_busybox.TestInitSystemBusyboxRw
tests.init.test_busybox.TestInitSystemBusyboxRo

Maybe define assertRunNok?

Best regards,
Romain


More information about the buildroot mailing list