summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/tests
diff options
context:
space:
mode:
authorRoss Burton <ross.burton@intel.com>2017-11-03 11:44:35 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-11-05 13:48:47 +0000
commit8f231aab8735d8c283f3c0c050cdf1701a54aa3a (patch)
treec33cd9a7a65001d38d1ef808a7ad54bb99b500a6 /bitbake/lib/bb/tests
parentf49573d8a533bae2938f5b3fc1be4f168a7aad0a (diff)
downloadpoky-8f231aab8735d8c283f3c0c050cdf1701a54aa3a.tar.gz
bitbake: tests/fetch: skip network tests the idiomatic way
Instead of not even having the test functions if network tests are disabled, use a custom decorator to mark the network tests and skip them. (Bitbake rev: cc420f430b1dafd9ca944bea259a564aaab34595) Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/tests')
-rw-r--r--bitbake/lib/bb/tests/fetch.py434
1 files changed, 222 insertions, 212 deletions
diff --git a/bitbake/lib/bb/tests/fetch.py b/bitbake/lib/bb/tests/fetch.py
index 209b13f695..154bf1779b 100644
--- a/bitbake/lib/bb/tests/fetch.py
+++ b/bitbake/lib/bb/tests/fetch.py
@@ -28,6 +28,11 @@ from bb.fetch2 import URI
28from bb.fetch2 import FetchMethod 28from bb.fetch2 import FetchMethod
29import bb 29import bb
30 30
31def skipIfNoNetwork():
32 if os.environ.get("BB_SKIP_NETTESTS") == "yes":
33 return unittest.skip("Network tests being skipped")
34 return lambda f: f
35
31class URITest(unittest.TestCase): 36class URITest(unittest.TestCase):
32 test_uris = { 37 test_uris = {
33 "http://www.google.com/index.html" : { 38 "http://www.google.com/index.html" : {
@@ -518,141 +523,153 @@ class FetcherLocalTest(FetcherTest):
518 self.fetchUnpack(['file://a;subdir=/bin/sh']) 523 self.fetchUnpack(['file://a;subdir=/bin/sh'])
519 524
520class FetcherNetworkTest(FetcherTest): 525class FetcherNetworkTest(FetcherTest):
526 @skipIfNoNetwork()
527 def test_fetch(self):
528 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)
529 fetcher.download()
530 self.assertEqual(os.path.getsize(self.dldir + "/bitbake-1.0.tar.gz"), 57749)
531 self.assertEqual(os.path.getsize(self.dldir + "/bitbake-1.1.tar.gz"), 57892)
532 self.d.setVar("BB_NO_NETWORK", "1")
533 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)
534 fetcher.download()
535 fetcher.unpack(self.unpackdir)
536 self.assertEqual(len(os.listdir(self.unpackdir + "/bitbake-1.0/")), 9)
537 self.assertEqual(len(os.listdir(self.unpackdir + "/bitbake-1.1/")), 9)
521 538
522 if os.environ.get("BB_SKIP_NETTESTS") == "yes": 539 @skipIfNoNetwork()
523 print("Unset BB_SKIP_NETTESTS to run network tests") 540 def test_fetch_mirror(self):
524 else: 541 self.d.setVar("MIRRORS", "http://.*/.* http://downloads.yoctoproject.org/releases/bitbake")
525 def test_fetch(self): 542 fetcher = bb.fetch.Fetch(["http://invalid.yoctoproject.org/releases/bitbake/bitbake-1.0.tar.gz"], self.d)
526 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) 543 fetcher.download()
527 fetcher.download() 544 self.assertEqual(os.path.getsize(self.dldir + "/bitbake-1.0.tar.gz"), 57749)
528 self.assertEqual(os.path.getsize(self.dldir + "/bitbake-1.0.tar.gz"), 57749) 545
529 self.assertEqual(os.path.getsize(self.dldir + "/bitbake-1.1.tar.gz"), 57892) 546 @skipIfNoNetwork()
530 self.d.setVar("BB_NO_NETWORK", "1") 547 def test_fetch_mirror_of_mirror(self):
531 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) 548 self.d.setVar("MIRRORS", "http://.*/.* http://invalid2.yoctoproject.org/ \n http://invalid2.yoctoproject.org/.* http://downloads.yoctoproject.org/releases/bitbake")
532 fetcher.download() 549 fetcher = bb.fetch.Fetch(["http://invalid.yoctoproject.org/releases/bitbake/bitbake-1.0.tar.gz"], self.d)
533 fetcher.unpack(self.unpackdir) 550 fetcher.download()
534 self.assertEqual(len(os.listdir(self.unpackdir + "/bitbake-1.0/")), 9) 551 self.assertEqual(os.path.getsize(self.dldir + "/bitbake-1.0.tar.gz"), 57749)
535 self.assertEqual(len(os.listdir(self.unpackdir + "/bitbake-1.1/")), 9) 552
536 553 @skipIfNoNetwork()
537 def test_fetch_mirror(self): 554 def test_fetch_file_mirror_of_mirror(self):
538 self.d.setVar("MIRRORS", "http://.*/.* http://downloads.yoctoproject.org/releases/bitbake") 555 self.d.setVar("MIRRORS", "http://.*/.* file:///some1where/ \n file:///some1where/.* file://some2where/ \n file://some2where/.* http://downloads.yoctoproject.org/releases/bitbake")
539 fetcher = bb.fetch.Fetch(["http://invalid.yoctoproject.org/releases/bitbake/bitbake-1.0.tar.gz"], self.d) 556 fetcher = bb.fetch.Fetch(["http://invalid.yoctoproject.org/releases/bitbake/bitbake-1.0.tar.gz"], self.d)
540 fetcher.download() 557 os.mkdir(self.dldir + "/some2where")
541 self.assertEqual(os.path.getsize(self.dldir + "/bitbake-1.0.tar.gz"), 57749) 558 fetcher.download()
542 559 self.assertEqual(os.path.getsize(self.dldir + "/bitbake-1.0.tar.gz"), 57749)
543 def test_fetch_mirror_of_mirror(self): 560
544 self.d.setVar("MIRRORS", "http://.*/.* http://invalid2.yoctoproject.org/ \n http://invalid2.yoctoproject.org/.* http://downloads.yoctoproject.org/releases/bitbake") 561 @skipIfNoNetwork()
545 fetcher = bb.fetch.Fetch(["http://invalid.yoctoproject.org/releases/bitbake/bitbake-1.0.tar.gz"], self.d) 562 def test_fetch_premirror(self):
546 fetcher.download() 563 self.d.setVar("PREMIRRORS", "http://.*/.* http://downloads.yoctoproject.org/releases/bitbake")
547 self.assertEqual(os.path.getsize(self.dldir + "/bitbake-1.0.tar.gz"), 57749) 564 fetcher = bb.fetch.Fetch(["http://invalid.yoctoproject.org/releases/bitbake/bitbake-1.0.tar.gz"], self.d)
548 565 fetcher.download()
549 def test_fetch_file_mirror_of_mirror(self): 566 self.assertEqual(os.path.getsize(self.dldir + "/bitbake-1.0.tar.gz"), 57749)
550 self.d.setVar("MIRRORS", "http://.*/.* file:///some1where/ \n file:///some1where/.* file://some2where/ \n file://some2where/.* http://downloads.yoctoproject.org/releases/bitbake") 567
551 fetcher = bb.fetch.Fetch(["http://invalid.yoctoproject.org/releases/bitbake/bitbake-1.0.tar.gz"], self.d) 568 @skipIfNoNetwork()
552 os.mkdir(self.dldir + "/some2where") 569 def gitfetcher(self, url1, url2):
553 fetcher.download() 570 def checkrevision(self, fetcher):
554 self.assertEqual(os.path.getsize(self.dldir + "/bitbake-1.0.tar.gz"), 57749)
555
556 def test_fetch_premirror(self):
557 self.d.setVar("PREMIRRORS", "http://.*/.* http://downloads.yoctoproject.org/releases/bitbake")
558 fetcher = bb.fetch.Fetch(["http://invalid.yoctoproject.org/releases/bitbake/bitbake-1.0.tar.gz"], self.d)
559 fetcher.download()
560 self.assertEqual(os.path.getsize(self.dldir + "/bitbake-1.0.tar.gz"), 57749)
561
562 def gitfetcher(self, url1, url2):
563 def checkrevision(self, fetcher):
564 fetcher.unpack(self.unpackdir)
565 revision = bb.process.run("git rev-parse HEAD", shell=True, cwd=self.unpackdir + "/git")[0].strip()
566 self.assertEqual(revision, "270a05b0b4ba0959fe0624d2a4885d7b70426da5")
567
568 self.d.setVar("BB_GENERATE_MIRROR_TARBALLS", "1")
569 self.d.setVar("SRCREV", "270a05b0b4ba0959fe0624d2a4885d7b70426da5")
570 fetcher = bb.fetch.Fetch([url1], self.d)
571 fetcher.download()
572 checkrevision(self, fetcher)
573 # Wipe out the dldir clone and the unpacked source, turn off the network and check mirror tarball works
574 bb.utils.prunedir(self.dldir + "/git2/")
575 bb.utils.prunedir(self.unpackdir)
576 self.d.setVar("BB_NO_NETWORK", "1")
577 fetcher = bb.fetch.Fetch([url2], self.d)
578 fetcher.download()
579 checkrevision(self, fetcher)
580
581 def test_gitfetch(self):
582 url1 = url2 = "git://git.openembedded.org/bitbake"
583 self.gitfetcher(url1, url2)
584
585 def test_gitfetch_goodsrcrev(self):
586 # SRCREV is set but matches rev= parameter
587 url1 = url2 = "git://git.openembedded.org/bitbake;rev=270a05b0b4ba0959fe0624d2a4885d7b70426da5"
588 self.gitfetcher(url1, url2)
589
590 def test_gitfetch_badsrcrev(self):
591 # SRCREV is set but does not match rev= parameter
592 url1 = url2 = "git://git.openembedded.org/bitbake;rev=dead05b0b4ba0959fe0624d2a4885d7b70426da5"
593 self.assertRaises(bb.fetch.FetchError, self.gitfetcher, url1, url2)
594
595 def test_gitfetch_tagandrev(self):
596 # SRCREV is set but does not match rev= parameter
597 url1 = url2 = "git://git.openembedded.org/bitbake;rev=270a05b0b4ba0959fe0624d2a4885d7b70426da5;tag=270a05b0b4ba0959fe0624d2a4885d7b70426da5"
598 self.assertRaises(bb.fetch.FetchError, self.gitfetcher, url1, url2)
599
600 def test_gitfetch_localusehead(self):
601 # Create dummy local Git repo
602 src_dir = tempfile.mkdtemp(dir=self.tempdir,
603 prefix='gitfetch_localusehead_')
604 src_dir = os.path.abspath(src_dir)
605 bb.process.run("git init", cwd=src_dir)
606 bb.process.run("git commit --allow-empty -m'Dummy commit'",
607 cwd=src_dir)
608 # Use other branch than master
609 bb.process.run("git checkout -b my-devel", cwd=src_dir)
610 bb.process.run("git commit --allow-empty -m'Dummy commit 2'",
611 cwd=src_dir)
612 stdout = bb.process.run("git rev-parse HEAD", cwd=src_dir)
613 orig_rev = stdout[0].strip()
614
615 # Fetch and check revision
616 self.d.setVar("SRCREV", "AUTOINC")
617 url = "git://" + src_dir + ";protocol=file;usehead=1"
618 fetcher = bb.fetch.Fetch([url], self.d)
619 fetcher.download()
620 fetcher.unpack(self.unpackdir)
621 stdout = bb.process.run("git rev-parse HEAD",
622 cwd=os.path.join(self.unpackdir, 'git'))
623 unpack_rev = stdout[0].strip()
624 self.assertEqual(orig_rev, unpack_rev)
625
626 def test_gitfetch_remoteusehead(self):
627 url = "git://git.openembedded.org/bitbake;usehead=1"
628 self.assertRaises(bb.fetch.ParameterError, self.gitfetcher, url, url)
629
630 def test_gitfetch_premirror(self):
631 url1 = "git://git.openembedded.org/bitbake"
632 url2 = "git://someserver.org/bitbake"
633 self.d.setVar("PREMIRRORS", "git://someserver.org/bitbake git://git.openembedded.org/bitbake \n")
634 self.gitfetcher(url1, url2)
635
636 def test_gitfetch_premirror2(self):
637 url1 = url2 = "git://someserver.org/bitbake"
638 self.d.setVar("PREMIRRORS", "git://someserver.org/bitbake git://git.openembedded.org/bitbake \n")
639 self.gitfetcher(url1, url2)
640
641 def test_gitfetch_premirror3(self):
642 realurl = "git://git.openembedded.org/bitbake"
643 dummyurl = "git://someserver.org/bitbake"
644 self.sourcedir = self.unpackdir.replace("unpacked", "sourcemirror.git")
645 os.chdir(self.tempdir)
646 bb.process.run("git clone %s %s 2> /dev/null" % (realurl, self.sourcedir), shell=True)
647 self.d.setVar("PREMIRRORS", "%s git://%s;protocol=file \n" % (dummyurl, self.sourcedir))
648 self.gitfetcher(dummyurl, dummyurl)
649
650 def test_git_submodule(self):
651 fetcher = bb.fetch.Fetch(["gitsm://git.yoctoproject.org/git-submodule-test;rev=f12e57f2edf0aa534cf1616fa983d165a92b0842"], self.d)
652 fetcher.download()
653 # Previous cwd has been deleted
654 os.chdir(os.path.dirname(self.unpackdir))
655 fetcher.unpack(self.unpackdir) 571 fetcher.unpack(self.unpackdir)
572 revision = bb.process.run("git rev-parse HEAD", shell=True, cwd=self.unpackdir + "/git")[0].strip()
573 self.assertEqual(revision, "270a05b0b4ba0959fe0624d2a4885d7b70426da5")
574
575 self.d.setVar("BB_GENERATE_MIRROR_TARBALLS", "1")
576 self.d.setVar("SRCREV", "270a05b0b4ba0959fe0624d2a4885d7b70426da5")
577 fetcher = bb.fetch.Fetch([url1], self.d)
578 fetcher.download()
579 checkrevision(self, fetcher)
580 # Wipe out the dldir clone and the unpacked source, turn off the network and check mirror tarball works
581 bb.utils.prunedir(self.dldir + "/git2/")
582 bb.utils.prunedir(self.unpackdir)
583 self.d.setVar("BB_NO_NETWORK", "1")
584 fetcher = bb.fetch.Fetch([url2], self.d)
585 fetcher.download()
586 checkrevision(self, fetcher)
587
588 @skipIfNoNetwork()
589 def test_gitfetch(self):
590 url1 = url2 = "git://git.openembedded.org/bitbake"
591 self.gitfetcher(url1, url2)
592
593 @skipIfNoNetwork()
594 def test_gitfetch_goodsrcrev(self):
595 # SRCREV is set but matches rev= parameter
596 url1 = url2 = "git://git.openembedded.org/bitbake;rev=270a05b0b4ba0959fe0624d2a4885d7b70426da5"
597 self.gitfetcher(url1, url2)
598
599 @skipIfNoNetwork()
600 def test_gitfetch_badsrcrev(self):
601 # SRCREV is set but does not match rev= parameter
602 url1 = url2 = "git://git.openembedded.org/bitbake;rev=dead05b0b4ba0959fe0624d2a4885d7b70426da5"
603 self.assertRaises(bb.fetch.FetchError, self.gitfetcher, url1, url2)
604
605 @skipIfNoNetwork()
606 def test_gitfetch_tagandrev(self):
607 # SRCREV is set but does not match rev= parameter
608 url1 = url2 = "git://git.openembedded.org/bitbake;rev=270a05b0b4ba0959fe0624d2a4885d7b70426da5;tag=270a05b0b4ba0959fe0624d2a4885d7b70426da5"
609 self.assertRaises(bb.fetch.FetchError, self.gitfetcher, url1, url2)
610
611 @skipIfNoNetwork()
612 def test_gitfetch_localusehead(self):
613 # Create dummy local Git repo
614 src_dir = tempfile.mkdtemp(dir=self.tempdir,
615 prefix='gitfetch_localusehead_')
616 src_dir = os.path.abspath(src_dir)
617 bb.process.run("git init", cwd=src_dir)
618 bb.process.run("git commit --allow-empty -m'Dummy commit'",
619 cwd=src_dir)
620 # Use other branch than master
621 bb.process.run("git checkout -b my-devel", cwd=src_dir)
622 bb.process.run("git commit --allow-empty -m'Dummy commit 2'",
623 cwd=src_dir)
624 stdout = bb.process.run("git rev-parse HEAD", cwd=src_dir)
625 orig_rev = stdout[0].strip()
626
627 # Fetch and check revision
628 self.d.setVar("SRCREV", "AUTOINC")
629 url = "git://" + src_dir + ";protocol=file;usehead=1"
630 fetcher = bb.fetch.Fetch([url], self.d)
631 fetcher.download()
632 fetcher.unpack(self.unpackdir)
633 stdout = bb.process.run("git rev-parse HEAD",
634 cwd=os.path.join(self.unpackdir, 'git'))
635 unpack_rev = stdout[0].strip()
636 self.assertEqual(orig_rev, unpack_rev)
637
638 @skipIfNoNetwork()
639 def test_gitfetch_remoteusehead(self):
640 url = "git://git.openembedded.org/bitbake;usehead=1"
641 self.assertRaises(bb.fetch.ParameterError, self.gitfetcher, url, url)
642
643 @skipIfNoNetwork()
644 def test_gitfetch_premirror(self):
645 url1 = "git://git.openembedded.org/bitbake"
646 url2 = "git://someserver.org/bitbake"
647 self.d.setVar("PREMIRRORS", "git://someserver.org/bitbake git://git.openembedded.org/bitbake \n")
648 self.gitfetcher(url1, url2)
649
650 @skipIfNoNetwork()
651 def test_gitfetch_premirror2(self):
652 url1 = url2 = "git://someserver.org/bitbake"
653 self.d.setVar("PREMIRRORS", "git://someserver.org/bitbake git://git.openembedded.org/bitbake \n")
654 self.gitfetcher(url1, url2)
655
656 @skipIfNoNetwork()
657 def test_gitfetch_premirror3(self):
658 realurl = "git://git.openembedded.org/bitbake"
659 dummyurl = "git://someserver.org/bitbake"
660 self.sourcedir = self.unpackdir.replace("unpacked", "sourcemirror.git")
661 os.chdir(self.tempdir)
662 bb.process.run("git clone %s %s 2> /dev/null" % (realurl, self.sourcedir), shell=True)
663 self.d.setVar("PREMIRRORS", "%s git://%s;protocol=file \n" % (dummyurl, self.sourcedir))
664 self.gitfetcher(dummyurl, dummyurl)
665
666 @skipIfNoNetwork()
667 def test_git_submodule(self):
668 fetcher = bb.fetch.Fetch(["gitsm://git.yoctoproject.org/git-submodule-test;rev=f12e57f2edf0aa534cf1616fa983d165a92b0842"], self.d)
669 fetcher.download()
670 # Previous cwd has been deleted
671 os.chdir(os.path.dirname(self.unpackdir))
672 fetcher.unpack(self.unpackdir)
656 673
657 674
658class TrustedNetworksTest(FetcherTest): 675class TrustedNetworksTest(FetcherTest):
@@ -782,32 +799,32 @@ class FetchLatestVersionTest(FetcherTest):
782 ("db", "http://download.oracle.com/berkeley-db/db-5.3.21.tar.gz", "http://www.oracle.com/technetwork/products/berkeleydb/downloads/index-082944.html", "http://download.oracle.com/otn/berkeley-db/(?P<name>db-)(?P<pver>((\d+[\.\-_]*)+))\.tar\.gz") 799 ("db", "http://download.oracle.com/berkeley-db/db-5.3.21.tar.gz", "http://www.oracle.com/technetwork/products/berkeleydb/downloads/index-082944.html", "http://download.oracle.com/otn/berkeley-db/(?P<name>db-)(?P<pver>((\d+[\.\-_]*)+))\.tar\.gz")
783 : "6.1.19", 800 : "6.1.19",
784 } 801 }
785 if os.environ.get("BB_SKIP_NETTESTS") == "yes": 802
786 print("Unset BB_SKIP_NETTESTS to run network tests") 803 @skipIfNoNetwork()
787 else: 804 def test_git_latest_versionstring(self):
788 def test_git_latest_versionstring(self): 805 for k, v in self.test_git_uris.items():
789 for k, v in self.test_git_uris.items(): 806 self.d.setVar("PN", k[0])
790 self.d.setVar("PN", k[0]) 807 self.d.setVar("SRCREV", k[2])
791 self.d.setVar("SRCREV", k[2]) 808 self.d.setVar("UPSTREAM_CHECK_GITTAGREGEX", k[3])
792 self.d.setVar("UPSTREAM_CHECK_GITTAGREGEX", k[3]) 809 ud = bb.fetch2.FetchData(k[1], self.d)
793 ud = bb.fetch2.FetchData(k[1], self.d) 810 pupver= ud.method.latest_versionstring(ud, self.d)
794 pupver= ud.method.latest_versionstring(ud, self.d) 811 verstring = pupver[0]
795 verstring = pupver[0] 812 self.assertTrue(verstring, msg="Could not find upstream version")
796 self.assertTrue(verstring, msg="Could not find upstream version") 813 r = bb.utils.vercmp_string(v, verstring)
797 r = bb.utils.vercmp_string(v, verstring) 814 self.assertTrue(r == -1 or r == 0, msg="Package %s, version: %s <= %s" % (k[0], v, verstring))
798 self.assertTrue(r == -1 or r == 0, msg="Package %s, version: %s <= %s" % (k[0], v, verstring)) 815
799 816 @skipIfNoNetwork()
800 def test_wget_latest_versionstring(self): 817 def test_wget_latest_versionstring(self):
801 for k, v in self.test_wget_uris.items(): 818 for k, v in self.test_wget_uris.items():
802 self.d.setVar("PN", k[0]) 819 self.d.setVar("PN", k[0])
803 self.d.setVar("UPSTREAM_CHECK_URI", k[2]) 820 self.d.setVar("UPSTREAM_CHECK_URI", k[2])
804 self.d.setVar("UPSTREAM_CHECK_REGEX", k[3]) 821 self.d.setVar("UPSTREAM_CHECK_REGEX", k[3])
805 ud = bb.fetch2.FetchData(k[1], self.d) 822 ud = bb.fetch2.FetchData(k[1], self.d)
806 pupver = ud.method.latest_versionstring(ud, self.d) 823 pupver = ud.method.latest_versionstring(ud, self.d)
807 verstring = pupver[0] 824 verstring = pupver[0]
808 self.assertTrue(verstring, msg="Could not find upstream version") 825 self.assertTrue(verstring, msg="Could not find upstream version")
809 r = bb.utils.vercmp_string(v, verstring) 826 r = bb.utils.vercmp_string(v, verstring)
810 self.assertTrue(r == -1 or r == 0, msg="Package %s, version: %s <= %s" % (k[0], v, verstring)) 827 self.assertTrue(r == -1 or r == 0, msg="Package %s, version: %s <= %s" % (k[0], v, verstring))
811 828
812 829
813class FetchCheckStatusTest(FetcherTest): 830class FetchCheckStatusTest(FetcherTest):
@@ -827,33 +844,30 @@ class FetchCheckStatusTest(FetcherTest):
827 "https://github.com/kergoth/tslib/releases/download/1.1/tslib-1.1.tar.xz" 844 "https://github.com/kergoth/tslib/releases/download/1.1/tslib-1.1.tar.xz"
828 ] 845 ]
829 846
830 if os.environ.get("BB_SKIP_NETTESTS") == "yes": 847 @skipIfNoNetwork()
831 print("Unset BB_SKIP_NETTESTS to run network tests") 848 def test_wget_checkstatus(self):
832 else: 849 fetch = bb.fetch2.Fetch(self.test_wget_uris, self.d)
833 850 for u in self.test_wget_uris:
834 def test_wget_checkstatus(self): 851 ud = fetch.ud[u]
835 fetch = bb.fetch2.Fetch(self.test_wget_uris, self.d) 852 m = ud.method
836 for u in self.test_wget_uris: 853 ret = m.checkstatus(fetch, ud, self.d)
837 ud = fetch.ud[u] 854 self.assertTrue(ret, msg="URI %s, can't check status" % (u))
838 m = ud.method
839 ret = m.checkstatus(fetch, ud, self.d)
840 self.assertTrue(ret, msg="URI %s, can't check status" % (u))
841 855
856 @skipIfNoNetwork()
857 def test_wget_checkstatus_connection_cache(self):
858 from bb.fetch2 import FetchConnectionCache
842 859
843 def test_wget_checkstatus_connection_cache(self): 860 connection_cache = FetchConnectionCache()
844 from bb.fetch2 import FetchConnectionCache 861 fetch = bb.fetch2.Fetch(self.test_wget_uris, self.d,
862 connection_cache = connection_cache)
845 863
846 connection_cache = FetchConnectionCache() 864 for u in self.test_wget_uris:
847 fetch = bb.fetch2.Fetch(self.test_wget_uris, self.d, 865 ud = fetch.ud[u]
848 connection_cache = connection_cache) 866 m = ud.method
867 ret = m.checkstatus(fetch, ud, self.d)
868 self.assertTrue(ret, msg="URI %s, can't check status" % (u))
849 869
850 for u in self.test_wget_uris: 870 connection_cache.close_connections()
851 ud = fetch.ud[u]
852 m = ud.method
853 ret = m.checkstatus(fetch, ud, self.d)
854 self.assertTrue(ret, msg="URI %s, can't check status" % (u))
855
856 connection_cache.close_connections()
857 871
858 872
859class GitMakeShallowTest(FetcherTest): 873class GitMakeShallowTest(FetcherTest):
@@ -972,15 +986,13 @@ class GitMakeShallowTest(FetcherTest):
972 self.make_shallow() 986 self.make_shallow()
973 self.assertRevCount(1) 987 self.assertRevCount(1)
974 988
975 if os.environ.get("BB_SKIP_NETTESTS") == "yes": 989 @skipIfNoNetwork()
976 print("Unset BB_SKIP_NETTESTS to run network tests") 990 def test_make_shallow_bitbake(self):
977 else: 991 self.git('remote add origin https://github.com/openembedded/bitbake')
978 def test_make_shallow_bitbake(self): 992 self.git('fetch --tags origin')
979 self.git('remote add origin https://github.com/openembedded/bitbake') 993 orig_revs = len(self.git('rev-list --all').splitlines())
980 self.git('fetch --tags origin') 994 self.make_shallow(['refs/tags/1.10.0'])
981 orig_revs = len(self.git('rev-list --all').splitlines()) 995 self.assertRevCount(orig_revs - 1746, ['--all'])
982 self.make_shallow(['refs/tags/1.10.0'])
983 self.assertRevCount(orig_revs - 1746, ['--all'])
984 996
985class GitShallowTest(FetcherTest): 997class GitShallowTest(FetcherTest):
986 def setUp(self): 998 def setUp(self):
@@ -1436,24 +1448,22 @@ class GitShallowTest(FetcherTest):
1436 with self.assertRaises(bb.fetch2.FetchError): 1448 with self.assertRaises(bb.fetch2.FetchError):
1437 self.fetch() 1449 self.fetch()
1438 1450
1439 if os.environ.get("BB_SKIP_NETTESTS") == "yes": 1451 @skipIfNoNetwork()
1440 print("Unset BB_SKIP_NETTESTS to run network tests") 1452 def test_bitbake(self):
1441 else: 1453 self.git('remote add --mirror=fetch origin git://github.com/openembedded/bitbake', cwd=self.srcdir)
1442 def test_bitbake(self): 1454 self.git('config core.bare true', cwd=self.srcdir)
1443 self.git('remote add --mirror=fetch origin git://github.com/openembedded/bitbake', cwd=self.srcdir) 1455 self.git('fetch', cwd=self.srcdir)
1444 self.git('config core.bare true', cwd=self.srcdir) 1456
1445 self.git('fetch', cwd=self.srcdir) 1457 self.d.setVar('BB_GIT_SHALLOW_DEPTH', '0')
1446 1458 # Note that the 1.10.0 tag is annotated, so this also tests
1447 self.d.setVar('BB_GIT_SHALLOW_DEPTH', '0') 1459 # reference of an annotated vs unannotated tag
1448 # Note that the 1.10.0 tag is annotated, so this also tests 1460 self.d.setVar('BB_GIT_SHALLOW_REVS', '1.10.0')
1449 # reference of an annotated vs unannotated tag 1461
1450 self.d.setVar('BB_GIT_SHALLOW_REVS', '1.10.0') 1462 self.fetch_shallow()
1451 1463
1452 self.fetch_shallow() 1464 # Confirm that the history of 1.10.0 was removed
1453 1465 orig_revs = len(self.git('rev-list master', cwd=self.srcdir).splitlines())
1454 # Confirm that the history of 1.10.0 was removed 1466 revs = len(self.git('rev-list master').splitlines())
1455 orig_revs = len(self.git('rev-list master', cwd=self.srcdir).splitlines()) 1467 self.assertNotEqual(orig_revs, revs)
1456 revs = len(self.git('rev-list master').splitlines()) 1468 self.assertRefs(['master', 'origin/master'])
1457 self.assertNotEqual(orig_revs, revs) 1469 self.assertRevCount(orig_revs - 1758)
1458 self.assertRefs(['master', 'origin/master'])
1459 self.assertRevCount(orig_revs - 1758)