base_job.py: Make TAPReport() work on python 2.4
[autotest-zwu.git] / server / source_kernel_unittest.py
blob6771b291c4709fcba73477dd3b2c0423347edae9
1 #!/usr/bin/python
3 import unittest
4 import common
5 from autotest_lib.client.common_lib.test_utils import mock
6 from autotest_lib.server import source_kernel, autotest, hosts
9 class TestSourceKernel(unittest.TestCase):
10 def setUp(self):
11 self.god = mock.mock_god()
12 self.host = self.god.create_mock_class(hosts.RemoteHost, "host")
13 self.god.stub_class(source_kernel.autotest, "Autotest")
14 self.kernel_autotest = source_kernel.autotest.Autotest.expect_new()
15 self.k = "kernel"
16 self.source_kernel = source_kernel.SourceKernel(self.k)
18 # call configure to set config_file
19 self.config = "config_file"
20 self.source_kernel.configure(self.config)
23 def tearDown(self):
24 self.god.unstub_all()
27 def test_install(self):
28 # setup
29 ctlfile = ("testkernel = job.kernel('%s')\n"
30 "testkernel.install()\n"
31 "testkernel.add_to_bootloader()\n" %(self.k))
33 # record
34 self.kernel_autotest.install.expect_call(self.host)
35 self.host.get_tmp_dir.expect_call().and_return("tmpdir")
36 self.kernel_autotest.run.expect_call(ctlfile, "tmpdir", self.host)
38 # run and check
39 self.source_kernel.install(self.host)
40 self.god.check_playback()
43 def test_build(self):
44 # setup
45 patches = "patches"
46 self.source_kernel.patch(patches)
47 ctlfile = ("testkernel = job.kernel('%s')\n"
48 "testkernel.patch('%s')\n"
49 "testkernel.config('%s')\n"
50 "testkernel.build()\n" % (self.k, patches, self.config))
52 # record
53 self.host.get_tmp_dir.expect_call().and_return("tmpdir")
54 self.kernel_autotest.run.expect_call(ctlfile, "tmpdir", self.host)
56 # run and check
57 self.source_kernel.build(self.host)
58 self.god.check_playback()
61 if __name__ == "__main__":
62 unittest.main()