[Buildroot] [RFC 1/4] support/testing: add perl test

François Perrad francois.perrad at gadz.org
Wed Nov 21 16:26:11 UTC 2018


Le lun. 19 nov. 2018 à 02:11, Ricardo Martincoski <
ricardo.martincoski at gmail.com> a écrit :

> Hello,
>
> In overall, the series looks good.
> Except for the general discussion in the cover letter about which path we
> want
> to follow (add the infra to add a .pl to the image in build time or not),
> I have
> only nits.
>
> On Sat, Nov 17, 2018 at 03:52 PM, Francois Perrad wrote:
>
> [snip]
> > +class TestPerl(infra.basetest.BRTest):
> > +    config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
> > +        """
> > +        BR2_TARGET_ROOTFS_CPIO=y
> > +        # BR2_TARGET_ROOTFS_TAR is not set
> > +        BR2_PACKAGE_PERL=y
>
> nit: this is not the order after 'make savedefconfig'
>
> > +        """
> > +
> [snip]
> > +    def version_test(self, timeout=-1):
>
> This timeout is always used with its default value, you can remove from
> here and
> from the call to emulator.run 2 lines below.
>
> > +        cmd = "perl -v"
>
> What about using this instead?
>         cmd = "perl -v | grep 'This is perl 5'"
>

As tester, I don't like this kind of code, because I never know which exit
code is available, the one from perl or the one from grep.
Code written for test must be obvious.
See the following example:

#!/usr/bin/env python
import unittest
import subprocess

class DeveloperWay(unittest.TestCase):
    def testPerl(self):
        retcode = subprocess.call("perl -v | grep 'This is perl 5'",
shell=True)
        self.assertEqual(retcode, 0)

class TesterWay(unittest.TestCase):
    def testPerl(self):
        retcode = subprocess.call('perl -v', shell=True)
        self.assertEqual(retcode, 0)
        output = subprocess.check_output('perl -v', shell=True)
        self.assert_('This is perl 5' in output)

unittest.main()

François

I guess Perl 6 will take a long time to be supported in Buildroot.
>
> > +        _, exit_code = self.emulator.run(cmd, timeout)
> > +        self.assertEqual(exit_code, 0)
> > +
> > +    def module_test(self, module, script="1", timeout=-1):
>
> If we end up using the extra logic (basically copied from
> TestPythonPackageBase)
> and having the .pl file added to the tree, this method would not be needed.
>
>
> Regards,
> Ricardo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20181121/13a37a58/attachment.html>


More information about the buildroot mailing list