devtool.py 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. # Copyright (C) 2016 Intel Corporation
  2. # Released under the MIT license (see COPYING.MIT)
  3. import os
  4. import shutil
  5. import subprocess
  6. from oeqa.sdkext.case import OESDKExtTestCase
  7. from oeqa.utils.httpserver import HTTPService
  8. from oeqa.utils.subprocesstweak import errors_have_output
  9. errors_have_output()
  10. class DevtoolTest(OESDKExtTestCase):
  11. @classmethod
  12. def setUpClass(cls):
  13. myapp_src = os.path.join(cls.tc.esdk_files_dir, "myapp")
  14. cls.myapp_dst = os.path.join(cls.tc.sdk_dir, "myapp")
  15. shutil.copytree(myapp_src, cls.myapp_dst)
  16. myapp_cmake_src = os.path.join(cls.tc.esdk_files_dir, "myapp_cmake")
  17. cls.myapp_cmake_dst = os.path.join(cls.tc.sdk_dir, "myapp_cmake")
  18. shutil.copytree(myapp_cmake_src, cls.myapp_cmake_dst)
  19. @classmethod
  20. def tearDownClass(cls):
  21. shutil.rmtree(cls.myapp_dst)
  22. shutil.rmtree(cls.myapp_cmake_dst)
  23. def _test_devtool_build(self, directory):
  24. self._run('devtool add myapp %s' % directory)
  25. try:
  26. self._run('devtool build myapp')
  27. finally:
  28. self._run('devtool reset myapp')
  29. def _test_devtool_build_package(self, directory):
  30. self._run('devtool add myapp %s' % directory)
  31. try:
  32. self._run('devtool package myapp')
  33. finally:
  34. self._run('devtool reset myapp')
  35. def test_devtool_location(self):
  36. output = self._run('which devtool')
  37. self.assertEqual(output.startswith(self.tc.sdk_dir), True, \
  38. msg="Seems that devtool isn't the eSDK one: %s" % output)
  39. def test_devtool_add_reset(self):
  40. self._run('devtool add myapp %s' % self.myapp_dst)
  41. self._run('devtool reset myapp')
  42. def test_devtool_build_make(self):
  43. self._test_devtool_build(self.myapp_dst)
  44. def test_devtool_build_esdk_package(self):
  45. self._test_devtool_build_package(self.myapp_dst)
  46. def test_devtool_build_cmake(self):
  47. self._test_devtool_build(self.myapp_cmake_dst)
  48. def test_extend_autotools_recipe_creation(self):
  49. req = 'https://github.com/rdfa/librdfa'
  50. recipe = "librdfa"
  51. self._run('devtool sdk-install libxml2')
  52. self._run('devtool add %s %s' % (recipe, req) )
  53. try:
  54. self._run('devtool build %s' % recipe)
  55. finally:
  56. self._run('devtool reset %s' % recipe)
  57. def test_devtool_kernelmodule(self):
  58. docfile = 'https://github.com/umlaeute/v4l2loopback.git'
  59. recipe = 'v4l2loopback-driver'
  60. self._run('devtool add %s %s' % (recipe, docfile) )
  61. try:
  62. self._run('devtool build %s' % recipe)
  63. finally:
  64. self._run('devtool reset %s' % recipe)
  65. def test_recipes_for_nodejs(self):
  66. package_nodejs = "npm://registry.npmjs.org;name=winston;version=2.2.0"
  67. self._run('devtool add %s ' % package_nodejs)
  68. try:
  69. self._run('devtool build %s ' % package_nodejs)
  70. finally:
  71. self._run('devtool reset %s '% package_nodejs)
  72. class SdkUpdateTest(OESDKExtTestCase):
  73. @classmethod
  74. def setUpClass(self):
  75. self.publish_dir = os.path.join(self.tc.sdk_dir, 'esdk_publish')
  76. if os.path.exists(self.publish_dir):
  77. shutil.rmtree(self.publish_dir)
  78. os.mkdir(self.publish_dir)
  79. base_tcname = "%s/%s" % (self.td.get("SDK_DEPLOY", ''),
  80. self.td.get("TOOLCHAINEXT_OUTPUTNAME", ''))
  81. tcname_new = "%s-new.sh" % base_tcname
  82. if not os.path.exists(tcname_new):
  83. tcname_new = "%s.sh" % base_tcname
  84. cmd = 'oe-publish-sdk %s %s' % (tcname_new, self.publish_dir)
  85. subprocess.check_output(cmd, shell=True)
  86. self.http_service = HTTPService(self.publish_dir)
  87. self.http_service.start()
  88. self.http_url = "http://127.0.0.1:%d" % self.http_service.port
  89. def test_sdk_update_http(self):
  90. output = self._run("devtool sdk-update \"%s\"" % self.http_url)
  91. @classmethod
  92. def tearDownClass(self):
  93. self.http_service.stop()
  94. shutil.rmtree(self.publish_dir)