All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Purdie <richard.purdie@linuxfoundation.org>
To: Stefan Herbrechtsmeier
	<stefan.herbrechtsmeier-oss@weidmueller.com>,
	openembedded-core@lists.openembedded.org
Cc: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
Subject: Re: [OE-core] [RFC PATCH v2 3/3] selftest: recipetool: Add test for handle_license_vars function
Date: Tue, 14 Dec 2021 13:01:33 +0000	[thread overview]
Message-ID: <81f66ff3524b0c4e82b3ed2974dbb7e5664817b5.camel@linuxfoundation.org> (raw)
In-Reply-To: <20211213150546.22196-3-stefan.herbrechtsmeier-oss@weidmueller.com>

On Mon, 2021-12-13 at 16:05 +0100, Stefan Herbrechtsmeier wrote:
> From: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
> 
> Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
> ---
> 
> (no changes since v1)
> 
>  meta/lib/oeqa/selftest/cases/recipetool.py | 62 ++++++++++++++++++++++
>  1 file changed, 62 insertions(+)
> 
> diff --git a/meta/lib/oeqa/selftest/cases/recipetool.py b/meta/lib/oeqa/selftest/cases/recipetool.py
> index 1c73b2c5e0..5330d73cbf 100644
> --- a/meta/lib/oeqa/selftest/cases/recipetool.py
> +++ b/meta/lib/oeqa/selftest/cases/recipetool.py
> @@ -592,6 +592,68 @@ class RecipetoolTests(RecipetoolBase):
>              with open(srcfile, 'w') as fh:
>                  fh.writelines(plugincontent)
>  
> +    def test_recipetool_handle_license_vars(self):
> +        from create import handle_license_vars
> +        from unittest.mock import Mock
> +
> +        commonlicdir = get_bb_var('COMMON_LICENSE_DIR')
> +
> +        d = bb.tinfoil.TinfoilDataStoreConnector
> +        d.getVar = Mock(return_value=commonlicdir)
> +
> +        srctree = tempfile.mkdtemp(prefix='recipetoolqa')
> +        self.track_for_cleanup(srctree)
> +
> +        # Multiple licenses
> +        licenses = ['MIT', 'ISC', 'BSD-3-Clause', 'Apache-2.0']
> +        for licence in licenses:
> +            shutil.copy(os.path.join(commonlicdir, licence), os.path.join(srctree, 'LICENSE.' + licence))
> +        # Duplicate license
> +        shutil.copy(os.path.join(commonlicdir, 'MIT'), os.path.join(srctree, 'LICENSE'))
> +
> +        extravalues = {
> +            # Duplicate and missing licenses
> +            'LICENSE': 'Zlib & BSD-2-Clause & Zlib',
> +            'LIC_FILES_CHKSUM': [
> +                'file://README.md;md5=0123456789abcdef0123456789abcd'
> +            ]
> +        }
> +        lines_before = []
> +        handled = []
> +        licvalues = handle_license_vars(srctree, lines_before, handled, extravalues, d)
> +        expected_lines_before = [
> +            '# WARNING: the following LICENSE and LIC_FILES_CHKSUM values are best guesses - it is',
> +            '# your responsibility to verify that the values are complete and correct.',
> +            '# NOTE: Original package / source metadata indicates license is: BSD-2-Clause & Zlib',
> +            '#',
> +            '# NOTE: multiple licenses have been detected; they have been separated with &',
> +            '# in the LICENSE value for now since it is a reasonable assumption that all',
> +            '# of the licenses apply. If instead there is a choice between the multiple',
> +            '# licenses then you should change the value to separate the licenses with |',
> +            '# instead of &. If there is any doubt, check the accompanying documentation',
> +            '# to determine which situation is applicable.',
> +            'LICENSE = "Apache-2.0 & BSD-2-Clause & BSD-3-Clause & ISC & MIT & Zlib"',
> +            'LIC_FILES_CHKSUM = "file://LICENSE;md5=0835ade698e0bcf8506ecda2f7b4f302 \\\n'
> +            '                    file://LICENSE.MIT;md5=0835ade698e0bcf8506ecda2f7b4f302 \\\n'
> +            '                    file://LICENSE.ISC;md5=f3b90e78ea0cffb20bf5cca7947a896d \\\n'
> +            '                    file://LICENSE.Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10 \\\n'
> +            '                    file://LICENSE.BSD-3-Clause;md5=550794465ba0ec5312d6919e203a55f9 \\\n'
> +            '                    file://README.md;md5=0123456789abcdef0123456789abcd"',
> +            ''
> +        ]
> +        self.assertEqual(lines_before, expected_lines_before)
> +        expected_licvalues = [
> +            ('MIT', 'LICENSE', '0835ade698e0bcf8506ecda2f7b4f302'),
> +            ('MIT', 'LICENSE.MIT', '0835ade698e0bcf8506ecda2f7b4f302'),
> +            ('ISC', 'LICENSE.ISC', 'f3b90e78ea0cffb20bf5cca7947a896d'),
> +            ('Apache-2.0', 'LICENSE.Apache-2.0', '89aea4e17d99a7cacdbeed46a0096b10'),
> +            ('BSD-3-Clause', 'LICENSE.BSD-3-Clause', '550794465ba0ec5312d6919e203a55f9')
> +        ]
> +        self.assertEqual(handled, [('license', expected_licvalues)])
> +        self.assertEqual(extravalues, {})
> +        self.assertEqual(licvalues, expected_licvalues)
> +
> +
>      def test_recipetool_split_pkg_licenses(self):
>          from create import split_pkg_licenses
>          licvalues = [
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#159642): https://lists.openembedded.org/g/openembedded-core/message/159642
> Mute This Topic: https://lists.openembedded.org/mt/87699203/1686473
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [richard.purdie@linuxfoundation.org]
> -=-=-=-=-=-=-=-=-=-=-=-
> 

The test failed in testing:

https://autobuilder.yoctoproject.org/typhoon/#/builders/79/builds/2956/steps/14/logs/stdio

Cheers,

Richard




  reply	other threads:[~2021-12-14 13:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-13 15:05 [RFC PATCH v2 1/3] recipetool: Separate licenses with & operator Stefan Herbrechtsmeier
2021-12-13 15:05 ` [RFC PATCH v2 2/3] selftest: recipetool: Add test for split_pkg_licenses function Stefan Herbrechtsmeier
2021-12-13 15:05 ` [RFC PATCH v2 3/3] selftest: recipetool: Add test for handle_license_vars function Stefan Herbrechtsmeier
2021-12-14 13:01   ` Richard Purdie [this message]
2021-12-14 15:30     ` [OE-core] " Stefan Herbrechtsmeier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=81f66ff3524b0c4e82b3ed2974dbb7e5664817b5.camel@linuxfoundation.org \
    --to=richard.purdie@linuxfoundation.org \
    --cc=openembedded-core@lists.openembedded.org \
    --cc=stefan.herbrechtsmeier-oss@weidmueller.com \
    --cc=stefan.herbrechtsmeier@weidmueller.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.