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