summaryrefslogtreecommitdiff
path: root/poky/bitbake/lib/bb/tests/fetch.py
diff options
context:
space:
mode:
Diffstat (limited to 'poky/bitbake/lib/bb/tests/fetch.py')
-rw-r--r--poky/bitbake/lib/bb/tests/fetch.py80
1 files changed, 80 insertions, 0 deletions
diff --git a/poky/bitbake/lib/bb/tests/fetch.py b/poky/bitbake/lib/bb/tests/fetch.py
index 6bdf0416d..16f975b13 100644
--- a/poky/bitbake/lib/bb/tests/fetch.py
+++ b/poky/bitbake/lib/bb/tests/fetch.py
@@ -991,6 +991,86 @@ class FetcherNetworkTest(FetcherTest):
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')
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')
+class SVNTest(FetcherTest):
+ def skipIfNoSvn():
+ import shutil
+ if not shutil.which("svn"):
+ return unittest.skip("svn not installed, tests being skipped")
+
+ if not shutil.which("svnadmin"):
+ return unittest.skip("svnadmin not installed, tests being skipped")
+
+ return lambda f: f
+
+ @skipIfNoSvn()
+ def setUp(self):
+ """ Create a local repository """
+
+ super(SVNTest, self).setUp()
+
+ # Create something we can fetch
+ src_dir = tempfile.mkdtemp(dir=self.tempdir,
+ prefix='svnfetch_srcdir_')
+ src_dir = os.path.abspath(src_dir)
+ bb.process.run("echo readme > README.md", cwd=src_dir)
+
+ # Store it in a local SVN repository
+ repo_dir = tempfile.mkdtemp(dir=self.tempdir,
+ prefix='svnfetch_localrepo_')
+ repo_dir = os.path.abspath(repo_dir)
+ bb.process.run("svnadmin create project", cwd=repo_dir)
+
+ self.repo_url = "file://%s/project" % repo_dir
+ bb.process.run("svn import --non-interactive -m 'Initial import' %s %s/trunk" % (src_dir, self.repo_url),
+ cwd=repo_dir)
+
+ bb.process.run("svn co %s svnfetch_co" % self.repo_url, cwd=self.tempdir)
+ # Github will emulate SVN. Use this to check if we're downloding...
+ bb.process.run("svn propset svn:externals 'bitbake http://github.com/openembedded/bitbake' .",
+ cwd=os.path.join(self.tempdir, 'svnfetch_co', 'trunk'))
+ bb.process.run("svn commit --non-interactive -m 'Add external'",
+ cwd=os.path.join(self.tempdir, 'svnfetch_co', 'trunk'))
+
+ self.src_dir = src_dir
+ self.repo_dir = repo_dir
+
+ @skipIfNoSvn()
+ def tearDown(self):
+ os.chdir(self.origdir)
+ if os.environ.get("BB_TMPDIR_NOCLEAN") == "yes":
+ print("Not cleaning up %s. Please remove manually." % self.tempdir)
+ else:
+ bb.utils.prunedir(self.tempdir)
+
+ @skipIfNoSvn()
+ @skipIfNoNetwork()
+ def test_noexternal_svn(self):
+ # Always match the rev count from setUp (currently rev 2)
+ url = "svn://%s;module=trunk;protocol=file;rev=2" % self.repo_url.replace('file://', '')
+ fetcher = bb.fetch.Fetch([url], self.d)
+ fetcher.download()
+ os.chdir(os.path.dirname(self.unpackdir))
+ fetcher.unpack(self.unpackdir)
+
+ self.assertTrue(os.path.exists(os.path.join(self.unpackdir, 'trunk')), msg="Missing trunk")
+ self.assertTrue(os.path.exists(os.path.join(self.unpackdir, 'trunk', 'README.md')), msg="Missing contents")
+ self.assertFalse(os.path.exists(os.path.join(self.unpackdir, 'trunk/bitbake/trunk')), msg="External dir should NOT exist")
+ self.assertFalse(os.path.exists(os.path.join(self.unpackdir, 'trunk/bitbake/trunk', 'README')), msg="External README should NOT exit")
+
+ @skipIfNoSvn()
+ def test_external_svn(self):
+ # Always match the rev count from setUp (currently rev 2)
+ url = "svn://%s;module=trunk;protocol=file;externals=allowed;rev=2" % self.repo_url.replace('file://', '')
+ fetcher = bb.fetch.Fetch([url], self.d)
+ fetcher.download()
+ os.chdir(os.path.dirname(self.unpackdir))
+ fetcher.unpack(self.unpackdir)
+
+ self.assertTrue(os.path.exists(os.path.join(self.unpackdir, 'trunk')), msg="Missing trunk")
+ self.assertTrue(os.path.exists(os.path.join(self.unpackdir, 'trunk', 'README.md')), msg="Missing contents")
+ self.assertTrue(os.path.exists(os.path.join(self.unpackdir, 'trunk/bitbake/trunk')), msg="External dir should exist")
+ self.assertTrue(os.path.exists(os.path.join(self.unpackdir, 'trunk/bitbake/trunk', 'README')), msg="External README should exit")
+
class TrustedNetworksTest(FetcherTest):
def test_trusted_network(self):
# Ensure trusted_network returns False when the host IS in the list.