diff options
Diffstat (limited to 'bitbake/lib/bb/tests/fetch.py')
-rw-r--r-- | bitbake/lib/bb/tests/fetch.py | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/bitbake/lib/bb/tests/fetch.py b/bitbake/lib/bb/tests/fetch.py index 6bdf0416d7..16f975b137 100644 --- a/bitbake/lib/bb/tests/fetch.py +++ b/bitbake/lib/bb/tests/fetch.py | |||
@@ -991,6 +991,86 @@ class FetcherNetworkTest(FetcherTest): | |||
991 | self.assertTrue(os.path.exists(os.path.join(repo_path, 'edgelet/hsm-sys/azure-iot-hsm-c/deps/utpm/deps/c-utility/testtools/umock-c/deps/ctest/README.md')), msg='Missing submodule checkout') | 991 | self.assertTrue(os.path.exists(os.path.join(repo_path, 'edgelet/hsm-sys/azure-iot-hsm-c/deps/utpm/deps/c-utility/testtools/umock-c/deps/ctest/README.md')), msg='Missing submodule checkout') |
992 | self.assertTrue(os.path.exists(os.path.join(repo_path, 'edgelet/hsm-sys/azure-iot-hsm-c/deps/utpm/deps/c-utility/testtools/umock-c/deps/testrunner/readme.md')), msg='Missing submodule checkout') | 992 | self.assertTrue(os.path.exists(os.path.join(repo_path, 'edgelet/hsm-sys/azure-iot-hsm-c/deps/utpm/deps/c-utility/testtools/umock-c/deps/testrunner/readme.md')), msg='Missing submodule checkout') |
993 | 993 | ||
994 | class SVNTest(FetcherTest): | ||
995 | def skipIfNoSvn(): | ||
996 | import shutil | ||
997 | if not shutil.which("svn"): | ||
998 | return unittest.skip("svn not installed, tests being skipped") | ||
999 | |||
1000 | if not shutil.which("svnadmin"): | ||
1001 | return unittest.skip("svnadmin not installed, tests being skipped") | ||
1002 | |||
1003 | return lambda f: f | ||
1004 | |||
1005 | @skipIfNoSvn() | ||
1006 | def setUp(self): | ||
1007 | """ Create a local repository """ | ||
1008 | |||
1009 | super(SVNTest, self).setUp() | ||
1010 | |||
1011 | # Create something we can fetch | ||
1012 | src_dir = tempfile.mkdtemp(dir=self.tempdir, | ||
1013 | prefix='svnfetch_srcdir_') | ||
1014 | src_dir = os.path.abspath(src_dir) | ||
1015 | bb.process.run("echo readme > README.md", cwd=src_dir) | ||
1016 | |||
1017 | # Store it in a local SVN repository | ||
1018 | repo_dir = tempfile.mkdtemp(dir=self.tempdir, | ||
1019 | prefix='svnfetch_localrepo_') | ||
1020 | repo_dir = os.path.abspath(repo_dir) | ||
1021 | bb.process.run("svnadmin create project", cwd=repo_dir) | ||
1022 | |||
1023 | self.repo_url = "file://%s/project" % repo_dir | ||
1024 | bb.process.run("svn import --non-interactive -m 'Initial import' %s %s/trunk" % (src_dir, self.repo_url), | ||
1025 | cwd=repo_dir) | ||
1026 | |||
1027 | bb.process.run("svn co %s svnfetch_co" % self.repo_url, cwd=self.tempdir) | ||
1028 | # Github will emulate SVN. Use this to check if we're downloding... | ||
1029 | bb.process.run("svn propset svn:externals 'bitbake http://github.com/openembedded/bitbake' .", | ||
1030 | cwd=os.path.join(self.tempdir, 'svnfetch_co', 'trunk')) | ||
1031 | bb.process.run("svn commit --non-interactive -m 'Add external'", | ||
1032 | cwd=os.path.join(self.tempdir, 'svnfetch_co', 'trunk')) | ||
1033 | |||
1034 | self.src_dir = src_dir | ||
1035 | self.repo_dir = repo_dir | ||
1036 | |||
1037 | @skipIfNoSvn() | ||
1038 | def tearDown(self): | ||
1039 | os.chdir(self.origdir) | ||
1040 | if os.environ.get("BB_TMPDIR_NOCLEAN") == "yes": | ||
1041 | print("Not cleaning up %s. Please remove manually." % self.tempdir) | ||
1042 | else: | ||
1043 | bb.utils.prunedir(self.tempdir) | ||
1044 | |||
1045 | @skipIfNoSvn() | ||
1046 | @skipIfNoNetwork() | ||
1047 | def test_noexternal_svn(self): | ||
1048 | # Always match the rev count from setUp (currently rev 2) | ||
1049 | url = "svn://%s;module=trunk;protocol=file;rev=2" % self.repo_url.replace('file://', '') | ||
1050 | fetcher = bb.fetch.Fetch([url], self.d) | ||
1051 | fetcher.download() | ||
1052 | os.chdir(os.path.dirname(self.unpackdir)) | ||
1053 | fetcher.unpack(self.unpackdir) | ||
1054 | |||
1055 | self.assertTrue(os.path.exists(os.path.join(self.unpackdir, 'trunk')), msg="Missing trunk") | ||
1056 | self.assertTrue(os.path.exists(os.path.join(self.unpackdir, 'trunk', 'README.md')), msg="Missing contents") | ||
1057 | self.assertFalse(os.path.exists(os.path.join(self.unpackdir, 'trunk/bitbake/trunk')), msg="External dir should NOT exist") | ||
1058 | self.assertFalse(os.path.exists(os.path.join(self.unpackdir, 'trunk/bitbake/trunk', 'README')), msg="External README should NOT exit") | ||
1059 | |||
1060 | @skipIfNoSvn() | ||
1061 | def test_external_svn(self): | ||
1062 | # Always match the rev count from setUp (currently rev 2) | ||
1063 | url = "svn://%s;module=trunk;protocol=file;externals=allowed;rev=2" % self.repo_url.replace('file://', '') | ||
1064 | fetcher = bb.fetch.Fetch([url], self.d) | ||
1065 | fetcher.download() | ||
1066 | os.chdir(os.path.dirname(self.unpackdir)) | ||
1067 | fetcher.unpack(self.unpackdir) | ||
1068 | |||
1069 | self.assertTrue(os.path.exists(os.path.join(self.unpackdir, 'trunk')), msg="Missing trunk") | ||
1070 | self.assertTrue(os.path.exists(os.path.join(self.unpackdir, 'trunk', 'README.md')), msg="Missing contents") | ||
1071 | self.assertTrue(os.path.exists(os.path.join(self.unpackdir, 'trunk/bitbake/trunk')), msg="External dir should exist") | ||
1072 | self.assertTrue(os.path.exists(os.path.join(self.unpackdir, 'trunk/bitbake/trunk', 'README')), msg="External README should exit") | ||
1073 | |||
994 | class TrustedNetworksTest(FetcherTest): | 1074 | class TrustedNetworksTest(FetcherTest): |
995 | def test_trusted_network(self): | 1075 | def test_trusted_network(self): |
996 | # Ensure trusted_network returns False when the host IS in the list. | 1076 | # Ensure trusted_network returns False when the host IS in the list. |