diff options
| author | Paul Eggleton <paul.eggleton@linux.intel.com> | 2014-04-08 16:49:55 +0100 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2014-04-09 14:31:14 +0100 |
| commit | 70288db2e94c100b0b4c74e1260923fc5ce26d25 (patch) | |
| tree | ac299ba2d242f9228ab7b932aa1ba0b383f8919e /bitbake/lib/bb/tests/fetch.py | |
| parent | 68ec4c1d1a115a6e6c44f3b79952ade7fef00762 (diff) | |
| download | poky-70288db2e94c100b0b4c74e1260923fc5ce26d25.tar.gz | |
bitbake: bitbake-selftest: add tests for local fetching
Add some explicit tests for unpacking local files to the appropriate
location. Some of these tests are actually testing for broken behaviour;
these have been called out in the comments, and associated bugs have
been filed.
(Bitbake rev: ca921c773c52392a5a338b2f493ad38c8132f708)
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
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 | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/bitbake/lib/bb/tests/fetch.py b/bitbake/lib/bb/tests/fetch.py index 4be5a07bec..7df7a0ef51 100644 --- a/bitbake/lib/bb/tests/fetch.py +++ b/bitbake/lib/bb/tests/fetch.py | |||
| @@ -390,6 +390,61 @@ class MirrorUriTest(FetcherTest): | |||
| 390 | uris, uds = bb.fetch2.build_mirroruris(fetcher, mirrors, self.d) | 390 | uris, uds = bb.fetch2.build_mirroruris(fetcher, mirrors, self.d) |
| 391 | self.assertEqual(uris, ['file:///someotherpath/downloads/bitbake-1.0.tar.gz']) | 391 | self.assertEqual(uris, ['file:///someotherpath/downloads/bitbake-1.0.tar.gz']) |
| 392 | 392 | ||
| 393 | |||
| 394 | class FetcherLocalTest(FetcherTest): | ||
| 395 | def setUp(self): | ||
| 396 | def touch(fn): | ||
| 397 | with file(fn, 'a'): | ||
| 398 | os.utime(fn, None) | ||
| 399 | |||
| 400 | super(FetcherLocalTest, self).setUp() | ||
| 401 | self.localsrcdir = os.path.join(self.tempdir, 'localsrc') | ||
| 402 | os.makedirs(self.localsrcdir) | ||
| 403 | touch(os.path.join(self.localsrcdir, 'a')) | ||
| 404 | touch(os.path.join(self.localsrcdir, 'b')) | ||
| 405 | os.makedirs(os.path.join(self.localsrcdir, 'dir')) | ||
| 406 | touch(os.path.join(self.localsrcdir, 'dir', 'c')) | ||
| 407 | touch(os.path.join(self.localsrcdir, 'dir', 'd')) | ||
| 408 | os.makedirs(os.path.join(self.localsrcdir, 'dir', 'subdir')) | ||
| 409 | touch(os.path.join(self.localsrcdir, 'dir', 'subdir', 'e')) | ||
| 410 | self.d.setVar("FILESPATH", self.localsrcdir) | ||
| 411 | |||
| 412 | def fetchUnpack(self, uris): | ||
| 413 | fetcher = bb.fetch.Fetch(uris, self.d) | ||
| 414 | fetcher.download() | ||
| 415 | fetcher.unpack(self.unpackdir) | ||
| 416 | flst = [] | ||
| 417 | for root, dirs, files in os.walk(self.unpackdir): | ||
| 418 | for f in files: | ||
| 419 | flst.append(os.path.relpath(os.path.join(root, f), self.unpackdir)) | ||
| 420 | flst.sort() | ||
| 421 | return flst | ||
| 422 | |||
| 423 | def test_local(self): | ||
| 424 | tree = self.fetchUnpack(['file://a', 'file://dir/c']) | ||
| 425 | self.assertEqual(tree, ['a', 'dir/c']) | ||
| 426 | |||
| 427 | def test_local_wildcard(self): | ||
| 428 | tree = self.fetchUnpack(['file://a', 'file://dir/*']) | ||
| 429 | # FIXME: this is broken - it should return ['a', 'dir/c', 'dir/d', 'dir/subdir/e'] | ||
| 430 | # see https://bugzilla.yoctoproject.org/show_bug.cgi?id=6128 | ||
| 431 | self.assertEqual(tree, ['a', 'b', 'dir/c', 'dir/d', 'dir/subdir/e']) | ||
| 432 | |||
| 433 | def test_local_dir(self): | ||
| 434 | tree = self.fetchUnpack(['file://a', 'file://dir']) | ||
| 435 | self.assertEqual(tree, ['a', 'dir/c', 'dir/d', 'dir/subdir/e']) | ||
| 436 | |||
| 437 | def test_local_subdir(self): | ||
| 438 | tree = self.fetchUnpack(['file://dir/subdir']) | ||
| 439 | # FIXME: this is broken - it should return ['dir/subdir/e'] | ||
| 440 | # see https://bugzilla.yoctoproject.org/show_bug.cgi?id=6129 | ||
| 441 | self.assertEqual(tree, ['subdir/e']) | ||
| 442 | |||
| 443 | def test_local_subdir_file(self): | ||
| 444 | tree = self.fetchUnpack(['file://dir/subdir/e']) | ||
| 445 | self.assertEqual(tree, ['dir/subdir/e']) | ||
| 446 | |||
| 447 | |||
| 393 | class FetcherNetworkTest(FetcherTest): | 448 | class FetcherNetworkTest(FetcherTest): |
| 394 | 449 | ||
| 395 | if os.environ.get("BB_SKIP_NETTESTS") == "yes": | 450 | if os.environ.get("BB_SKIP_NETTESTS") == "yes": |
