blob: 6771b291c4709fcba73477dd3b2c0423347edae9 [file] [log] [blame]
mbligh421a4f02008-07-16 20:38:22 +00001#!/usr/bin/python
2
3import unittest
4import common
5from autotest_lib.client.common_lib.test_utils import mock
jadmanski8d631c92008-08-18 21:12:40 +00006from autotest_lib.server import source_kernel, autotest, hosts
mbligh421a4f02008-07-16 20:38:22 +00007
8
9class TestSourceKernel(unittest.TestCase):
10 def setUp(self):
11 self.god = mock.mock_god()
jadmanski8d631c92008-08-18 21:12:40 +000012 self.host = self.god.create_mock_class(hosts.RemoteHost, "host")
mbligh421a4f02008-07-16 20:38:22 +000013 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)
17
18 # call configure to set config_file
19 self.config = "config_file"
20 self.source_kernel.configure(self.config)
21
22
23 def tearDown(self):
24 self.god.unstub_all()
25
26
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))
32
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)
37
38 # run and check
39 self.source_kernel.install(self.host)
40 self.god.check_playback()
41
42
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))
51
52 # record
53 self.host.get_tmp_dir.expect_call().and_return("tmpdir")
54 self.kernel_autotest.run.expect_call(ctlfile, "tmpdir", self.host)
55
56 # run and check
57 self.source_kernel.build(self.host)
58 self.god.check_playback()
59
60
61if __name__ == "__main__":
62 unittest.main()