aboutsummaryrefslogtreecommitdiff
blob: c3efebf550291b9f707586471a48118e52a68389 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
# Copyright 2018 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

from portage.tests import TestCase
from portage.tests.resolver.ResolverPlayground import (
	ResolverPlayground,
	ResolverPlaygroundTestCase,
)

class OrUpgradeInstalledTestCase(TestCase):

	def testOrUpgradeInstalled(self):
		ebuilds = {
			'net-misc/foo-1': {
				'EAPI': '6',
				'RDEPEND': '|| ( sys-libs/glibc[rpc(-)]  net-libs/libtirpc )'
			},
			'net-libs/libtirpc-1': {
				'EAPI': '6',
			},
			'sys-libs/glibc-2.26': {
				'EAPI': '6',
				'IUSE': ''
			},
			'sys-libs/glibc-2.24': {
				'EAPI': '6',
				'IUSE': '+rpc'
			},
		}

		installed = {
			'sys-libs/glibc-2.24': {
				'EAPI': '6',
				'IUSE': '+rpc',
				'USE': 'rpc',
			},
		}

		world = ['sys-libs/glibc']

		test_cases = (
			# Test bug 643974, where we need to install libtirpc
			# in order to upgrade glibc.
			ResolverPlaygroundTestCase(
				['net-misc/foo', '@world'],
				options={'--update': True, '--deep': True},
				success=True,
				ambiguous_merge_order=True,
				mergelist=(
					(
						'net-libs/libtirpc-1',
						'sys-libs/glibc-2.26',
						'net-misc/foo-1',
					),
				)
			),
		)

		playground = ResolverPlayground(debug=False,
			ebuilds=ebuilds, installed=installed, world=world)

		try:
			for test_case in test_cases:
				playground.run_TestCase(test_case)
				self.assertEqual(test_case.test_success, True,
					test_case.fail_msg)
		finally:
			playground.debug = False
			playground.cleanup()

		# In some cases it's necessary to avoid upgrade due to
		# the package being masked.
		user_config = {
			"package.mask" : (
				">=sys-libs/glibc-2.26",
			),
		}

		test_cases = (
			ResolverPlaygroundTestCase(
				['net-misc/foo', '@world'],
				options={'--update': True, '--deep': True},
				success=True,
				mergelist=[
					'net-misc/foo-1',
				]
			),
		)

		playground = ResolverPlayground(debug=False,
			ebuilds=ebuilds, installed=installed, world=world,
			user_config=user_config)

		try:
			for test_case in test_cases:
				playground.run_TestCase(test_case)
				self.assertEqual(test_case.test_success, True,
					test_case.fail_msg)
		finally:
			playground.debug = False
			playground.cleanup()

	def testVirtualRust(self):
		ebuilds = {
			'dev-lang/rust-1.19.0': {},
			'dev-lang/rust-1.23.0': {},
			'dev-lang/rust-bin-1.19.0': {},
			'virtual/rust-1.19.0': {
				'RDEPEND': '|| ( =dev-lang/rust-1.19.0* =dev-lang/rust-bin-1.19.0* )'
			},
		}

		installed = {
			'dev-lang/rust-1.19.0': {},
			'virtual/rust-1.19.0': {
				'RDEPEND': '|| ( =dev-lang/rust-1.19.0* =dev-lang/rust-bin-1.19.0* )'
			},
		}

		world = ['virtual/rust']

		test_cases = (
			# Test bug 645416, where rust-bin-1.19.0 was pulled in
			# inappropriately due to the rust-1.23.0 update being
			# available.
			ResolverPlaygroundTestCase(
				['virtual/rust'],
				options={'--update': True, '--deep': True},
				success=True,
				mergelist=[]
			),
			# Test upgrade to rust-1.23.0, which is only possible
			# if rust-bin-1.19.0 is installed in order to satisfy
			# virtual/rust-1.19.0.
			ResolverPlaygroundTestCase(
				['=dev-lang/rust-1.23.0', 'virtual/rust'],
				options={'--update': True, '--deep': True},
				all_permutations=True,
				success=True,
				ambiguous_merge_order=True,
				mergelist=(
					(
						'dev-lang/rust-1.23.0',
						'dev-lang/rust-bin-1.19.0',
					),
				),
			),
		)

		playground = ResolverPlayground(debug=False,
			ebuilds=ebuilds, installed=installed, world=world)

		try:
			for test_case in test_cases:
				playground.run_TestCase(test_case)
				self.assertEqual(test_case.test_success, True,
					test_case.fail_msg)
		finally:
			playground.debug = False
			playground.cleanup()


	def test_llvm_slot_operator(self):
		ebuilds = {
			'media-libs/mesa-19.2.8': {
				'EAPI': '7',
				'RDEPEND': '''|| (
					sys-devel/llvm:10
					sys-devel/llvm:9
					sys-devel/llvm:8
					sys-devel/llvm:7
				)
				sys-devel/llvm:='''
			},
			'sys-devel/llvm-10': {
				'EAPI': '7',
				'KEYWORDS': '',
				'SLOT': '10',
			},
			'sys-devel/llvm-9': {
				'EAPI': '7',
				'SLOT': '9',
			},
			'sys-devel/llvm-8': {
				'EAPI': '7',
				'SLOT': '8',
			},
		}

		installed = {
			'media-libs/mesa-19.2.8': {
				'EAPI': '7',
				'RDEPEND': '''|| (
					sys-devel/llvm:10
					sys-devel/llvm:9
					sys-devel/llvm:8
					sys-devel/llvm:7
				)
				sys-devel/llvm:8/8='''
			},
			'sys-devel/llvm-8': {
				'EAPI': '7',
				'SLOT': '8',
			},
		}

		world = ['media-libs/mesa']

		test_cases = (
			# Demonstrate bug 706278, where there is a missed slot operator
			# rebuild that prevents upgrade from llvm-8 to llvm-9.
			ResolverPlaygroundTestCase(
				['@world'],
				options={'--update': True, '--deep': True},
				success=True,
				mergelist=[],
				#mergelist=['sys-devel/llvm-9'],
			),
		)

		playground = ResolverPlayground(debug=False,
			ebuilds=ebuilds, installed=installed, world=world)

		try:
			for test_case in test_cases:
				playground.run_TestCase(test_case)
				self.assertEqual(test_case.test_success, True,
					test_case.fail_msg)
		finally:
			playground.debug = False
			playground.cleanup()