opkg.py 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #
  2. # SPDX-License-Identifier: MIT
  3. #
  4. import os
  5. from oeqa.utils.httpserver import HTTPService
  6. from oeqa.runtime.case import OERuntimeTestCase
  7. from oeqa.core.decorator.data import skipIfNotDataVar, skipIfNotFeature
  8. from oeqa.runtime.decorator.package import OEHasPackage
  9. class OpkgTest(OERuntimeTestCase):
  10. def pkg(self, command, expected = 0):
  11. command = 'opkg %s' % command
  12. status, output = self.target.run(command, 1500)
  13. message = os.linesep.join([command, output])
  14. self.assertEqual(status, expected, message)
  15. return output
  16. class OpkgRepoTest(OpkgTest):
  17. @classmethod
  18. def setUp(cls):
  19. allarchfeed = 'all'
  20. if cls.tc.td["MULTILIB_VARIANTS"]:
  21. allarchfeed = cls.tc.td["TUNE_PKGARCH"]
  22. service_repo = os.path.join(cls.tc.td['DEPLOY_DIR_IPK'], allarchfeed)
  23. cls.repo_server = HTTPService(service_repo, cls.tc.target.server_ip, logger=cls.tc.logger)
  24. cls.repo_server.start()
  25. @classmethod
  26. def tearDown(cls):
  27. cls.repo_server.stop()
  28. def setup_source_config_for_package_install(self):
  29. apt_get_source_server = 'http://%s:%s/' % (self.tc.target.server_ip, self.repo_server.port)
  30. apt_get_sourceslist_dir = '/etc/opkg/'
  31. self.target.run('cd %s; echo src/gz all %s >> opkg.conf' % (apt_get_sourceslist_dir, apt_get_source_server))
  32. def cleanup_source_config_for_package_install(self):
  33. apt_get_sourceslist_dir = '/etc/opkg/'
  34. self.target.run('cd %s; sed -i "/^src/d" opkg.conf' % (apt_get_sourceslist_dir))
  35. @skipIfNotFeature('package-management',
  36. 'Test requires package-management to be in IMAGE_FEATURES')
  37. @skipIfNotDataVar('IMAGE_PKGTYPE', 'ipk',
  38. 'IPK is not the primary package manager')
  39. @OEHasPackage(['opkg'])
  40. def test_opkg_install_from_repo(self):
  41. self.setup_source_config_for_package_install()
  42. self.pkg('update')
  43. self.pkg('remove run-postinsts-dev')
  44. self.pkg('install run-postinsts-dev')
  45. self.cleanup_source_config_for_package_install()