summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/selftest/cases/gotoolchain.py
diff options
context:
space:
mode:
authorJoshua Lock <joshua.g.lock@intel.com>2017-10-04 17:22:48 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-11-08 22:24:03 +0000
commit51b3c38b5d5d80c3acf5d2477db38b08803c8883 (patch)
tree2e1c6b83c5045651d4e54ad8ede868c9e55aac04 /meta/lib/oeqa/selftest/cases/gotoolchain.py
parentb40d80993e3a36ca5b59970e04e46dd7884e7599 (diff)
downloadpoky-51b3c38b5d5d80c3acf5d2477db38b08803c8883.tar.gz
lib/oeqa/selftest/cases/gotoolchain: add selftest for the Go toolchain
Add a simple test case to being testing of the Go toolchain: 1) build meta-go-toolchain 2) create a temp directory and install the generated Go toolchain within 3) fetch an archive of the Go Dep tool 4) create an appropriately laid out GOROOT and inflate the dep archive there 5) build the dep command with the SDK's Go toolchain and check it returned successfully. [YOCTO #12152] (From OE-Core rev: bca999644e28e1666357bcbeab685547c6f9dd65) Signed-off-by: Joshua Lock <joshua.g.lock@intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/selftest/cases/gotoolchain.py')
-rw-r--r--meta/lib/oeqa/selftest/cases/gotoolchain.py67
1 files changed, 67 insertions, 0 deletions
diff --git a/meta/lib/oeqa/selftest/cases/gotoolchain.py b/meta/lib/oeqa/selftest/cases/gotoolchain.py
new file mode 100644
index 0000000000..1e23257f4d
--- /dev/null
+++ b/meta/lib/oeqa/selftest/cases/gotoolchain.py
@@ -0,0 +1,67 @@
1import glob
2import os
3import shutil
4import tempfile
5from oeqa.selftest.case import OESelftestTestCase
6from oeqa.utils.commands import runCmd, bitbake, get_bb_vars
7
8
9class oeGoToolchainSelfTest(OESelftestTestCase):
10 """
11 Test cases for OE's Go toolchain
12 """
13
14 @staticmethod
15 def get_sdk_environment(tmpdir_SDKQA):
16 pattern = os.path.join(tmpdir_SDKQA, "environment-setup-*")
17 # FIXME: this is a very naive implementation
18 return glob.glob(pattern)[0]
19
20 @staticmethod
21 def get_sdk_toolchain():
22 bb_vars = get_bb_vars(['SDK_DEPLOY', 'TOOLCHAIN_OUTPUTNAME'],
23 "meta-go-toolchain")
24 sdk_deploy = bb_vars['SDK_DEPLOY']
25 toolchain_name = bb_vars['TOOLCHAIN_OUTPUTNAME']
26 return os.path.join(sdk_deploy, toolchain_name + ".sh")
27
28 @classmethod
29 def setUpClass(cls):
30 super(oeGoToolchainSelfTest, cls).setUpClass()
31 cls.tmpdir_SDKQA = tempfile.mkdtemp(prefix='SDKQA')
32 cls.go_path = os.path.join(cls.tmpdir_SDKQA, "go")
33 # Build the SDK and locate it in DEPLOYDIR
34 bitbake("meta-go-toolchain")
35 cls.sdk_path = oeGoToolchainSelfTest.get_sdk_toolchain()
36 # Install the SDK into the tmpdir
37 runCmd("sh %s -y -d \"%s\"" % (cls.sdk_path, cls.tmpdir_SDKQA))
38 cls.env_SDK = oeGoToolchainSelfTest.get_sdk_environment(cls.tmpdir_SDKQA)
39
40 @classmethod
41 def tearDownClass(cls):
42 shutil.rmtree(cls.tmpdir_SDKQA, ignore_errors=True)
43 super(oeGoToolchainSelfTest, cls).tearDownClass()
44
45 def run_sdk_go_command(self, gocmd):
46 cmd = "cd %s; " % self.tmpdir_SDKQA
47 cmd = cmd + ". %s; " % self.env_SDK
48 cmd = cmd + "export GOPATH=%s; " % self.go_path
49 cmd = cmd + "${CROSS_COMPILE}go %s" % gocmd
50 return runCmd(cmd).status
51
52 def test_go_dep_build(self):
53 proj = "github.com/golang"
54 name = "dep"
55 ver = "v0.3.1"
56 archive = ".tar.gz"
57 url = "https://%s/%s/archive/%s%s" % (proj, name, ver, archive)
58
59 runCmd("cd %s; wget %s" % (self.tmpdir_SDKQA, url))
60 runCmd("cd %s; tar -xf %s" % (self.tmpdir_SDKQA, ver+archive))
61 runCmd("mkdir -p %s/src/%s" % (self.go_path, proj))
62 runCmd("mv %s/dep-0.3.1 %s/src/%s/%s"
63 % (self.tmpdir_SDKQA, self.go_path, proj, name))
64 retv = self.run_sdk_go_command('build %s/%s/cmd/dep'
65 % (proj, name))
66 self.assertEqual(retv, 0,
67 msg="Running go build failed for %s" % name)