Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame^] | 1 | # |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 2 | # Copyright (C) 2016 Intel Corporation |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame^] | 3 | # |
| 4 | # SPDX-License-Identifier: MIT |
| 5 | # |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 6 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7 | import os |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 8 | import shutil |
| 9 | import subprocess |
| 10 | |
| 11 | from oeqa.sdkext.case import OESDKExtTestCase |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 12 | from oeqa.utils.httpserver import HTTPService |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 13 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 14 | from oeqa.utils.subprocesstweak import errors_have_output |
| 15 | errors_have_output() |
| 16 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 17 | class 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 Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 52 | def test_devtool_add_reset(self): |
| 53 | self._run('devtool add myapp %s' % self.myapp_dst) |
| 54 | self._run('devtool reset myapp') |
| 55 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 56 | def test_devtool_build_make(self): |
| 57 | self._test_devtool_build(self.myapp_dst) |
| 58 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 59 | def test_devtool_build_esdk_package(self): |
| 60 | self._test_devtool_build_package(self.myapp_dst) |
| 61 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 62 | def test_devtool_build_cmake(self): |
| 63 | self._test_devtool_build(self.myapp_cmake_dst) |
| 64 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 65 | 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 Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 75 | 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 Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 84 | 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 Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 91 | |
| 92 | class 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) |