blob: 9cfee1cd886526ec913f0f35cdcf6c47caa05c5d [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)
Andrew Geissler82c905d2020-04-13 13:39:40 -050028 cls.repo_server = HTTPService(service_repo,
29 '0.0.0.0', port=cls.tc.target.server_port,
30 logger=cls.tc.logger)
Brad Bishop316dfdd2018-06-25 12:45:53 -040031 cls.repo_server.start()
32
33 @classmethod
Brad Bishop977dc1a2019-02-06 16:01:43 -050034 def tearDown(cls):
Brad Bishop316dfdd2018-06-25 12:45:53 -040035 cls.repo_server.stop()
36
37 def setup_source_config_for_package_install(self):
38 apt_get_source_server = 'http://%s:%s/' % (self.tc.target.server_ip, self.repo_server.port)
39 apt_get_sourceslist_dir = '/etc/opkg/'
40 self.target.run('cd %s; echo src/gz all %s >> opkg.conf' % (apt_get_sourceslist_dir, apt_get_source_server))
41
42 def cleanup_source_config_for_package_install(self):
43 apt_get_sourceslist_dir = '/etc/opkg/'
44 self.target.run('cd %s; sed -i "/^src/d" opkg.conf' % (apt_get_sourceslist_dir))
45
46 @skipIfNotFeature('package-management',
47 'Test requires package-management to be in IMAGE_FEATURES')
48 @skipIfNotDataVar('IMAGE_PKGTYPE', 'ipk',
49 'IPK is not the primary package manager')
Brad Bishop64c979e2019-11-04 13:55:29 -050050 @skipIfFeature('read-only-rootfs',
51 'Test does not work with read-only-rootfs in IMAGE_FEATURES')
Brad Bishop316dfdd2018-06-25 12:45:53 -040052 @OEHasPackage(['opkg'])
53 def test_opkg_install_from_repo(self):
54 self.setup_source_config_for_package_install()
55 self.pkg('update')
56 self.pkg('remove run-postinsts-dev')
57 self.pkg('install run-postinsts-dev')
58 self.cleanup_source_config_for_package_install()