blob: 5ffb732556b248954d0a02c7bf08394dd3a80755 [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)
Andrew Geisslerc182c622020-05-15 14:13:32 -050023 subprocess.check_output(['git', 'init', '.'], cwd=cls.myapp_dst)
24 subprocess.check_output(['git', 'add', '.'], cwd=cls.myapp_dst)
25 subprocess.check_output(['git', 'commit', '-m', "'test commit'"], cwd=cls.myapp_dst)
Brad Bishop6e60e8b2018-02-01 10:27:11 -050026
27 myapp_cmake_src = os.path.join(cls.tc.esdk_files_dir, "myapp_cmake")
28 cls.myapp_cmake_dst = os.path.join(cls.tc.sdk_dir, "myapp_cmake")
29 shutil.copytree(myapp_cmake_src, cls.myapp_cmake_dst)
Andrew Geisslerc182c622020-05-15 14:13:32 -050030 subprocess.check_output(['git', 'init', '.'], cwd=cls.myapp_cmake_dst)
31 subprocess.check_output(['git', 'add', '.'], cwd=cls.myapp_cmake_dst)
32 subprocess.check_output(['git', 'commit', '-m', "'test commit'"], cwd=cls.myapp_cmake_dst)
Brad Bishop6e60e8b2018-02-01 10:27:11 -050033
34 @classmethod
35 def tearDownClass(cls):
36 shutil.rmtree(cls.myapp_dst)
37 shutil.rmtree(cls.myapp_cmake_dst)
38
39 def _test_devtool_build(self, directory):
40 self._run('devtool add myapp %s' % directory)
41 try:
42 self._run('devtool build myapp')
43 finally:
44 self._run('devtool reset myapp')
45
46 def _test_devtool_build_package(self, directory):
47 self._run('devtool add myapp %s' % directory)
48 try:
49 self._run('devtool package myapp')
50 finally:
51 self._run('devtool reset myapp')
52
53 def test_devtool_location(self):
54 output = self._run('which devtool')
55 self.assertEqual(output.startswith(self.tc.sdk_dir), True, \
56 msg="Seems that devtool isn't the eSDK one: %s" % output)
57
Brad Bishop6e60e8b2018-02-01 10:27:11 -050058 def test_devtool_add_reset(self):
59 self._run('devtool add myapp %s' % self.myapp_dst)
60 self._run('devtool reset myapp')
61
Brad Bishop6e60e8b2018-02-01 10:27:11 -050062 def test_devtool_build_make(self):
63 self._test_devtool_build(self.myapp_dst)
64
Brad Bishop6e60e8b2018-02-01 10:27:11 -050065 def test_devtool_build_esdk_package(self):
66 self._test_devtool_build_package(self.myapp_dst)
67
Brad Bishop6e60e8b2018-02-01 10:27:11 -050068 def test_devtool_build_cmake(self):
69 self._test_devtool_build(self.myapp_cmake_dst)
70
Brad Bishop6e60e8b2018-02-01 10:27:11 -050071 def test_extend_autotools_recipe_creation(self):
72 req = 'https://github.com/rdfa/librdfa'
73 recipe = "librdfa"
74 self._run('devtool sdk-install libxml2')
75 self._run('devtool add %s %s' % (recipe, req) )
76 try:
77 self._run('devtool build %s' % recipe)
78 finally:
79 self._run('devtool reset %s' % recipe)
80
Brad Bishop6e60e8b2018-02-01 10:27:11 -050081 def test_devtool_kernelmodule(self):
Brad Bishop79641f22019-09-10 07:20:22 -040082 docfile = 'https://git.yoctoproject.org/git/kernel-module-hello-world'
83 recipe = 'kernel-module-hello-world'
Brad Bishop6e60e8b2018-02-01 10:27:11 -050084 self._run('devtool add %s %s' % (recipe, docfile) )
85 try:
86 self._run('devtool build %s' % recipe)
87 finally:
88 self._run('devtool reset %s' % recipe)
89
Brad Bishop6e60e8b2018-02-01 10:27:11 -050090 def test_recipes_for_nodejs(self):
91 package_nodejs = "npm://registry.npmjs.org;name=winston;version=2.2.0"
92 self._run('devtool add %s ' % package_nodejs)
93 try:
94 self._run('devtool build %s ' % package_nodejs)
95 finally:
96 self._run('devtool reset %s '% package_nodejs)
Brad Bishopd7bf8c12018-02-25 22:55:05 -050097
98class SdkUpdateTest(OESDKExtTestCase):
99 @classmethod
100 def setUpClass(self):
101 self.publish_dir = os.path.join(self.tc.sdk_dir, 'esdk_publish')
102 if os.path.exists(self.publish_dir):
103 shutil.rmtree(self.publish_dir)
104 os.mkdir(self.publish_dir)
105
106 base_tcname = "%s/%s" % (self.td.get("SDK_DEPLOY", ''),
107 self.td.get("TOOLCHAINEXT_OUTPUTNAME", ''))
108 tcname_new = "%s-new.sh" % base_tcname
109 if not os.path.exists(tcname_new):
110 tcname_new = "%s.sh" % base_tcname
111
112 cmd = 'oe-publish-sdk %s %s' % (tcname_new, self.publish_dir)
113 subprocess.check_output(cmd, shell=True)
114
Patrick Williams864cc432023-02-09 14:54:44 -0600115 self.http_service = HTTPService(self.publish_dir, logger=self.logger)
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500116 self.http_service.start()
117
118 self.http_url = "http://127.0.0.1:%d" % self.http_service.port
119
120 def test_sdk_update_http(self):
121 output = self._run("devtool sdk-update \"%s\"" % self.http_url)
122
123 @classmethod
124 def tearDownClass(self):
125 self.http_service.stop()
126 shutil.rmtree(self.publish_dir)