blob: 5a02add764f9e309401ce2ca4de6d02c1d536c3a [file] [log] [blame]
Brad Bishopc342db32019-05-15 21:57:59 -04001#
Brad Bishop6e60e8b2018-02-01 10:27:11 -05002# Copyright (C) 2016 Intel Corporation
Brad Bishopc342db32019-05-15 21:57:59 -04003#
4# SPDX-License-Identifier: MIT
5#
Brad Bishop6e60e8b2018-02-01 10:27:11 -05006
Brad Bishopd7bf8c12018-02-25 22:55:05 -05007import os
Brad Bishop6e60e8b2018-02-01 10:27:11 -05008import shutil
9import subprocess
10
11from oeqa.sdkext.case import OESDKExtTestCase
Brad Bishopd7bf8c12018-02-25 22:55:05 -050012from oeqa.utils.httpserver import HTTPService
Brad Bishop6e60e8b2018-02-01 10:27:11 -050013
Brad Bishop19323692019-04-05 15:28:33 -040014from oeqa.utils.subprocesstweak import errors_have_output
15errors_have_output()
16
Brad Bishop6e60e8b2018-02-01 10:27:11 -050017class DevtoolTest(OESDKExtTestCase):
18 @classmethod
19 def setUpClass(cls):
20 myapp_src = os.path.join(cls.tc.esdk_files_dir, "myapp")
21 cls.myapp_dst = os.path.join(cls.tc.sdk_dir, "myapp")
22 shutil.copytree(myapp_src, cls.myapp_dst)
23
24 myapp_cmake_src = os.path.join(cls.tc.esdk_files_dir, "myapp_cmake")
25 cls.myapp_cmake_dst = os.path.join(cls.tc.sdk_dir, "myapp_cmake")
26 shutil.copytree(myapp_cmake_src, cls.myapp_cmake_dst)
27
28 @classmethod
29 def tearDownClass(cls):
30 shutil.rmtree(cls.myapp_dst)
31 shutil.rmtree(cls.myapp_cmake_dst)
32
33 def _test_devtool_build(self, directory):
34 self._run('devtool add myapp %s' % directory)
35 try:
36 self._run('devtool build myapp')
37 finally:
38 self._run('devtool reset myapp')
39
40 def _test_devtool_build_package(self, directory):
41 self._run('devtool add myapp %s' % directory)
42 try:
43 self._run('devtool package myapp')
44 finally:
45 self._run('devtool reset myapp')
46
47 def test_devtool_location(self):
48 output = self._run('which devtool')
49 self.assertEqual(output.startswith(self.tc.sdk_dir), True, \
50 msg="Seems that devtool isn't the eSDK one: %s" % output)
51
Brad Bishop6e60e8b2018-02-01 10:27:11 -050052 def test_devtool_add_reset(self):
53 self._run('devtool add myapp %s' % self.myapp_dst)
54 self._run('devtool reset myapp')
55
Brad Bishop6e60e8b2018-02-01 10:27:11 -050056 def test_devtool_build_make(self):
57 self._test_devtool_build(self.myapp_dst)
58
Brad Bishop6e60e8b2018-02-01 10:27:11 -050059 def test_devtool_build_esdk_package(self):
60 self._test_devtool_build_package(self.myapp_dst)
61
Brad Bishop6e60e8b2018-02-01 10:27:11 -050062 def test_devtool_build_cmake(self):
63 self._test_devtool_build(self.myapp_cmake_dst)
64
Brad Bishop6e60e8b2018-02-01 10:27:11 -050065 def test_extend_autotools_recipe_creation(self):
66 req = 'https://github.com/rdfa/librdfa'
67 recipe = "librdfa"
68 self._run('devtool sdk-install libxml2')
69 self._run('devtool add %s %s' % (recipe, req) )
70 try:
71 self._run('devtool build %s' % recipe)
72 finally:
73 self._run('devtool reset %s' % recipe)
74
Brad Bishop6e60e8b2018-02-01 10:27:11 -050075 def test_devtool_kernelmodule(self):
76 docfile = 'https://github.com/umlaeute/v4l2loopback.git'
77 recipe = 'v4l2loopback-driver'
78 self._run('devtool add %s %s' % (recipe, docfile) )
79 try:
80 self._run('devtool build %s' % recipe)
81 finally:
82 self._run('devtool reset %s' % recipe)
83
Brad Bishop6e60e8b2018-02-01 10:27:11 -050084 def test_recipes_for_nodejs(self):
85 package_nodejs = "npm://registry.npmjs.org;name=winston;version=2.2.0"
86 self._run('devtool add %s ' % package_nodejs)
87 try:
88 self._run('devtool build %s ' % package_nodejs)
89 finally:
90 self._run('devtool reset %s '% package_nodejs)
Brad Bishopd7bf8c12018-02-25 22:55:05 -050091
92class SdkUpdateTest(OESDKExtTestCase):
93 @classmethod
94 def setUpClass(self):
95 self.publish_dir = os.path.join(self.tc.sdk_dir, 'esdk_publish')
96 if os.path.exists(self.publish_dir):
97 shutil.rmtree(self.publish_dir)
98 os.mkdir(self.publish_dir)
99
100 base_tcname = "%s/%s" % (self.td.get("SDK_DEPLOY", ''),
101 self.td.get("TOOLCHAINEXT_OUTPUTNAME", ''))
102 tcname_new = "%s-new.sh" % base_tcname
103 if not os.path.exists(tcname_new):
104 tcname_new = "%s.sh" % base_tcname
105
106 cmd = 'oe-publish-sdk %s %s' % (tcname_new, self.publish_dir)
107 subprocess.check_output(cmd, shell=True)
108
109 self.http_service = HTTPService(self.publish_dir)
110 self.http_service.start()
111
112 self.http_url = "http://127.0.0.1:%d" % self.http_service.port
113
114 def test_sdk_update_http(self):
115 output = self._run("devtool sdk-update \"%s\"" % self.http_url)
116
117 @classmethod
118 def tearDownClass(self):
119 self.http_service.stop()
120 shutil.rmtree(self.publish_dir)