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