forked from autotest/autotest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsource_kernel_unittest.py
executable file
·65 lines (49 loc) · 1.95 KB
/
source_kernel_unittest.py
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
#!/usr/bin/python
import unittest
try:
import autotest.common as common
except ImportError:
import common
from autotest.client.shared.test_utils import mock
from autotest.server import source_kernel, hosts
class TestSourceKernel(unittest.TestCase):
def setUp(self):
self.god = mock.mock_god()
self.host = self.god.create_mock_class(hosts.RemoteHost, "host")
self.god.stub_class(source_kernel.autotest_remote, "Autotest")
self.kernel_autotest = source_kernel.autotest_remote.Autotest.expect_new()
self.k = "kernel"
self.source_kernel = source_kernel.SourceKernel(self.k)
# call configure to set config_file
self.config = "config_file"
self.source_kernel.configure(self.config)
def tearDown(self):
self.god.unstub_all()
def test_install(self):
# setup
ctlfile = ("testkernel = job.kernel('%s')\n"
"testkernel.install()\n"
"testkernel.add_to_bootloader()\n" %(self.k))
# record
self.kernel_autotest.install.expect_call(self.host)
self.host.get_tmp_dir.expect_call().and_return("tmpdir")
self.kernel_autotest.run.expect_call(ctlfile, "tmpdir", self.host)
# run and check
self.source_kernel.install(self.host)
self.god.check_playback()
def test_build(self):
# setup
patches = "patches"
self.source_kernel.patch(patches)
ctlfile = ("testkernel = job.kernel('%s')\n"
"testkernel.patch('%s')\n"
"testkernel.config('%s')\n"
"testkernel.build()\n" % (self.k, patches, self.config))
# record
self.host.get_tmp_dir.expect_call().and_return("tmpdir")
self.kernel_autotest.run.expect_call(ctlfile, "tmpdir", self.host)
# run and check
self.source_kernel.build(self.host)
self.god.check_playback()
if __name__ == "__main__":
unittest.main()