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