blob: 793143f72cfcbcc932164d8a83588382a6329f45 [file] [log] [blame]
Brad Bishop316dfdd2018-06-25 12:45:53 -04001import os
2from oeqa.utils.httpserver import HTTPService
3from oeqa.runtime.case import OERuntimeTestCase
4from oeqa.core.decorator.data import skipIfNotDataVar, skipIfNotFeature
5from oeqa.runtime.decorator.package import OEHasPackage
6
7class AptTest(OERuntimeTestCase):
8
9 def pkg(self, command, expected = 0):
10 command = 'apt-get %s' % command
11 status, output = self.target.run(command, 1500)
12 message = os.linesep.join([command, output])
13 self.assertEqual(status, expected, message)
14 return output
15
16class AptRepoTest(AptTest):
17
18 @classmethod
19 def setUpClass(cls):
20 service_repo = os.path.join(cls.tc.td['DEPLOY_DIR_DEB'], 'all')
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080021 cls.repo_server = HTTPService(service_repo, cls.tc.target.server_ip, logger=cls.tc.logger)
Brad Bishop316dfdd2018-06-25 12:45:53 -040022 cls.repo_server.start()
23
24 @classmethod
25 def tearDownClass(cls):
26 cls.repo_server.stop()
27
28 def setup_source_config_for_package_install(self):
29 apt_get_source_server = 'http://%s:%s/' % (self.tc.target.server_ip, self.repo_server.port)
30 apt_get_sourceslist_dir = '/etc/apt/'
31 self.target.run('cd %s; echo deb %s ./ > sources.list' % (apt_get_sourceslist_dir, apt_get_source_server))
32
33 def cleanup_source_config_for_package_install(self):
34 apt_get_sourceslist_dir = '/etc/apt/'
35 self.target.run('cd %s; rm sources.list' % (apt_get_sourceslist_dir))
36
37 @skipIfNotFeature('package-management',
38 'Test requires package-management to be in IMAGE_FEATURES')
39 @skipIfNotDataVar('IMAGE_PKGTYPE', 'deb',
40 'DEB is not the primary package manager')
41 @OEHasPackage(['apt'])
42 def test_apt_install_from_repo(self):
43 self.setup_source_config_for_package_install()
44 self.pkg('update')
45 self.pkg('remove --yes run-postinsts-dev')
46 self.pkg('install --yes --allow-unauthenticated run-postinsts-dev')
47 self.cleanup_source_config_for_package_install()