diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-06-03 23:21:56 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-07-06 13:02:30 +0100 |
commit | 175cf0be148455a7fcc9a6885b968e79a4987834 (patch) | |
tree | 574ccbf75a66f90e4cd0ef783a534c56bfb7391d /meta | |
parent | 4f79cdf16eb3be8b485a46ce3bbdd553e6908696 (diff) | |
download | poky-175cf0be148455a7fcc9a6885b968e79a4987834.tar.gz |
selftest/fetch: Avoid occasional selftest failure from poor temp file name choice
The temp file name may contain "_" characters. Switch to a temporary directory
and a fixed filename to avoid this to avoid errors like:
bb.data_smart.ExpansionError: Failure expanding variable PN, expression was
${@bb.parse.vars_from_file(d.getVar('FILE', False),d)[0] or 'defaultpkgname'}
which triggered exception ParseError:
ParseError in /tmp/tmpd_f2__to.bb: Unable to generate default variables from
filename (too many underscores)
(From OE-Core rev: 8c2d92f855fe0d692228f7ebf7e7b116195ccf0c)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit 086e2ae7b2b7496b4f3ae01436b4049d7f2ff8c4)
Signed-off-by: Anuj Mittal <anuj.mittal@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r-- | meta/lib/oeqa/selftest/cases/fetch.py | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/meta/lib/oeqa/selftest/cases/fetch.py b/meta/lib/oeqa/selftest/cases/fetch.py index 67e85d3e4c..cd15f65129 100644 --- a/meta/lib/oeqa/selftest/cases/fetch.py +++ b/meta/lib/oeqa/selftest/cases/fetch.py | |||
@@ -55,25 +55,26 @@ MIRRORS_forcevariable = "git://.*/.* http://downloads.yoctoproject.org/mirror/so | |||
55 | 55 | ||
56 | 56 | ||
57 | class Dependencies(OESelftestTestCase): | 57 | class Dependencies(OESelftestTestCase): |
58 | def write_recipe(self, content): | 58 | def write_recipe(self, content, tempdir): |
59 | f = tempfile.NamedTemporaryFile(mode="wt", suffix=".bb") | 59 | f = os.path.join(tempdir, "test.bb") |
60 | f.write(content) | 60 | with open(f, "w") as fd: |
61 | f.flush() | 61 | fd.write(content) |
62 | return f | 62 | return f |
63 | 63 | ||
64 | def test_dependencies(self): | 64 | def test_dependencies(self): |
65 | """ | 65 | """ |
66 | Verify that the correct dependencies are generated for specific SRC_URI entries. | 66 | Verify that the correct dependencies are generated for specific SRC_URI entries. |
67 | """ | 67 | """ |
68 | with bb.tinfoil.Tinfoil() as tinfoil: | 68 | |
69 | with bb.tinfoil.Tinfoil() as tinfoil, tempfile.TemporaryDirectory(prefix="selftest-fetch") as tempdir: | ||
69 | tinfoil.prepare(config_only=False, quiet=2) | 70 | tinfoil.prepare(config_only=False, quiet=2) |
70 | 71 | ||
71 | r = """ | 72 | r = """ |
72 | LICENSE="CLOSED" | 73 | LICENSE="CLOSED" |
73 | SRC_URI="http://example.com/tarball.zip" | 74 | SRC_URI="http://example.com/tarball.zip" |
74 | """ | 75 | """ |
75 | f = self.write_recipe(textwrap.dedent(r)) | 76 | f = self.write_recipe(textwrap.dedent(r), tempdir) |
76 | d = tinfoil.parse_recipe_file(f.name) | 77 | d = tinfoil.parse_recipe_file(f) |
77 | self.assertIn("wget-native", d.getVarFlag("do_fetch", "depends")) | 78 | self.assertIn("wget-native", d.getVarFlag("do_fetch", "depends")) |
78 | self.assertIn("unzip-native", d.getVarFlag("do_unpack", "depends")) | 79 | self.assertIn("unzip-native", d.getVarFlag("do_unpack", "depends")) |
79 | 80 | ||
@@ -82,8 +83,8 @@ class Dependencies(OESelftestTestCase): | |||
82 | LICENSE="CLOSED" | 83 | LICENSE="CLOSED" |
83 | SRC_URI="https://example.com/tarball;downloadfilename=something.zip" | 84 | SRC_URI="https://example.com/tarball;downloadfilename=something.zip" |
84 | """ | 85 | """ |
85 | f = self.write_recipe(textwrap.dedent(r)) | 86 | f = self.write_recipe(textwrap.dedent(r), tempdir) |
86 | d = tinfoil.parse_recipe_file(f.name) | 87 | d = tinfoil.parse_recipe_file(f) |
87 | self.assertIn("wget-native", d.getVarFlag("do_fetch", "depends")) | 88 | self.assertIn("wget-native", d.getVarFlag("do_fetch", "depends")) |
88 | self.assertIn("unzip-native", d.getVarFlag("do_unpack", "depends") or "") | 89 | self.assertIn("unzip-native", d.getVarFlag("do_unpack", "depends") or "") |
89 | 90 | ||
@@ -91,8 +92,8 @@ class Dependencies(OESelftestTestCase): | |||
91 | LICENSE="CLOSED" | 92 | LICENSE="CLOSED" |
92 | SRC_URI="ftp://example.com/tarball.lz" | 93 | SRC_URI="ftp://example.com/tarball.lz" |
93 | """ | 94 | """ |
94 | f = self.write_recipe(textwrap.dedent(r)) | 95 | f = self.write_recipe(textwrap.dedent(r), tempdir) |
95 | d = tinfoil.parse_recipe_file(f.name) | 96 | d = tinfoil.parse_recipe_file(f) |
96 | self.assertIn("wget-native", d.getVarFlag("do_fetch", "depends")) | 97 | self.assertIn("wget-native", d.getVarFlag("do_fetch", "depends")) |
97 | self.assertIn("lzip-native", d.getVarFlag("do_unpack", "depends")) | 98 | self.assertIn("lzip-native", d.getVarFlag("do_unpack", "depends")) |
98 | 99 | ||
@@ -100,6 +101,6 @@ class Dependencies(OESelftestTestCase): | |||
100 | LICENSE="CLOSED" | 101 | LICENSE="CLOSED" |
101 | SRC_URI="git://example.com/repo" | 102 | SRC_URI="git://example.com/repo" |
102 | """ | 103 | """ |
103 | f = self.write_recipe(textwrap.dedent(r)) | 104 | f = self.write_recipe(textwrap.dedent(r), tempdir) |
104 | d = tinfoil.parse_recipe_file(f.name) | 105 | d = tinfoil.parse_recipe_file(f) |
105 | self.assertIn("git-native", d.getVarFlag("do_fetch", "depends")) | 106 | self.assertIn("git-native", d.getVarFlag("do_fetch", "depends")) |