blob: a29c93e59a2d68195a751f80f4b8588eb838c2d7 [file] [log] [blame]
Brad Bishopc342db32019-05-15 21:57:59 -04001#
Patrick Williams92b42cb2022-09-03 06:53:57 -05002# Copyright OpenEmbedded Contributors
3#
Brad Bishopc342db32019-05-15 21:57:59 -04004# SPDX-License-Identifier: MIT
5#
6
Brad Bishop316dfdd2018-06-25 12:45:53 -04007import os
8from oeqa.utils.httpserver import HTTPService
9from oeqa.runtime.case import OERuntimeTestCase
Brad Bishop64c979e2019-11-04 13:55:29 -050010from oeqa.core.decorator.data import skipIfNotDataVar, skipIfNotFeature, skipIfFeature
Brad Bishop316dfdd2018-06-25 12:45:53 -040011from oeqa.runtime.decorator.package import OEHasPackage
12
13class 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
22class OpkgRepoTest(OpkgTest):
23
24 @classmethod
Brad Bishop977dc1a2019-02-06 16:01:43 -050025 def setUp(cls):
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080026 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 Geissler82c905d2020-04-13 13:39:40 -050030 cls.repo_server = HTTPService(service_repo,
31 '0.0.0.0', port=cls.tc.target.server_port,
32 logger=cls.tc.logger)
Brad Bishop316dfdd2018-06-25 12:45:53 -040033 cls.repo_server.start()
34
35 @classmethod
Brad Bishop977dc1a2019-02-06 16:01:43 -050036 def tearDown(cls):
Brad Bishop316dfdd2018-06-25 12:45:53 -040037 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 Bishop64c979e2019-11-04 13:55:29 -050052 @skipIfFeature('read-only-rootfs',
53 'Test does not work with read-only-rootfs in IMAGE_FEATURES')
Brad Bishop316dfdd2018-06-25 12:45:53 -040054 @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()