diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2012-05-04 18:28:21 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2012-05-07 11:03:00 +0100 |
commit | b478649e4964398cfd1197da359ee090ed63ab3e (patch) | |
tree | 3f7ca78abcbbdbc255ea3b6cb1e6f76b659f6499 /bitbake/lib/bb/tests/fetch.py | |
parent | d4d4aab8dc6f1a75c3a3331e8df71297b3dddcc1 (diff) | |
download | poky-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.py | 42 |
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 | ||
20 | import unittest | 20 | import unittest |
21 | import tempfile | ||
22 | import os | ||
21 | import bb | 23 | import bb |
22 | 24 | ||
25 | |||
26 | class 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 | |||
23 | class URLHandle(unittest.TestCase): | 65 | class URLHandle(unittest.TestCase): |
24 | 66 | ||
25 | datatable = { | 67 | datatable = { |