summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/tests/fetch.py
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2012-05-04 18:28:21 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2012-05-07 11:03:00 +0100
commitb478649e4964398cfd1197da359ee090ed63ab3e (patch)
tree3f7ca78abcbbdbc255ea3b6cb1e6f76b659f6499 /bitbake/lib/bb/tests/fetch.py
parentd4d4aab8dc6f1a75c3a3331e8df71297b3dddcc1 (diff)
downloadpoky-b478649e4964398cfd1197da359ee090ed63ab3e.tar.gz
bitbake/tests/fetch: Add simple http fetcher tests
(Bitbake rev: 27b89561781f19fd95308433bec06fa8b7b354e8) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
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 = {