diff options
Diffstat (limited to 'meta/lib/oeqa/selftest/cases/fetch.py')
-rw-r--r-- | meta/lib/oeqa/selftest/cases/fetch.py | 69 |
1 files changed, 64 insertions, 5 deletions
diff --git a/meta/lib/oeqa/selftest/cases/fetch.py b/meta/lib/oeqa/selftest/cases/fetch.py index 76cbadf2ff..44099176fc 100644 --- a/meta/lib/oeqa/selftest/cases/fetch.py +++ b/meta/lib/oeqa/selftest/cases/fetch.py | |||
@@ -1,7 +1,12 @@ | |||
1 | # | 1 | # |
2 | # Copyright OpenEmbedded Contributors | ||
3 | # | ||
2 | # SPDX-License-Identifier: MIT | 4 | # SPDX-License-Identifier: MIT |
3 | # | 5 | # |
4 | 6 | ||
7 | import tempfile | ||
8 | import textwrap | ||
9 | import bb.tinfoil | ||
5 | import oe.path | 10 | import oe.path |
6 | from oeqa.selftest.case import OESelftestTestCase | 11 | from oeqa.selftest.case import OESelftestTestCase |
7 | from oeqa.utils.commands import bitbake | 12 | from oeqa.utils.commands import bitbake |
@@ -21,8 +26,8 @@ class Fetch(OESelftestTestCase): | |||
21 | # No mirrors, should use git to fetch successfully | 26 | # No mirrors, should use git to fetch successfully |
22 | features = """ | 27 | features = """ |
23 | DL_DIR = "%s" | 28 | DL_DIR = "%s" |
24 | MIRRORS_forcevariable = "" | 29 | MIRRORS:forcevariable = "" |
25 | PREMIRRORS_forcevariable = "" | 30 | PREMIRRORS:forcevariable = "" |
26 | """ % dldir | 31 | """ % dldir |
27 | self.write_config(features) | 32 | self.write_config(features) |
28 | oe.path.remove(dldir, recurse=True) | 33 | oe.path.remove(dldir, recurse=True) |
@@ -31,9 +36,10 @@ PREMIRRORS_forcevariable = "" | |||
31 | # No mirrors and broken git, should fail | 36 | # No mirrors and broken git, should fail |
32 | features = """ | 37 | features = """ |
33 | DL_DIR = "%s" | 38 | DL_DIR = "%s" |
39 | SRC_URI:pn-dbus-wait = "git://git.yoctoproject.org/dbus-wait;branch=master;protocol=git" | ||
34 | GIT_PROXY_COMMAND = "false" | 40 | GIT_PROXY_COMMAND = "false" |
35 | MIRRORS_forcevariable = "" | 41 | MIRRORS:forcevariable = "" |
36 | PREMIRRORS_forcevariable = "" | 42 | PREMIRRORS:forcevariable = "" |
37 | """ % dldir | 43 | """ % dldir |
38 | self.write_config(features) | 44 | self.write_config(features) |
39 | oe.path.remove(dldir, recurse=True) | 45 | oe.path.remove(dldir, recurse=True) |
@@ -43,9 +49,62 @@ PREMIRRORS_forcevariable = "" | |||
43 | # Broken git but a specific mirror | 49 | # Broken git but a specific mirror |
44 | features = """ | 50 | features = """ |
45 | DL_DIR = "%s" | 51 | DL_DIR = "%s" |
52 | SRC_URI:pn-dbus-wait = "git://git.yoctoproject.org/dbus-wait;branch=master;protocol=git" | ||
46 | GIT_PROXY_COMMAND = "false" | 53 | GIT_PROXY_COMMAND = "false" |
47 | MIRRORS_forcevariable = "git://.*/.* http://downloads.yoctoproject.org/mirror/sources/" | 54 | MIRRORS:forcevariable = "git://.*/.* http://downloads.yoctoproject.org/mirror/sources/" |
48 | """ % dldir | 55 | """ % dldir |
49 | self.write_config(features) | 56 | self.write_config(features) |
50 | oe.path.remove(dldir, recurse=True) | 57 | oe.path.remove(dldir, recurse=True) |
51 | bitbake("dbus-wait -c fetch -f") | 58 | bitbake("dbus-wait -c fetch -f") |
59 | |||
60 | |||
61 | class Dependencies(OESelftestTestCase): | ||
62 | def write_recipe(self, content, tempdir): | ||
63 | f = os.path.join(tempdir, "test.bb") | ||
64 | with open(f, "w") as fd: | ||
65 | fd.write(content) | ||
66 | return f | ||
67 | |||
68 | def test_dependencies(self): | ||
69 | """ | ||
70 | Verify that the correct dependencies are generated for specific SRC_URI entries. | ||
71 | """ | ||
72 | |||
73 | with bb.tinfoil.Tinfoil() as tinfoil, tempfile.TemporaryDirectory(prefix="selftest-fetch") as tempdir: | ||
74 | tinfoil.prepare(config_only=False, quiet=2) | ||
75 | |||
76 | r = """ | ||
77 | LICENSE="CLOSED" | ||
78 | SRC_URI="http://example.com/tarball.zip" | ||
79 | """ | ||
80 | f = self.write_recipe(textwrap.dedent(r), tempdir) | ||
81 | d = tinfoil.parse_recipe_file(f) | ||
82 | self.assertIn("wget-native", d.getVarFlag("do_fetch", "depends")) | ||
83 | self.assertIn("unzip-native", d.getVarFlag("do_unpack", "depends")) | ||
84 | |||
85 | # Verify that the downloadfilename overrides the URI | ||
86 | r = """ | ||
87 | LICENSE="CLOSED" | ||
88 | SRC_URI="https://example.com/tarball;downloadfilename=something.zip" | ||
89 | """ | ||
90 | f = self.write_recipe(textwrap.dedent(r), tempdir) | ||
91 | d = tinfoil.parse_recipe_file(f) | ||
92 | self.assertIn("wget-native", d.getVarFlag("do_fetch", "depends")) | ||
93 | self.assertIn("unzip-native", d.getVarFlag("do_unpack", "depends") or "") | ||
94 | |||
95 | r = """ | ||
96 | LICENSE="CLOSED" | ||
97 | SRC_URI="ftp://example.com/tarball.lz" | ||
98 | """ | ||
99 | f = self.write_recipe(textwrap.dedent(r), tempdir) | ||
100 | d = tinfoil.parse_recipe_file(f) | ||
101 | self.assertIn("wget-native", d.getVarFlag("do_fetch", "depends")) | ||
102 | self.assertIn("lzip-native", d.getVarFlag("do_unpack", "depends")) | ||
103 | |||
104 | r = """ | ||
105 | LICENSE="CLOSED" | ||
106 | SRC_URI="git://example.com/repo;branch=master;rev=ffffffffffffffffffffffffffffffffffffffff" | ||
107 | """ | ||
108 | f = self.write_recipe(textwrap.dedent(r), tempdir) | ||
109 | d = tinfoil.parse_recipe_file(f) | ||
110 | self.assertIn("git-native", d.getVarFlag("do_fetch", "depends")) | ||