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