bitbake-devel.lists.openembedded.org archive mirror
 help / color / mirror / Atom feed
From: "Vishal Patel" <vishal.patel@xilinx.com>
To: <bitbake-devel@lists.openembedded.org>
Cc: <mark.hatle@xilinx.com>, Vishal Patel <vishal.patel@xilinx.com>
Subject: [PATCH 1/1] tests/fetch.py: Add test case to verify PREMIRROR with mix of remote and local
Date: Wed, 1 Sep 2021 12:44:56 -0700	[thread overview]
Message-ID: <20210901194456.2642587-2-vishal.patel@xilinx.com> (raw)
In-Reply-To: <20210901194456.2642587-1-vishal.patel@xilinx.com>

If the PREMIRROR lists both remote and local mirrors, and has BB_NO_NETWORK
enabled, it will fail on the first network attempt without falling back to
the local (file://) PREMIRROR.

Signed-off-by: Vishal Patel <vishal.patel@xilinx.com>
---
 lib/bb/tests/fetch.py | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/lib/bb/tests/fetch.py b/lib/bb/tests/fetch.py
index 9291ce4a..559c678b 100644
--- a/lib/bb/tests/fetch.py
+++ b/lib/bb/tests/fetch.py
@@ -823,6 +823,26 @@ class FetcherNoNetworkTest(FetcherTest):
         self.assertFalse(os.path.exists(os.path.join(self.dldir, "test-file.tar.gz")))
         self.assertFalse(os.path.exists(os.path.join(self.dldir, "test-file.tar.gz.done")))

+    def test_fetch_premirror(self):
+        mirrordir = os.path.join(self.tempdir, 'mirror')
+        os.mkdir(mirrordir)
+        # create the file in a mirror directory with correct hash
+        string = "this is a test file\n".encode("utf-8")
+        with open(os.path.join(mirrordir, "test-file.tar.gz"), "wb") as f:
+            f.write(string)
+        self.d.setVarFlag("SRC_URI", "sha256sum", "b6668cf8c46c7075e18215d922e7812ca082fa6cc34668d00a6c20aee4551fb6")
+        self.d.setVar("PREMIRRORS", "http://.*/.* file://%s/test-file.tar.gz" % mirrordir)
+        fetcher = bb.fetch.Fetch(["http://invalid.yoctoproject.org/release/test-file.tar.gz"], self.d)
+        fetcher.download()
+        self.assertEqual(os.path.getsize(self.dldir + "/test-file.tar.gz"), 20)
+        bb.utils.remove(self.dldir, recurse=True)
+
+        self.d.setVar("BB_NO_NETWORK", "1")
+        self.d.setVar("PREMIRRORS", "http://.*/.* http://downloads.yoctoproject.org/releases/bitbake \nhttp://.*/.* file://%s/test-file.tar.gz" % mirrordir)
+        fetcher = bb.fetch.Fetch(["http://invalid.yoctoproject.org/release/test-file.tar.gz"], self.d)
+        fetcher.download()
+        self.assertEqual(os.path.getsize(self.dldir + "/test-file.tar.gz"), 20)
+
 class FetcherNetworkTest(FetcherTest):
     @skipIfNoNetwork()
     def test_fetch(self):
--
2.25.1

This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.

  reply	other threads:[~2021-09-01 19:45 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-01 19:44 [PATCH 0/1] RFC Bug in PREMIRROR Vishal Patel
2021-09-01 19:44 ` Vishal Patel [this message]
2021-09-01 19:55 ` [bitbake-devel] " Mark Hatle
2021-09-01 21:40 ` Richard Purdie
2021-09-01 21:46   ` Mark Hatle
2021-09-01 21:48     ` Richard Purdie

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=20210901194456.2642587-2-vishal.patel@xilinx.com \
    --to=vishal.patel@xilinx.com \
    --cc=bitbake-devel@lists.openembedded.org \
    --cc=mark.hatle@xilinx.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).