Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 1 | # Copyright (C) 2016 Intel Corporation |
| 2 | # Released under the MIT license (see COPYING.MIT) |
| 3 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 4 | import os |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 5 | import shutil |
| 6 | import subprocess |
| 7 | |
| 8 | from oeqa.sdkext.case import OESDKExtTestCase |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 9 | from oeqa.core.decorator.oeid import OETestID |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 10 | from oeqa.utils.httpserver import HTTPService |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 11 | |
| 12 | class DevtoolTest(OESDKExtTestCase): |
| 13 | @classmethod |
| 14 | def setUpClass(cls): |
| 15 | myapp_src = os.path.join(cls.tc.esdk_files_dir, "myapp") |
| 16 | cls.myapp_dst = os.path.join(cls.tc.sdk_dir, "myapp") |
| 17 | shutil.copytree(myapp_src, cls.myapp_dst) |
| 18 | |
| 19 | myapp_cmake_src = os.path.join(cls.tc.esdk_files_dir, "myapp_cmake") |
| 20 | cls.myapp_cmake_dst = os.path.join(cls.tc.sdk_dir, "myapp_cmake") |
| 21 | shutil.copytree(myapp_cmake_src, cls.myapp_cmake_dst) |
| 22 | |
| 23 | @classmethod |
| 24 | def tearDownClass(cls): |
| 25 | shutil.rmtree(cls.myapp_dst) |
| 26 | shutil.rmtree(cls.myapp_cmake_dst) |
| 27 | |
| 28 | def _test_devtool_build(self, directory): |
| 29 | self._run('devtool add myapp %s' % directory) |
| 30 | try: |
| 31 | self._run('devtool build myapp') |
| 32 | finally: |
| 33 | self._run('devtool reset myapp') |
| 34 | |
| 35 | def _test_devtool_build_package(self, directory): |
| 36 | self._run('devtool add myapp %s' % directory) |
| 37 | try: |
| 38 | self._run('devtool package myapp') |
| 39 | finally: |
| 40 | self._run('devtool reset myapp') |
| 41 | |
| 42 | def test_devtool_location(self): |
| 43 | output = self._run('which devtool') |
| 44 | self.assertEqual(output.startswith(self.tc.sdk_dir), True, \ |
| 45 | msg="Seems that devtool isn't the eSDK one: %s" % output) |
| 46 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 47 | def test_devtool_add_reset(self): |
| 48 | self._run('devtool add myapp %s' % self.myapp_dst) |
| 49 | self._run('devtool reset myapp') |
| 50 | |
| 51 | @OETestID(1605) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 52 | def test_devtool_build_make(self): |
| 53 | self._test_devtool_build(self.myapp_dst) |
| 54 | |
| 55 | @OETestID(1606) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 56 | def test_devtool_build_esdk_package(self): |
| 57 | self._test_devtool_build_package(self.myapp_dst) |
| 58 | |
| 59 | @OETestID(1607) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 60 | def test_devtool_build_cmake(self): |
| 61 | self._test_devtool_build(self.myapp_cmake_dst) |
| 62 | |
| 63 | @OETestID(1608) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 64 | def test_extend_autotools_recipe_creation(self): |
| 65 | req = 'https://github.com/rdfa/librdfa' |
| 66 | recipe = "librdfa" |
| 67 | self._run('devtool sdk-install libxml2') |
| 68 | self._run('devtool add %s %s' % (recipe, req) ) |
| 69 | try: |
| 70 | self._run('devtool build %s' % recipe) |
| 71 | finally: |
| 72 | self._run('devtool reset %s' % recipe) |
| 73 | |
| 74 | @OETestID(1609) |
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 | |
| 84 | @OETestID(1610) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 85 | def test_recipes_for_nodejs(self): |
| 86 | package_nodejs = "npm://registry.npmjs.org;name=winston;version=2.2.0" |
| 87 | self._run('devtool add %s ' % package_nodejs) |
| 88 | try: |
| 89 | self._run('devtool build %s ' % package_nodejs) |
| 90 | finally: |
| 91 | self._run('devtool reset %s '% package_nodejs) |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 92 | |
| 93 | class SdkUpdateTest(OESDKExtTestCase): |
| 94 | @classmethod |
| 95 | def setUpClass(self): |
| 96 | self.publish_dir = os.path.join(self.tc.sdk_dir, 'esdk_publish') |
| 97 | if os.path.exists(self.publish_dir): |
| 98 | shutil.rmtree(self.publish_dir) |
| 99 | os.mkdir(self.publish_dir) |
| 100 | |
| 101 | base_tcname = "%s/%s" % (self.td.get("SDK_DEPLOY", ''), |
| 102 | self.td.get("TOOLCHAINEXT_OUTPUTNAME", '')) |
| 103 | tcname_new = "%s-new.sh" % base_tcname |
| 104 | if not os.path.exists(tcname_new): |
| 105 | tcname_new = "%s.sh" % base_tcname |
| 106 | |
| 107 | cmd = 'oe-publish-sdk %s %s' % (tcname_new, self.publish_dir) |
| 108 | subprocess.check_output(cmd, shell=True) |
| 109 | |
| 110 | self.http_service = HTTPService(self.publish_dir) |
| 111 | self.http_service.start() |
| 112 | |
| 113 | self.http_url = "http://127.0.0.1:%d" % self.http_service.port |
| 114 | |
| 115 | def test_sdk_update_http(self): |
| 116 | output = self._run("devtool sdk-update \"%s\"" % self.http_url) |
| 117 | |
| 118 | @classmethod |
| 119 | def tearDownClass(self): |
| 120 | self.http_service.stop() |
| 121 | shutil.rmtree(self.publish_dir) |