blob: 750706161ba53ad72a43ab0adeaffaeb50732451 [file] [log] [blame]
Brad Bishopc342db32019-05-15 21:57:59 -04001#
2# SPDX-License-Identifier: MIT
3#
4
Brad Bishop316dfdd2018-06-25 12:45:53 -04005import os
6from oeqa.utils.httpserver import HTTPService
7from oeqa.runtime.case import OERuntimeTestCase
Brad Bishop64c979e2019-11-04 13:55:29 -05008from oeqa.core.decorator.data import skipIfNotDataVar, skipIfNotFeature, skipIfFeature
Brad Bishop316dfdd2018-06-25 12:45:53 -04009from oeqa.runtime.decorator.package import OEHasPackage
10
11class 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
20class OpkgRepoTest(OpkgTest):
21
22 @classmethod
Brad Bishop977dc1a2019-02-06 16:01:43 -050023 def setUp(cls):
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080024 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 Bishop316dfdd2018-06-25 12:45:53 -040029 cls.repo_server.start()
30
31 @classmethod
Brad Bishop977dc1a2019-02-06 16:01:43 -050032 def tearDown(cls):
Brad Bishop316dfdd2018-06-25 12:45:53 -040033 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 Bishop64c979e2019-11-04 13:55:29 -050048 @skipIfFeature('read-only-rootfs',
49 'Test does not work with read-only-rootfs in IMAGE_FEATURES')
Brad Bishop316dfdd2018-06-25 12:45:53 -040050 @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()