summaryrefslogtreecommitdiffstats
path: root/meta/lib
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2021-06-03 23:21:56 +0100
committerAnuj Mittal <anuj.mittal@intel.com>2021-06-30 14:02:49 +0800
commit8c2d92f855fe0d692228f7ebf7e7b116195ccf0c (patch)
treeca58666bbcc25f9e040b5f296fa3961f79c8b9f1 /meta/lib
parentd96dc6345619977748a1dbb4ed981d031d7ecee6 (diff)
downloadopenembedded-core-8c2d92f855fe0d692228f7ebf7e7b116195ccf0c.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) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> (cherry picked from commit 086e2ae7b2b7496b4f3ae01436b4049d7f2ff8c4) Signed-off-by: Anuj Mittal <anuj.mittal@intel.com>
Diffstat (limited to 'meta/lib')
-rw-r--r--meta/lib/oeqa/selftest/cases/fetch.py27
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
class Dependencies(OESelftestTestCase):
- def write_recipe(self, content):
- f = tempfile.NamedTemporaryFile(mode="wt", suffix=".bb")
- f.write(content)
- f.flush()
+ def write_recipe(self, content, tempdir):
+ f = os.path.join(tempdir, "test.bb")
+ with open(f, "w") as fd:
+ fd.write(content)
return f
def test_dependencies(self):
"""
Verify that the correct dependencies are generated for specific SRC_URI entries.
"""
- with bb.tinfoil.Tinfoil() as tinfoil:
+
+ with bb.tinfoil.Tinfoil() as tinfoil, tempfile.TemporaryDirectory(prefix="selftest-fetch") as tempdir:
tinfoil.prepare(config_only=False, quiet=2)
r = """
LICENSE="CLOSED"
SRC_URI="http://example.com/tarball.zip"
"""
- f = self.write_recipe(textwrap.dedent(r))
- d = tinfoil.parse_recipe_file(f.name)
+ f = self.write_recipe(textwrap.dedent(r), tempdir)
+ d = tinfoil.parse_recipe_file(f)
self.assertIn("wget-native", d.getVarFlag("do_fetch", "depends"))
self.assertIn("unzip-native", d.getVarFlag("do_unpack", "depends"))
@@ -82,8 +83,8 @@ class Dependencies(OESelftestTestCase):
LICENSE="CLOSED"
SRC_URI="https://example.com/tarball;downloadfilename=something.zip"
"""
- f = self.write_recipe(textwrap.dedent(r))
- d = tinfoil.parse_recipe_file(f.name)
+ f = self.write_recipe(textwrap.dedent(r), tempdir)
+ d = tinfoil.parse_recipe_file(f)
self.assertIn("wget-native", d.getVarFlag("do_fetch", "depends"))
self.assertIn("unzip-native", d.getVarFlag("do_unpack", "depends") or "")
@@ -91,8 +92,8 @@ class Dependencies(OESelftestTestCase):
LICENSE="CLOSED"
SRC_URI="ftp://example.com/tarball.lz"
"""
- f = self.write_recipe(textwrap.dedent(r))
- d = tinfoil.parse_recipe_file(f.name)
+ f = self.write_recipe(textwrap.dedent(r), tempdir)
+ d = tinfoil.parse_recipe_file(f)
self.assertIn("wget-native", d.getVarFlag("do_fetch", "depends"))
self.assertIn("lzip-native", d.getVarFlag("do_unpack", "depends"))
@@ -100,6 +101,6 @@ class Dependencies(OESelftestTestCase):
LICENSE="CLOSED"
SRC_URI="git://example.com/repo"
"""
- f = self.write_recipe(textwrap.dedent(r))
- d = tinfoil.parse_recipe_file(f.name)
+ f = self.write_recipe(textwrap.dedent(r), tempdir)
+ d = tinfoil.parse_recipe_file(f)
self.assertIn("git-native", d.getVarFlag("do_fetch", "depends"))