summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/tests/fetch.py
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/bb/tests/fetch.py')
-rw-r--r--bitbake/lib/bb/tests/fetch.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/bitbake/lib/bb/tests/fetch.py b/bitbake/lib/bb/tests/fetch.py
index 8bd3e89520..234b251466 100644
--- a/bitbake/lib/bb/tests/fetch.py
+++ b/bitbake/lib/bb/tests/fetch.py
@@ -18,8 +18,50 @@
18# 18#
19 19
20import unittest 20import unittest
21import tempfile
22import os
21import bb 23import bb
22 24
25
26class FetcherTest(unittest.TestCase):
27
28 def setUp(self):
29 self.d = bb.data.init()
30 self.tempdir = tempfile.mkdtemp()
31 self.dldir = os.path.join(self.tempdir, "download")
32 os.mkdir(self.dldir)
33 self.d.setVar("DL_DIR", self.dldir)
34 self.unpackdir = os.path.join(self.tempdir, "unpacked")
35 os.mkdir(self.unpackdir)
36
37 def tearDown(self):
38 bb.utils.prunedir(self.tempdir)
39
40 def test_fetch(self):
41 fetcher = bb.fetch.Fetch(["http://downloads.yoctoproject.org/releases/bitbake/bitbake-1.0.tar.gz", "http://downloads.yoctoproject.org/releases/bitbake/bitbake-1.1.tar.gz"], self.d)
42 fetcher.download()
43 self.assertEqual(os.path.getsize(self.dldir + "/bitbake-1.0.tar.gz"), 57749)
44 self.assertEqual(os.path.getsize(self.dldir + "/bitbake-1.1.tar.gz"), 57892)
45 self.d.setVar("BB_NO_NETWORK", "1")
46 fetcher = bb.fetch.Fetch(["http://downloads.yoctoproject.org/releases/bitbake/bitbake-1.0.tar.gz", "http://downloads.yoctoproject.org/releases/bitbake/bitbake-1.1.tar.gz"], self.d)
47 fetcher.download()
48 fetcher.unpack(self.unpackdir)
49 self.assertEqual(len(os.listdir(self.unpackdir + "/bitbake-1.0/")), 9)
50 self.assertEqual(len(os.listdir(self.unpackdir + "/bitbake-1.1/")), 9)
51
52 def test_fetch_mirror(self):
53 self.d.setVar("MIRRORS", "http://.*/.* http://downloads.yoctoproject.org/releases/bitbake")
54 fetcher = bb.fetch.Fetch(["http://invalid.yoctoproject.org/releases/bitbake/bitbake-1.0.tar.gz"], self.d)
55 fetcher.download()
56 self.assertEqual(os.path.getsize(self.dldir + "/bitbake-1.0.tar.gz"), 57749)
57
58 def test_fetch_premirror(self):
59 self.d.setVar("PREMIRRORS", "http://.*/.* http://downloads.yoctoproject.org/releases/bitbake")
60 fetcher = bb.fetch.Fetch(["http://invalid.yoctoproject.org/releases/bitbake/bitbake-1.0.tar.gz"], self.d)
61 fetcher.download()
62 self.assertEqual(os.path.getsize(self.dldir + "/bitbake-1.0.tar.gz"), 57749)
63
64
23class URLHandle(unittest.TestCase): 65class URLHandle(unittest.TestCase):
24 66
25 datatable = { 67 datatable = {