diff options
-rw-r--r-- | meta/lib/oeqa/selftest/eSDK.py | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/meta/lib/oeqa/selftest/eSDK.py b/meta/lib/oeqa/selftest/eSDK.py new file mode 100644 index 0000000000..9d5c680948 --- /dev/null +++ b/meta/lib/oeqa/selftest/eSDK.py | |||
@@ -0,0 +1,103 @@ | |||
1 | import unittest | ||
2 | import tempfile | ||
3 | import shutil | ||
4 | import os | ||
5 | import glob | ||
6 | import logging | ||
7 | import subprocess | ||
8 | import oeqa.utils.ftools as ftools | ||
9 | from oeqa.utils.decorators import testcase | ||
10 | from oeqa.selftest.base import oeSelfTest | ||
11 | from oeqa.utils.commands import runCmd, bitbake, get_bb_var | ||
12 | from oeqa.utils.httpserver import HTTPService | ||
13 | |||
14 | class oeSDKExtSelfTest(oeSelfTest): | ||
15 | """ | ||
16 | # Bugzilla Test Plan: 6033 | ||
17 | # This code is planned to be part of the automation for eSDK containig | ||
18 | # Install libraries and headers, image generation binary feeds. | ||
19 | """ | ||
20 | |||
21 | @staticmethod | ||
22 | def get_esdk_environment(env_eSDK, tmpdir_eSDKQA): | ||
23 | # XXX: at this time use the first env need to investigate | ||
24 | # what environment load oe-selftest, i586, x86_64 | ||
25 | pattern = os.path.join(tmpdir_eSDKQA, 'environment-setup-*') | ||
26 | return glob.glob(pattern)[0] | ||
27 | |||
28 | @staticmethod | ||
29 | def run_esdk_cmd(env_eSDK, tmpdir_eSDKQA, cmd, postconfig=None, **options): | ||
30 | if postconfig: | ||
31 | esdk_conf_file = os.path.join(tmpdir_eSDKQA, 'conf', 'local.conf') | ||
32 | with open(esdk_conf_file, 'a+') as f: | ||
33 | f.write(postconfig) | ||
34 | if not options: | ||
35 | options = {} | ||
36 | if not 'shell' in options: | ||
37 | options['shell'] = True | ||
38 | |||
39 | runCmd("cd %s; . %s; %s" % (tmpdir_eSDKQA, env_eSDK, cmd), **options) | ||
40 | |||
41 | @staticmethod | ||
42 | def generate_eSDK(image): | ||
43 | pn_task = '%s -c populate_sdk_ext' % image | ||
44 | bitbake(pn_task) | ||
45 | |||
46 | @staticmethod | ||
47 | def get_eSDK_toolchain(image): | ||
48 | pn_task = '%s -c populate_sdk_ext' % image | ||
49 | |||
50 | sdk_deploy = get_bb_var('SDK_DEPLOY', pn_task) | ||
51 | toolchain_name = get_bb_var('TOOLCHAINEXT_OUTPUTNAME', pn_task) | ||
52 | return os.path.join(sdk_deploy, toolchain_name + '.sh') | ||
53 | |||
54 | |||
55 | @classmethod | ||
56 | def setUpClass(cls): | ||
57 | # Start to serve sstate dir | ||
58 | sstate_dir = os.path.join(os.environ['BUILDDIR'], 'sstate-cache') | ||
59 | cls.http_service = HTTPService(sstate_dir) | ||
60 | cls.http_service.start() | ||
61 | |||
62 | http_url = "127.0.0.1:%d" % cls.http_service.port | ||
63 | |||
64 | image = 'core-image-minimal' | ||
65 | |||
66 | cls.tmpdir_eSDKQA = tempfile.mkdtemp(prefix='eSDKQA') | ||
67 | oeSDKExtSelfTest.generate_eSDK(image) | ||
68 | |||
69 | # Install eSDK | ||
70 | ext_sdk_path = oeSDKExtSelfTest.get_eSDK_toolchain(image) | ||
71 | runCmd("%s -y -d \"%s\"" % (ext_sdk_path, cls.tmpdir_eSDKQA)) | ||
72 | |||
73 | cls.env_eSDK = oeSDKExtSelfTest.get_esdk_environment('', cls.tmpdir_eSDKQA) | ||
74 | |||
75 | # Configure eSDK to use sstate mirror from poky | ||
76 | sstate_config=""" | ||
77 | SDK_LOCAL_CONF_WHITELIST = "SSTATE_MIRRORS" | ||
78 | SSTATE_MIRRORS = "file://.* http://%s/PATH" | ||
79 | """ % http_url | ||
80 | with open(os.path.join(cls.tmpdir_eSDKQA, 'conf', 'local.conf'), 'a+') as f: | ||
81 | f.write(sstate_config) | ||
82 | |||
83 | |||
84 | @classmethod | ||
85 | def tearDownClass(cls): | ||
86 | shutil.rmtree(cls.tmpdir_eSDKQA) | ||
87 | cls.http_service.stop() | ||
88 | |||
89 | @testcase (1471) | ||
90 | def test_install_libraries_headers(self): | ||
91 | pn_sstate = 'bc' | ||
92 | bitbake(pn_sstate) | ||
93 | cmd = "devtool sdk-install %s " % pn_sstate | ||
94 | oeSDKExtSelfTest.run_esdk_cmd(self.env_eSDK, self.tmpdir_eSDKQA, cmd) | ||
95 | |||
96 | @testcase(1472) | ||
97 | def test_image_generation_binary_feeds(self): | ||
98 | image = 'core-image-minimal' | ||
99 | cmd = "devtool build-image %s" % image | ||
100 | oeSDKExtSelfTest.run_esdk_cmd(self.env_eSDK, self.tmpdir_eSDKQA, cmd) | ||
101 | |||
102 | if __name__ == '__main__': | ||
103 | unittest.main() | ||