diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2012-06-20 13:02:08 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2012-06-21 13:10:34 +0100 |
commit | ad8d1d3a1545f612da6d784632b4b3027feff7f8 (patch) | |
tree | 1c0b29aff069e66e97030f337a446d4b43df0941 /bitbake/lib/bb | |
parent | a627fe5afe8cc159ac24136c5862ffcf43f38bcd (diff) | |
download | poky-ad8d1d3a1545f612da6d784632b4b3027feff7f8.tar.gz |
bitbake: test/fetch: Add in unit tests for uri_replace() and git premirrors
(From Poky rev: 4be81b5cadb7813d37152411c23764501f5869d3)
(Bitbake rev: f91b4c2e3a2b3029d653a18de7ae2b0ecd7e2536)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb')
-rw-r--r-- | bitbake/lib/bb/tests/fetch.py | 55 |
1 files changed, 52 insertions, 3 deletions
diff --git a/bitbake/lib/bb/tests/fetch.py b/bitbake/lib/bb/tests/fetch.py index 42af8839e0..d890ec990e 100644 --- a/bitbake/lib/bb/tests/fetch.py +++ b/bitbake/lib/bb/tests/fetch.py | |||
@@ -26,6 +26,32 @@ import bb | |||
26 | 26 | ||
27 | class FetcherTest(unittest.TestCase): | 27 | class FetcherTest(unittest.TestCase): |
28 | 28 | ||
29 | replaceuris = { | ||
30 | ("git://git.invalid.infradead.org/mtd-utils.git;tag=1234567890123456789012345678901234567890", "git://.*/.*", "http://somewhere.org/somedir/") | ||
31 | : "http://somewhere.org/somedir/git2_git.invalid.infradead.org.mtd-utils.git.tar.gz", | ||
32 | ("git://git.invalid.infradead.org/mtd-utils.git;tag=1234567890123456789012345678901234567890", "git://.*/([^/]+/)*([^/]*)", "git://somewhere.org/somedir/\\2;protocol=http") | ||
33 | : "git://somewhere.org/somedir/mtd-utils.git;tag=1234567890123456789012345678901234567890;protocol=http", | ||
34 | ("git://git.invalid.infradead.org/foo/mtd-utils.git;tag=1234567890123456789012345678901234567890", "git://.*/([^/]+/)*([^/]*)", "git://somewhere.org/somedir/\\2;protocol=http") | ||
35 | : "git://somewhere.org/somedir/mtd-utils.git;tag=1234567890123456789012345678901234567890;protocol=http", | ||
36 | ("git://git.invalid.infradead.org/foo/mtd-utils.git;tag=1234567890123456789012345678901234567890", "git://.*/([^/]+/)*([^/]*)", "git://somewhere.org/\\2;protocol=http") | ||
37 | : "git://somewhere.org/mtd-utils.git;tag=1234567890123456789012345678901234567890;protocol=http", | ||
38 | ("git://someserver.org/bitbake;tag=1234567890123456789012345678901234567890", "git://someserver.org/bitbake", "git://git.openembedded.org/bitbake") | ||
39 | : "git://git.openembedded.org/bitbake;tag=1234567890123456789012345678901234567890", | ||
40 | ("file://sstate-xyz.tgz", "file://.*", "file:///somewhere/1234/sstate-cache") | ||
41 | : "file:///somewhere/1234/sstate-cache/sstate-xyz.tgz", | ||
42 | ("file://sstate-xyz.tgz", "file://.*", "file:///somewhere/1234/sstate-cache/") | ||
43 | : "file:///somewhere/1234/sstate-cache/sstate-xyz.tgz", | ||
44 | ("http://somewhere.org/somedir1/somedir2/somefile_1.2.3.tar.gz", "http://.*/.*", "http://somewhere2.org/somedir3") | ||
45 | : "http://somewhere2.org/somedir3/somefile_1.2.3.tar.gz", | ||
46 | ("http://somewhere.org/somedir1/somefile_1.2.3.tar.gz", "http://somewhere.org/somedir1/somefile_1.2.3.tar.gz", "http://somewhere2.org/somedir3/somefile_1.2.3.tar.gz") | ||
47 | : "http://somewhere2.org/somedir3/somefile_1.2.3.tar.gz", | ||
48 | ("http://www.apache.org/dist/subversion/subversion-1.7.1.tar.bz2", "http://www.apache.org/dist", "http://archive.apache.org/dist") | ||
49 | : "http://archive.apache.org/dist/subversion/subversion-1.7.1.tar.bz2" | ||
50 | #Renaming files doesn't work | ||
51 | #("http://somewhere.org/somedir1/somefile_1.2.3.tar.gz", "http://somewhere.org/somedir1/somefile_1.2.3.tar.gz", "http://somewhere2.org/somedir3/somefile_2.3.4.tar.gz") : "http://somewhere2.org/somedir3/somefile_2.3.4.tar.gz" | ||
52 | #("file://sstate-xyz.tgz", "file://.*/.*", "file:///somewhere/1234/sstate-cache") : "file:///somewhere/1234/sstate-cache/sstate-xyz.tgz", | ||
53 | } | ||
54 | |||
29 | def setUp(self): | 55 | def setUp(self): |
30 | self.d = bb.data.init() | 56 | self.d = bb.data.init() |
31 | self.tempdir = tempfile.mkdtemp() | 57 | self.tempdir = tempfile.mkdtemp() |
@@ -64,7 +90,7 @@ class FetcherTest(unittest.TestCase): | |||
64 | fetcher.download() | 90 | fetcher.download() |
65 | self.assertEqual(os.path.getsize(self.dldir + "/bitbake-1.0.tar.gz"), 57749) | 91 | self.assertEqual(os.path.getsize(self.dldir + "/bitbake-1.0.tar.gz"), 57749) |
66 | 92 | ||
67 | def test_gitfetch(self): | 93 | def gitfetcher(self, url1, url2): |
68 | def checkrevision(self, fetcher): | 94 | def checkrevision(self, fetcher): |
69 | fetcher.unpack(self.unpackdir) | 95 | fetcher.unpack(self.unpackdir) |
70 | revision = subprocess.check_output("git rev-parse HEAD", shell=True, cwd=self.unpackdir + "/git").strip() | 96 | revision = subprocess.check_output("git rev-parse HEAD", shell=True, cwd=self.unpackdir + "/git").strip() |
@@ -72,17 +98,40 @@ class FetcherTest(unittest.TestCase): | |||
72 | 98 | ||
73 | self.d.setVar("BB_GENERATE_MIRROR_TARBALLS", "1") | 99 | self.d.setVar("BB_GENERATE_MIRROR_TARBALLS", "1") |
74 | self.d.setVar("SRCREV", "270a05b0b4ba0959fe0624d2a4885d7b70426da5") | 100 | self.d.setVar("SRCREV", "270a05b0b4ba0959fe0624d2a4885d7b70426da5") |
75 | fetcher = bb.fetch.Fetch(["git://git.openembedded.org/bitbake"], self.d) | 101 | fetcher = bb.fetch.Fetch([url1], self.d) |
76 | fetcher.download() | 102 | fetcher.download() |
77 | checkrevision(self, fetcher) | 103 | checkrevision(self, fetcher) |
78 | # Wipe out the dldir clone and the unpacked source, turn off the network and check mirror tarball works | 104 | # Wipe out the dldir clone and the unpacked source, turn off the network and check mirror tarball works |
79 | bb.utils.prunedir(self.dldir + "/git2/") | 105 | bb.utils.prunedir(self.dldir + "/git2/") |
80 | bb.utils.prunedir(self.unpackdir) | 106 | bb.utils.prunedir(self.unpackdir) |
81 | self.d.setVar("BB_NO_NETWORK", "1") | 107 | self.d.setVar("BB_NO_NETWORK", "1") |
82 | fetcher = bb.fetch.Fetch(["git://git.openembedded.org/bitbake"], self.d) | 108 | fetcher = bb.fetch.Fetch([url2], self.d) |
83 | fetcher.download() | 109 | fetcher.download() |
84 | checkrevision(self, fetcher) | 110 | checkrevision(self, fetcher) |
85 | 111 | ||
112 | def test_gitfetch(self): | ||
113 | url1 = url2 = "git://git.openembedded.org/bitbake" | ||
114 | self.gitfetcher(url1, url2) | ||
115 | |||
116 | def test_gitfetch_premirror(self): | ||
117 | url1 = "git://git.openembedded.org/bitbake" | ||
118 | url2 = "git://someserver.org/bitbake" | ||
119 | self.d.setVar("PREMIRRORS", "git://someserver.org/bitbake git://git.openembedded.org/bitbake \n") | ||
120 | self.gitfetcher(url1, url2) | ||
121 | |||
122 | def test_gitfetch_premirror2(self): | ||
123 | url1 = url2 = "git://someserver.org/bitbake" | ||
124 | self.d.setVar("PREMIRRORS", "git://someserver.org/bitbake git://git.openembedded.org/bitbake \n") | ||
125 | self.gitfetcher(url1, url2) | ||
126 | |||
127 | def test_urireplace(self): | ||
128 | for k, v in self.replaceuris.items(): | ||
129 | ud = bb.fetch.FetchData(k[0], self.d) | ||
130 | ud.setup_localpath(self.d) | ||
131 | newuris = bb.fetch2.uri_replace(ud, k[1], k[2], self.d) | ||
132 | self.assertEqual(newuris, v) | ||
133 | |||
134 | |||
86 | class URLHandle(unittest.TestCase): | 135 | class URLHandle(unittest.TestCase): |
87 | 136 | ||
88 | datatable = { | 137 | datatable = { |