blob: 74a940d80f9dc5098c8c12dccb1730e85c5dc8be [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
8from oeqa.core.decorator.data import skipIfNotDataVar, skipIfNotFeature
9from oeqa.runtime.decorator.package import OEHasPackage
10
11class AptTest(OERuntimeTestCase):
12
13 def pkg(self, command, expected = 0):
14 command = 'apt-get %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 AptRepoTest(AptTest):
21
22 @classmethod
23 def setUpClass(cls):
24 service_repo = os.path.join(cls.tc.td['DEPLOY_DIR_DEB'], 'all')
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080025 cls.repo_server = HTTPService(service_repo, cls.tc.target.server_ip, logger=cls.tc.logger)
Brad Bishop316dfdd2018-06-25 12:45:53 -040026 cls.repo_server.start()
27
28 @classmethod
29 def tearDownClass(cls):
30 cls.repo_server.stop()
31
32 def setup_source_config_for_package_install(self):
33 apt_get_source_server = 'http://%s:%s/' % (self.tc.target.server_ip, self.repo_server.port)
34 apt_get_sourceslist_dir = '/etc/apt/'
35 self.target.run('cd %s; echo deb %s ./ > sources.list' % (apt_get_sourceslist_dir, apt_get_source_server))
36
37 def cleanup_source_config_for_package_install(self):
38 apt_get_sourceslist_dir = '/etc/apt/'
39 self.target.run('cd %s; rm sources.list' % (apt_get_sourceslist_dir))
40
41 @skipIfNotFeature('package-management',
42 'Test requires package-management to be in IMAGE_FEATURES')
43 @skipIfNotDataVar('IMAGE_PKGTYPE', 'deb',
44 'DEB is not the primary package manager')
45 @OEHasPackage(['apt'])
46 def test_apt_install_from_repo(self):
47 self.setup_source_config_for_package_install()
48 self.pkg('update')
49 self.pkg('remove --yes run-postinsts-dev')
50 self.pkg('install --yes --allow-unauthenticated run-postinsts-dev')
51 self.cleanup_source_config_for_package_install()