blob: 078d9cd148a8734c50226739380c9c5728ae382e [file] [log] [blame]
jadmanskia543fb02008-09-15 14:30:25 +00001#!/usr/bin/python
2
showard4cfdce12009-06-15 20:23:29 +00003import unittest, os, time, re, glob, logging
jadmanskia543fb02008-09-15 14:30:25 +00004import common
5from autotest_lib.client.common_lib.test_utils import mock
mbligh53da18e2009-01-05 21:13:26 +00006from autotest_lib.client.bin import kernel, job, utils, kernelexpand
jadmanskia543fb02008-09-15 14:30:25 +00007from autotest_lib.client.bin import kernel_config, boottool, os_dep
8
jadmanskia543fb02008-09-15 14:30:25 +00009class TestKernel(unittest.TestCase):
10 def setUp(self):
11 self.god = mock.mock_god()
12
showard4cfdce12009-06-15 20:23:29 +000013 logging.disable(logging.CRITICAL)
14
jadmanskia543fb02008-09-15 14:30:25 +000015 self.god.stub_function(time, "time")
16 self.god.stub_function(os, "mkdir")
17 self.god.stub_function(os, "chdir")
18 self.god.stub_function(os, "symlink")
19 self.god.stub_function(os, "remove")
20 self.god.stub_function(os.path, "isdir")
21 self.god.stub_function(os.path, "exists")
22 self.god.stub_function(os.path, "isfile")
23 self.god.stub_function(os_dep, "commands")
24 self.god.stub_function(kernel, "open")
25 self.god.stub_function(utils, "system")
26 self.god.stub_function(utils, "system_output")
27 self.god.stub_function(utils, "get_file")
mbligh53da18e2009-01-05 21:13:26 +000028 self.god.stub_function(utils, "get_current_kernel_arch")
29 self.god.stub_function(utils, "cat_file_to_cmd")
30 self.god.stub_function(utils, "force_copy")
31 self.god.stub_function(utils, "extract_tarball_to_dir")
32 self.god.stub_function(utils, "count_cpus")
33 self.god.stub_function(utils, "get_os_vendor")
jadmanskia543fb02008-09-15 14:30:25 +000034 self.god.stub_function(kernelexpand, "expand_classic")
35 self.god.stub_function(kernel_config, "modules_needed")
36 self.god.stub_function(glob, "glob")
showard75cdfee2009-06-10 17:40:41 +000037 def dummy_mark(filename, msg):
38 pass
39 self.god.stub_with(kernel, '_mark', dummy_mark)
jadmanskia543fb02008-09-15 14:30:25 +000040
41 self.job = self.god.create_mock_class(job.job, "job")
42 self.job.bootloader = self.god.create_mock_class(boottool.boottool,
43 "boottool")
44
showard75cdfee2009-06-10 17:40:41 +000045 class DummyLoggingManager(object):
46 def tee_redirect_debug_dir(self, *args, **kwargs):
47 pass
48
49
50 def restore(self, *args, **kwargs):
51 pass
52
53 self.job.logging = DummyLoggingManager()
54
jadmanskia543fb02008-09-15 14:30:25 +000055 self.job.autodir = "autodir"
56 self.base_tree = "2.6.24"
57 self.tmp_dir = "tmpdir"
58 self.subdir = "subdir"
59
60
61 def tearDown(self):
62 self.god.unstub_all()
63
64
65 def construct_kernel(self):
66 self.kernel = kernel.kernel.__new__(kernel.kernel)
67 self.god.stub_function(self.kernel, "extract")
68
69 # setup
70 self.src_dir = os.path.join(self.tmp_dir, 'src')
71 self.build_dir = os.path.join(self.tmp_dir, "build_dir")
72 self.config_dir = os.path.join(self.subdir, 'config')
73 self.log_dir = os.path.join(self.subdir, 'debug')
74 self.results_dir = os.path.join(self.subdir, 'results')
75
76 # record
77 os.path.isdir.expect_call(self.src_dir).and_return(True)
78 utils.system.expect_call('rm -rf ' + self.src_dir)
79 os.path.isdir.expect_call(self.build_dir).and_return(True)
80 utils.system.expect_call('rm -rf ' + self.build_dir)
81 os.path.exists.expect_call(self.src_dir).and_return(False)
82 os.mkdir.expect_call(self.src_dir)
83 for path in [self.config_dir, self.log_dir, self.results_dir]:
84 os.path.exists.expect_call(path).and_return(True)
85 utils.system.expect_call('rm -rf ' + path)
86 os.mkdir.expect_call(path)
87
88 logpath = os.path.join(self.log_dir, 'build_log')
89 self.logfile = self.god.create_mock_class(file, "file")
90 kernel.open.expect_call(logpath, 'w+').and_return(self.logfile)
mbligh53da18e2009-01-05 21:13:26 +000091 utils.get_current_kernel_arch.expect_call().and_return('ia64')
jadmanskia543fb02008-09-15 14:30:25 +000092 self.logfile.write.expect_call('BASE: %s\n' % self.base_tree)
93 self.kernel.extract.expect_call(self.base_tree)
94
95 # finish creation of kernel object and test (and unstub extract)
96 self.kernel.__init__(self.job, self.base_tree, self.subdir,
97 self.tmp_dir, "build_dir")
98 self.god.check_playback()
99 self.god.unstub(self.kernel, "extract")
100
101
102 def test_constructor(self):
103 self.construct_kernel()
104
105
106 def test_kernelexpand1(self):
107 self.construct_kernel()
108
109 ret_val = self.kernel.kernelexpand("/path/to/kernel")
110 self.assertEquals(ret_val, ["/path/to/kernel"])
111 self.god.check_playback()
112
113
114 def test_kernel_expand2(self):
115 self.construct_kernel()
116 kernel = "kernel.tar.gz"
117
118 # record
119 self.job.config_get.expect_call('mirror.mirrors').and_return('mirror')
120 kernelexpand.expand_classic.expect_call(kernel,
121 'mirror').and_return('patches')
122
123 # run
124 self.assertEquals(self.kernel.kernelexpand(kernel), 'patches')
125 self.god.check_playback()
126
127
128 def test_kernel_expand3(self):
129 self.construct_kernel()
130 kernel = "kernel.tar.gz"
131
132 # record
133 self.job.config_get.expect_call('mirror.mirrors')
134 self.job.config_get.expect_call(
135 'mirror.ftp_kernel_org').and_return('mirror')
136 korg = 'http://www.kernel.org/pub/linux/kernel'
137 mirrors = [
138 [ korg + '/v2.6', 'mirror' + '/v2.6' ],
139 [ korg + '/people/akpm/patches/2.6', 'mirror' + '/akpm' ],
140 [ korg + '/people/mbligh', 'mirror' + '/mbligh' ],
141 ]
142 kernelexpand.expand_classic.expect_call(kernel,
143 mirrors).and_return('patches')
144
145 # run
146 self.assertEquals(self.kernel.kernelexpand(kernel), 'patches')
147 self.god.check_playback()
148
149
150 def test_extract1(self):
151 self.construct_kernel()
152
153 # setup
154 self.god.stub_function(self.kernel, "get_kernel_tree")
155
156 # record
157 os.path.exists.expect_call(self.base_tree).and_return(True)
158 self.kernel.get_kernel_tree.expect_call(self.base_tree)
159 self.job.record.expect_call('GOOD', self.subdir, 'kernel.extract')
160
161 # run
162 self.kernel.extract(self.base_tree)
163 self.god.check_playback()
164 self.god.unstub(self.kernel, "get_kernel_tree")
165
166
167 def test_extract2(self):
168 self.construct_kernel()
169
170 # setup
171 self.god.stub_function(self.kernel, "kernelexpand")
172 self.god.stub_function(self.kernel, "get_kernel_tree")
173 self.god.stub_function(self.kernel, "patch")
174
175 # record
176 os.path.exists.expect_call(self.base_tree).and_return(False)
177 components = ["component0", "component1"]
178 self.kernel.kernelexpand.expect_call(self.base_tree).and_return(
179 components)
180 self.kernel.get_kernel_tree.expect_call(components[0])
181 self.kernel.patch.expect_call(components[1])
182 self.job.record.expect_call('GOOD', self.subdir, 'kernel.extract')
183
184 # run
185 self.kernel.extract(self.base_tree)
186 self.god.check_playback()
187 self.god.unstub(self.kernel, "kernelexpand")
188 self.god.unstub(self.kernel, "get_kernel_tree")
189 self.god.unstub(self.kernel, "patch")
190
191
192 def test_patch1(self):
193 self.construct_kernel()
194 patches = ('patch1', 'patch2')
195 self.god.stub_function(self.kernel, "apply_patches")
196 self.god.stub_function(self.kernel, "get_patches")
197
198 #record
199 self.kernel.get_patches.expect_call(patches).and_return(patches)
200 self.kernel.apply_patches.expect_call(patches)
201 self.job.record.expect_call('GOOD', self.subdir, 'kernel.patch')
202
203 #run
204 self.kernel.patch(*patches)
205 self.god.check_playback()
206 self.god.unstub(self.kernel, "apply_patches")
207 self.god.unstub(self.kernel, "get_patches")
208
209
210 def test_patch2(self):
211 self.construct_kernel()
212 patches = []
213
214 # record
215 self.job.record.expect_call('GOOD', self.subdir, 'kernel.patch')
216
217 # run
218 self.kernel.patch(*patches)
219 self.god.check_playback()
220
221
222 def test_config(self):
223 self.construct_kernel()
224
225 # setup
226 self.god.stub_function(self.kernel, "set_cross_cc")
227 self.god.stub_class(kernel_config, "kernel_config")
228
229 # record
230 self.kernel.set_cross_cc.expect_call()
231 kernel_config.kernel_config.expect_new(self.job, self.build_dir,
232 self.config_dir, '', None,
jadmanski8b71d012008-11-06 16:46:41 +0000233 False, self.base_tree, None)
jadmanskia543fb02008-09-15 14:30:25 +0000234 self.job.record.expect_call('GOOD', self.subdir, 'kernel.config')
235
236 # run
237 self.kernel.config()
238 self.god.check_playback()
239 self.god.unstub(self.kernel, "set_cross_cc")
240
241
242 def test_get_patches(self):
243 self.construct_kernel()
244
245 # setup
246 patches = ['patch1', 'patch2', 'patch3']
247 local_patches = []
248
249 # record
250 for patch in patches:
251 dest = os.path.join(self.src_dir, os.path.basename(patch))
252 utils.get_file.expect_call(patch, dest)
253 utils.system_output.expect_call(
254 'md5sum ' + dest).and_return('md5sum')
255 local_patches.append((patch, dest, 'md5sum'))
256
257 # run and check
258 self.assertEquals(self.kernel.get_patches(patches), local_patches)
259 self.god.check_playback()
260
261
262 def test_apply_patches(self):
263 self.construct_kernel()
264
265 # setup
266 patches = []
267 patches.append(('patch1', 'patch1.gz', 'md5sum1'))
268 patches.append(('patch2', 'patch2.bz2', 'md5sum2'))
269 patches.append(('patch3', 'patch3', 'md5sum3'))
270 applied_patches = []
271
272 # record
273 os.chdir.expect_call(self.build_dir)
274
275 patch_id = "%s %s %s" % ('patch1', 'patch1', 'md5sum1')
276 log = "PATCH: " + patch_id + "\n"
mbligh53da18e2009-01-05 21:13:26 +0000277 utils.cat_file_to_cmd.expect_call('patch1.gz',
jadmanskia543fb02008-09-15 14:30:25 +0000278 'patch -p1 > /dev/null')
279 self.logfile.write.expect_call(log)
280 applied_patches.append(patch_id)
281
282 patch_id = "%s %s %s" % ('patch2', 'patch2', 'md5sum2')
283 log = "PATCH: " + patch_id + "\n"
mbligh53da18e2009-01-05 21:13:26 +0000284 utils.cat_file_to_cmd.expect_call('patch2.bz2',
jadmanskia543fb02008-09-15 14:30:25 +0000285 'patch -p1 > /dev/null')
286 self.logfile.write.expect_call(log)
287 applied_patches.append(patch_id)
288
mbligh53da18e2009-01-05 21:13:26 +0000289 utils.force_copy.expect_call('patch3',
jadmanskia543fb02008-09-15 14:30:25 +0000290 self.results_dir).and_return('local_patch3')
291 self.job.relative_path.expect_call('local_patch3').and_return(
292 'rel_local_patch3')
293 patch_id = "%s %s %s" % ('patch3', 'rel_local_patch3', 'md5sum3')
294 log = "PATCH: " + patch_id + "\n"
mbligh53da18e2009-01-05 21:13:26 +0000295 utils.cat_file_to_cmd.expect_call('patch3',
jadmanskia543fb02008-09-15 14:30:25 +0000296 'patch -p1 > /dev/null')
297 self.logfile.write.expect_call(log)
298 applied_patches.append(patch_id)
299
300 # run and test
301 self.kernel.apply_patches(patches)
302 self.assertEquals(self.kernel.applied_patches, applied_patches)
303 self.god.check_playback()
304
305
306 def test_get_kernel_tree1(self):
307 self.construct_kernel()
308
309 # record
310 os.path.isdir.expect_call(self.base_tree).and_return(True)
311 os.symlink.expect_call(self.base_tree, self.build_dir)
312
313 # run and check
314 self.kernel.get_kernel_tree(self.base_tree)
315 self.god.check_playback()
316
317
318 def test_get_kernel_tree2(self):
319 self.construct_kernel()
320
321 # record
322 os.path.isdir.expect_call(self.base_tree).and_return(False)
323 os.chdir.expect_call(os.path.dirname(self.src_dir))
324 tarball = os.path.join(self.src_dir, os.path.basename(self.base_tree))
325 utils.get_file.expect_call(self.base_tree, tarball)
mbligh53da18e2009-01-05 21:13:26 +0000326 utils.extract_tarball_to_dir.expect_call(tarball,
jadmanskia543fb02008-09-15 14:30:25 +0000327 self.build_dir)
328
329 # run and check
330 self.kernel.get_kernel_tree(self.base_tree)
331 self.god.check_playback()
332
333
334 def test_extraversion(self):
335 self.construct_kernel()
336 tag = "tag"
337
338 # record
339 os.chdir.expect_call(self.build_dir)
340 extraversion_sub = r's/^EXTRAVERSION =\s*\(.*\)/EXTRAVERSION = '
341 p = extraversion_sub + '\\1-%s/' % tag
342 utils.system.expect_call('mv Makefile Makefile.old')
343 utils.system.expect_call('sed "%s" < Makefile.old > Makefile' % p)
344
345 # run and check
346 self.kernel.extraversion(tag)
347 self.god.check_playback()
348
349
350 def test_build(self):
351 self.construct_kernel()
352 self.god.stub_function(self.kernel, "extraversion")
353 self.god.stub_function(self.kernel, "set_cross_cc")
354 self.god.stub_function(self.kernel, "get_kernel_build_ver")
355 self.kernel.build_target = 'build_target'
356
357 # record
358 os_dep.commands.expect_call('gcc', 'make')
359 logfile = os.path.join(self.log_dir, 'kernel_build')
360 os.chdir.expect_call(self.build_dir)
361 self.kernel.extraversion.expect_call('autotest')
362 self.kernel.set_cross_cc.expect_call()
363 utils.system.expect_call('make dep', ignore_status=True)
mbligh53da18e2009-01-05 21:13:26 +0000364 utils.count_cpus.expect_call().and_return(4)
jadmanskia543fb02008-09-15 14:30:25 +0000365 threads = 2 * 4
366 build_string = 'make -j %d %s %s' % (threads, '', 'build_target')
367 utils.system.expect_call(build_string)
368 kernel_config.modules_needed.expect_call('.config').and_return(True)
369 utils.system.expect_call('make -j %d modules' % (threads))
370 self.kernel.get_kernel_build_ver.expect_call().and_return('2.6.24')
371 kernel_version = re.sub('-autotest', '', '2.6.24')
372 self.logfile.write.expect_call('BUILD VERSION: %s\n' % kernel_version)
mbligh53da18e2009-01-05 21:13:26 +0000373 utils.force_copy.expect_call(self.build_dir+'/System.map',
jadmanskia543fb02008-09-15 14:30:25 +0000374 self.results_dir)
375 self.job.record.expect_call('GOOD', self.subdir, 'kernel.build')
376
377 # run and check
378 self.kernel.build()
379 self.god.check_playback()
380
381
382 def test_build_timed(self):
383 self.construct_kernel()
384 self.god.stub_function(self.kernel, "set_cross_cc")
385 self.god.stub_function(self.kernel, "clean")
386
387 # record
388 os.chdir.expect_call(self.build_dir)
389 self.kernel.set_cross_cc.expect_call()
390 self.kernel.clean.expect_call(logged=False)
391 build_string = "/usr/bin/time -o /dev/null make -j 8 vmlinux"
392 build_string += ' > /dev/null 2>&1'
393 utils.system.expect_call(build_string)
394 os.path.isfile.expect_call('vmlinux').and_return(True)
395
396 # run and check
397 self.kernel.build_timed(threads=8)
398 self.god.check_playback()
399
400
401 def test_clean(self):
402 self.construct_kernel()
403
404 # record
405 os.chdir.expect_call(self.build_dir)
406 utils.system.expect_call('make clean > /dev/null 2> /dev/null')
407 self.job.record.expect_call('GOOD', self.subdir, 'kernel.clean')
408
409 # run and check
410 self.kernel.clean()
411 self.god.check_playback()
412
413
414 def test_mkinitrd(self):
415 self.construct_kernel()
416
417 # record
mbligh53da18e2009-01-05 21:13:26 +0000418 utils.get_os_vendor.expect_call().and_return('Ubuntu')
jadmanskia543fb02008-09-15 14:30:25 +0000419 os.path.isfile.expect_call('initrd').and_return(True)
420 os.remove.expect_call('initrd')
421 self.job.config_get.expect_call(
422 'kernel.mkinitrd_extra_args').and_return(None)
423 args = ''
424 os.path.isfile.expect_call('/usr/sbin/mkinitrd').and_return(True)
425 cmd = '/usr/sbin/mkinitrd'
426 utils.system.expect_call('%s %s -o initrd 2.6.24' % (cmd, args))
427 self.job.record.expect_call('GOOD', self.subdir, 'kernel.mkinitrd')
428
429 # run and check
430 self.kernel.mkinitrd(version="2.6.24", image="image",
431 system_map="system_map", initrd="initrd")
432 self.god.check_playback()
433
434
435 def test_install(self):
436 self.construct_kernel()
437 tag = 'autotest'
438 prefix = '/'
439 self.kernel.build_image = None
440 self.kernel.build_target = 'build_target'
441 self.god.stub_function(self.kernel, "get_kernel_build_ver")
442 self.god.stub_function(self.kernel, "mkinitrd")
443
444 # record
445 os.chdir.expect_call(self.build_dir)
446 os.path.isdir.expect_call(prefix).and_return(False)
447 os.mkdir.expect_call(prefix)
448 boot_dir = os.path.join(prefix, 'boot')
449 os.path.isdir.expect_call(boot_dir).and_return(False)
450 os.mkdir.expect_call(boot_dir)
451 glob.glob.expect_call(
452 'arch/*/boot/' + 'build_target').and_return('')
453 build_image = self.kernel.build_target
mbligh53da18e2009-01-05 21:13:26 +0000454 utils.force_copy.expect_call('vmlinux',
jadmanskia543fb02008-09-15 14:30:25 +0000455 '/boot/vmlinux-autotest')
mbligh53da18e2009-01-05 21:13:26 +0000456 utils.force_copy.expect_call('build_target',
jadmanskia543fb02008-09-15 14:30:25 +0000457 '/boot/vmlinuz-autotest')
mbligh53da18e2009-01-05 21:13:26 +0000458 utils.force_copy.expect_call('System.map',
jadmanskia543fb02008-09-15 14:30:25 +0000459 '/boot/System.map-autotest')
mbligh53da18e2009-01-05 21:13:26 +0000460 utils.force_copy.expect_call('.config',
jadmanskia543fb02008-09-15 14:30:25 +0000461 '/boot/config-autotest')
462 kernel_config.modules_needed.expect_call('.config').and_return(True)
463 utils.system.expect_call('make modules_install INSTALL_MOD_PATH=%s'
464 % prefix)
465 initrd = boot_dir + '/initrd-' + tag
466 self.kernel.get_kernel_build_ver.expect_call().and_return('2.6.24')
467 self.kernel.mkinitrd.expect_call('2.6.24', '/boot/vmlinuz-autotest',
468 '/boot/System.map-autotest', '/boot/initrd-autotest')
469 self.job.record.expect_call('GOOD', self.subdir, 'kernel.install')
470
471 # run and check
472 self.kernel.install()
473 self.god.check_playback()
474
475
476 def test_add_to_bootloader(self):
477 self.construct_kernel()
478
479 # setup
480 tag = 'autotest'
481 args = ''
482 self.kernel.image = "image"
483 self.kernel.initrd = "initrd"
484
485 # record
486 self.job.bootloader.remove_kernel.expect_call(tag)
487 self.job.config_get.expect_call(
488 'boot.default_args').and_return('baseargs')
489 args = 'baseargs' + " " + args
mblighc2ebea02009-10-02 00:02:33 +0000490 self.job.bootloader.add_kernel.expect_call(
491 'image', 'autotest', initrd='initrd', args='baseargs',
492 root=None)
jadmanskia543fb02008-09-15 14:30:25 +0000493
494 # run and check
495 self.kernel.add_to_bootloader()
496 self.god.check_playback()
497
498
499 def test_get_kernel_build_arch1(self):
500 self.construct_kernel()
501
502 # record
mbligh53da18e2009-01-05 21:13:26 +0000503 utils.get_current_kernel_arch.expect_call().and_return("i386")
jadmanskia543fb02008-09-15 14:30:25 +0000504
505 # run and check
506 self.assertEquals(self.kernel.get_kernel_build_arch(), "i386")
507 self.god.check_playback()
508
509
510 def test_get_kernel_build_arch2(self):
511 self.construct_kernel()
512
513 # run and check
514 self.assertEquals(self.kernel.get_kernel_build_arch('i586'), "i386")
515 self.god.check_playback()
516
517
518 def test_get_kernel_build_release(self):
519 self.construct_kernel()
520 mock_file = self.god.create_mock_class(file, "file")
521
522 # record
523 for f in [self.build_dir + "/include/linux/version.h",
524 self.build_dir + "/include/linux/utsrelease.h"]:
525 os.path.exists.expect_call(f).and_return(True)
526 kernel.open.expect_call(f, 'r').and_return(mock_file)
527 mock_file.readlines.expect_call().and_return("Some lines")
528 mock_file.close.expect_call()
529
showard1104cd12009-11-13 20:45:10 +0000530 for f in [self.build_dir + "/include/linux/compile.h",
531 self.build_dir + "/include/generated/utsrelease.h",
532 self.build_dir + "/include/generated/compile.h"]:
533 os.path.exists.expect_call(f).and_return(False)
jadmanskia543fb02008-09-15 14:30:25 +0000534
535 # run and test
536 self.kernel.get_kernel_build_release()
537 self.god.check_playback()
538
539
540 def test_get_kernel_build_ident(self):
541 self.construct_kernel()
542 self.god.stub_function(self.kernel, "get_kernel_build_release")
543
544 # record
545 self.kernel.get_kernel_build_release.expect_call().and_return(
546 ("AwesomeRelease", "1.0"))
547
548 # run and check
549 self.assertEquals(self.kernel.get_kernel_build_ident(),
550 "AwesomeRelease::1.0")
551 self.god.check_playback()
552
553
554 def test_boot(self):
555 self.construct_kernel()
556 self.god.stub_function(self.kernel, "get_kernel_build_ident")
557 self.god.stub_function(self.kernel, "install")
558 self.god.stub_function(self.kernel, "add_to_bootloader")
559 self.kernel.applied_patches = "applied_patches"
560 when = 1
561 args = ''
562 self.kernel.installed_as = False
563
564 # record
jadmanskia543fb02008-09-15 14:30:25 +0000565 self.kernel.get_kernel_build_ident.expect_call().and_return("ident")
jadmanski067b26c2008-09-25 19:46:56 +0000566 time.time.expect_call().and_return(when)
jadmanskia543fb02008-09-15 14:30:25 +0000567 args += " IDENT=%d" % (when)
jadmanski067b26c2008-09-25 19:46:56 +0000568 self.job.next_step_prepend.expect_call(["job.end_reboot_and_verify",
jadmanskia543fb02008-09-15 14:30:25 +0000569 when, "ident", self.subdir, self.kernel.applied_patches])
570 self.kernel.install.expect_call()
571 self.kernel.add_to_bootloader.expect_call(args=args,
572 tag=False)
jadmanski02c0e452008-10-21 16:33:44 +0000573 self.job.start_reboot.expect_call()
jadmanskia543fb02008-09-15 14:30:25 +0000574 self.job.reboot.expect_call(tag=False)
575
576 # run and check
577 self.kernel.boot()
578 self.god.check_playback()
579
580
jadmanski067b26c2008-09-25 19:46:56 +0000581 def test_boot_without_ident(self):
582 self.construct_kernel()
583 self.god.stub_function(self.kernel, "get_kernel_build_ident")
584 self.god.stub_function(self.kernel, "install")
585 self.god.stub_function(self.kernel, "add_to_bootloader")
586 self.kernel.applied_patches = "applied_patches"
587 when = 1
588 args = ''
589 self.kernel.installed_as = False
590
591 # record
592 self.kernel.get_kernel_build_ident.expect_call().and_return("ident")
593 self.job.next_step_prepend.expect_call(["job.end_reboot",
594 self.subdir, "ident", self.kernel.applied_patches])
595 self.kernel.install.expect_call()
596 self.kernel.add_to_bootloader.expect_call(args=args,
597 tag=False)
jadmanski02c0e452008-10-21 16:33:44 +0000598 self.job.start_reboot.expect_call()
jadmanski067b26c2008-09-25 19:46:56 +0000599 self.job.reboot.expect_call(tag=False)
600
601 # run and check
602 self.kernel.boot(ident=False)
603 self.god.check_playback()
604
605
jadmanskia543fb02008-09-15 14:30:25 +0000606if __name__ == "__main__":
607 unittest.main()