summaryrefslogtreecommitdiffstats
path: root/recipes-test/virt-test/files/allow_bootstrap_3rd_party_image.patch
diff options
context:
space:
mode:
Diffstat (limited to 'recipes-test/virt-test/files/allow_bootstrap_3rd_party_image.patch')
-rw-r--r--recipes-test/virt-test/files/allow_bootstrap_3rd_party_image.patch233
1 files changed, 233 insertions, 0 deletions
diff --git a/recipes-test/virt-test/files/allow_bootstrap_3rd_party_image.patch b/recipes-test/virt-test/files/allow_bootstrap_3rd_party_image.patch
new file mode 100644
index 0000000..7e53f59
--- /dev/null
+++ b/recipes-test/virt-test/files/allow_bootstrap_3rd_party_image.patch
@@ -0,0 +1,233 @@
1virt-test: Bootstrap using other OS images.
2
3Upstream-Status: Accepted
4
5Signed-off-by: Petre Pircalabu <petre.pircalabu@enea.com>
6
7--- a/run
8+++ b/run
9@@ -10,6 +10,7 @@ import traceback
10 import signal
11 import optparse
12 import logging
13+import virttest.defaults
14
15
16 class StreamProxy(object):
17@@ -173,9 +174,8 @@ class VirtTestRunParser(optparse.OptionP
18 def __init__(self):
19 optparse.OptionParser.__init__(self, usage='Usage: %prog [options]')
20 from virttest import data_dir
21- from virttest import bootstrap
22- jeos_info = bootstrap.get_jeos_info()
23- self.default_guest_os = jeos_info['variant']
24+ os_info = virttest.defaults.get_default_guest_os_info()
25+ self.default_guest_os = os_info['variant']
26
27 try:
28 qemu_bin_path = _find_default_qemu_paths()[0]
29@@ -267,7 +267,7 @@ class VirtTestRunParser(optparse.OptionP
30 help=("Machine type under test. "
31 "If -c is provided, this will be ignored. "
32 "Default: all for the chosen guests, %s if "
33- "--guest-os not given." % DEFAULT_MACHINE_TYPE))
34+ "--guest-os not given." % virttest.defaults.DEFAULT_MACHINE_TYPE))
35 general.add_option("--tests", action="store", dest="tests",
36 default="",
37 help=('List of space separated tests to be '
38@@ -415,7 +415,6 @@ def variant_only_file(filename):
39 return ", ".join(result)
40
41
42-DEFAULT_MACHINE_TYPE = "i440fx"
43 QEMU_DEFAULT_SET = "migrate..tcp, migrate..unix, migrate..exec, migrate..fd"
44 LIBVIRT_DEFAULT_SET = variant_only_file('backends/libvirt/cfg/default_tests')
45 LVSB_DEFAULT_SET = ("lvsb_date")
46@@ -546,7 +545,7 @@ class VirtTestApp(object):
47 # TODO: this is x86-specific, instead we can get the default
48 # arch from qemu binary and run on all supported machine types
49 if self.options.arch is None and self.options.guest_os is None:
50- self.cartesian_parser.only_filter(DEFAULT_MACHINE_TYPE)
51+ self.cartesian_parser.only_filter(virttest.defaults.DEFAULT_MACHINE_TYPE)
52 else:
53 self.cartesian_parser.only_filter(self.options.machine_type)
54 else:
55@@ -827,7 +826,9 @@ class VirtTestApp(object):
56 selinux=self.options.selinux_setup,
57 restore_image=keep_image,
58 verbose=self.options.verbose,
59- update_providers=self.options.update_providers)
60+ update_providers=self.options.update_providers,
61+ guest_os=(self.options.guest_os or
62+ self.option_parser.default_guest_os))
63 sys.exit(0)
64
65 if self.options.type:
66--- a/virttest/bootstrap.py
67+++ b/virttest/bootstrap.py
68@@ -9,6 +9,7 @@ import data_dir
69 import asset
70 import cartesian_config
71 import utils_selinux
72+import defaults
73
74 basic_program_requirements = ['tcpdump', 'nc', 'ip', 'arping']
75
76@@ -53,15 +54,30 @@ last_subtest = {'qemu': ['shutdown'],
77 test_filter = ['__init__', 'cfg', 'dropin.py']
78
79
80-def get_jeos_info():
81+def get_guest_os_info_list(test_name, guest_os):
82 """
83- Gets the correct asset and variant information depending on host OS.
84+ Returns a list of matching assets compatible with the specified test name
85+ and guest OS
86 """
87- jeos_info = {'asset': 'jeos-19-64', 'variant': 'JeOS.19'}
88- issue_contents = utils.read_file('/etc/issue')
89- if 'Fedora' in issue_contents and '20' in issue_contents:
90- jeos_info = {'asset': 'jeos-20-64', 'variant': 'JeOS.20'}
91- return jeos_info
92+
93+ os_info_list = []
94+
95+ cartesian_parser = cartesian_config.Parser()
96+ cartesian_parser.parse_file(data_dir.get_backend_cfg_path(test_name, 'guest-os.cfg'))
97+ cartesian_parser.only_filter(guest_os)
98+ dicts = cartesian_parser.get_dicts();
99+
100+ for params in dicts:
101+ image_name = params.get('image_name', 'image').split('/')[-1]
102+ shortname = params.get('shortname', guest_os)
103+ os_info_list.append({'asset': image_name, 'variant': shortname})
104+
105+ if not os_info_list:
106+ logging.error("Could not find any assets compatible with %s for %s",
107+ guest_os, test_name)
108+ raise ValueError("Missing compatible assets for %s", guest_os)
109+
110+ return os_info_list
111
112
113 def _get_config_filter():
114@@ -704,7 +720,8 @@ def verify_selinux(datadir, imagesdir, i
115 def bootstrap(test_name, test_dir, base_dir, default_userspace_paths,
116 check_modules, online_docs_url, restore_image=False,
117 download_image=True, interactive=True, selinux=False,
118- verbose=False, update_providers=False):
119+ verbose=False, update_providers=False,
120+ guest_os=defaults.DEFAULT_GUEST_OS):
121 """
122 Common virt test assistant module.
123
124@@ -723,6 +740,8 @@ def bootstrap(test_name, test_dir, base_
125 :param selinux: Whether setup SELinux contexts for shared/data.
126 :param update_providers: Whether to update test providers if they are already
127 downloaded.
128+ :param guest_os: Specify the guest image used for bootstrapping. By default
129+ the JeOS image is used.
130
131 :raise error.CmdError: If JeOS image failed to uncompress
132 :raise ValueError: If 7za was not found
133@@ -790,10 +809,10 @@ def bootstrap(test_name, test_dir, base_
134 step += 2
135 logging.info("%s - Verifying (and possibly downloading) guest image",
136 step)
137- jeos_info = get_jeos_info()
138- jeos_asset = jeos_info['asset']
139- asset.download_asset(jeos_asset, interactive=interactive,
140- restore_image=restore_image)
141+ for os_info in get_guest_os_info_list(test_name, guest_os):
142+ os_asset = os_info['asset']
143+ asset.download_asset(os_asset, interactive=interactive,
144+ restore_image=restore_image)
145
146 if check_modules:
147 logging.info("")
148--- /dev/null
149+++ b/virttest/defaults.py
150@@ -0,0 +1,18 @@
151+DEFAULT_MACHINE_TYPE = "i440fx"
152+DEFAULT_GUEST_OS = "JeOS.19"
153+
154+
155+def get_default_guest_os_info():
156+ """
157+ Gets the default asset and variant information depending on host OS
158+ """
159+ os_info = {'asset': 'jeos-19-64', 'variant': DEFAULT_GUEST_OS}
160+
161+ from autotest.client import utils
162+
163+ issue_contents = utils.read_file('/etc/issue')
164+
165+ if 'Fedora' in issue_contents and '20' in issue_contents:
166+ os_info = {'asset': 'jeos-20-64', 'variant': 'JeOS.20'}
167+
168+ return os_info
169--- a/virttest/standalone_test.py
170+++ b/virttest/standalone_test.py
171@@ -24,6 +24,7 @@ import arch
172 import funcatexit
173 import version
174 import qemu_vm
175+import defaults
176
177 global GUEST_NAME_LIST
178 GUEST_NAME_LIST = None
179@@ -226,7 +227,7 @@ class Test(object):
180 % error_message)
181
182 except Exception, e:
183- if (not t_type is None):
184+ if (t_type is not None):
185 error_message = funcatexit.run_exitfuncs(env, t_type)
186 if error_message:
187 logging.error(error_message)
188@@ -306,7 +307,7 @@ class Bcolors(object):
189 allowed_terms = ['linux', 'xterm', 'xterm-256color', 'vt100',
190 'screen', 'screen-256color']
191 term = os.environ.get("TERM")
192- if (not os.isatty(1)) or (not term in allowed_terms):
193+ if (not os.isatty(1)) or (term not in allowed_terms):
194 self.disable()
195
196 def disable(self):
197@@ -392,7 +393,7 @@ def print_fail(t_elapsed, open_fd=False)
198 bcolors.ENDC + " (%.2f s)" % t_elapsed)
199 fd_fail_msg = (bcolors.FAIL + "FAIL" +
200 bcolors.ENDC + " (%.2f s) (%s fd)" %
201- (t_elapsed, utils_misc.get_virt_test_open_fds()))
202+ (t_elapsed, utils_misc.get_virt_test_open_fds()))
203 if open_fd:
204 msg = fd_fail_msg
205 else:
206@@ -667,6 +668,8 @@ def bootstrap_tests(options):
207 else:
208 restore_image = False
209
210+ os_info = defaults.get_default_guest_os_info()
211+
212 kwargs = {'test_name': options.type,
213 'test_dir': test_dir,
214 'base_dir': data_dir.get_data_dir(),
215@@ -677,7 +680,8 @@ def bootstrap_tests(options):
216 'selinux': options.selinux_setup,
217 'restore_image': restore_image,
218 'interactive': False,
219- 'update_providers': options.update_providers}
220+ 'update_providers': options.update_providers,
221+ 'guest_os': options.guest_os or os_info['variant']}
222
223 # Tolerance we have without printing a message for the user to wait (3 s)
224 tolerance = 3
225@@ -909,7 +913,7 @@ def run_tests(parser, options):
226 dependencies_satisfied = True
227 for dep in dct.get("dep"):
228 for test_name in status_dct.keys():
229- if not dep in test_name:
230+ if dep not in test_name:
231 continue
232
233 if not status_dct[test_name]: