2
# Chris Lumens <clumens@redhat.com>
4
# Copyright 2009-2014 Red Hat, Inc.
6
# This copyrighted material is made available to anyone wishing to use, modify,
7
# copy, or redistribute it subject to the terms and conditions of the GNU
8
# General Public License v.2. This program is distributed in the hope that it
9
# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10
# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
# See the GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License along with
14
# this program; if not, write to the Free Software Foundation, Inc., 51
15
# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16
# trademarks that are incorporated in the source code or documentation are not
17
# subject to the GNU General Public License and may only be used or replicated
18
# with the express permission of Red Hat, Inc.
21
from tests.baseclass import *
23
from pykickstart.errors import *
25
class FC3_TestCase(CommandTest):
26
command = "bootloader"
28
def runTest(self, iscrypted=False):
29
if "--linear" in self.optionList:
35
self.assert_parse("bootloader --append=rhgb","bootloader --append=\"rhgb\" %s--location=mbr\n" % linear)
36
self.assert_parse("bootloader --append=\"rhgb quiet\"", "bootloader --append=\"rhgb quiet\" %s--location=mbr\n" % linear)
37
self.assert_parse("bootloader", "bootloader %s--location=mbr\n" % linear)
39
if "--linear" in self.optionList and "--nolinear" in self.optionList:
40
self.assert_parse("bootloader --nolinear", "bootloader --location=mbr\n")
41
self.assert_parse("bootloader --nolinear --linear", "bootloader --linear --location=mbr\n")
42
self.assert_parse("bootloader --linear --nolinear", "bootloader --location=mbr\n")
44
for loc in ["mbr", "partition", "none", "boot"]:
45
self.assert_parse("bootloader --location=%s" % loc, "bootloader %s--location=%s\n" % (linear, loc))
47
if "--lba32" in self.optionList:
48
self.assert_parse("bootloader --lba32", "bootloader %s--location=mbr --lba32\n" % linear)
50
self.assert_parse("bootloader --password=blahblah", "bootloader %s--location=mbr --password=\"blahblah\"\n" % linear)
52
self.assert_parse("bootloader --md5pass=blahblah", "bootloader %s--location=mbr --md5pass=\"blahblah\"\n" % linear)
53
self.assert_parse("bootloader --upgrade", "bootloader %s--location=mbr --upgrade\n" % linear)
54
self.assert_parse("bootloader --driveorder=hda,sdb", "bootloader %s--location=mbr --driveorder=\"hda,sdb\"\n" % linear)
56
if "--useLilo" in self.optionList:
57
self.assert_parse("bootloader --useLilo", "bootloader %s--location=mbr --useLilo\n" % linear)
58
self.assert_parse("lilo")
61
self.assert_parse_error("bootloader --append", KickstartParseError)
62
self.assert_parse_error("bootloader --location=nowhere", KickstartParseError)
63
self.assert_parse_error("bootloader --password", KickstartParseError)
64
self.assert_parse_error("bootloader --md5pass", KickstartParseError)
65
self.assert_parse_error("bootloader --driveorder", KickstartParseError)
67
class FC4_TestCase(FC3_TestCase):
68
def runTest(self, iscrypted=False):
70
FC3_TestCase.runTest(self, iscrypted)
72
# Ensure these options have been removed.
73
self.assert_removed("bootloader", "--linear")
74
self.assert_removed("bootloader", "--nolinear")
75
self.assert_removed("bootloader", "--useLilo")
77
class F8_TestCase(FC4_TestCase):
78
def runTest(self, iscrypted=False):
80
FC4_TestCase.runTest(self, iscrypted)
83
self.assert_parse("bootloader --timeout 47", "bootloader --location=mbr --timeout=47\n")
84
self.assert_parse("bootloader --default=this", "bootloader --location=mbr --default=this\n")
87
self.assert_parse_error("bootloader --timeout", KickstartParseError)
88
self.assert_parse_error("bootloader --default", KickstartParseError)
90
class F12_TestCase(F8_TestCase):
91
def runTest(self, iscrypted=False):
93
F8_TestCase.runTest(self, iscrypted)
96
self.assert_deprecated("bootloader", "--lba32")
98
class F14_TestCase(F12_TestCase):
99
def runTest(self, iscrypted=False):
101
F12_TestCase.runTest(self, iscrypted)
104
self.assert_parse_error("bootloader --lba32", KickstartParseError)
106
class F15_TestCase(F14_TestCase):
107
def runTest(self, iscrypted=False):
109
F14_TestCase.runTest(self, iscrypted=True)
112
self.assert_parse("bootloader --password=blahblah --iscrypted", "bootloader --location=mbr --password=\"blahblah\" --iscrypted\n")
113
self.assert_parse("bootloader --md5pass=blahblah", "bootloader --location=mbr --password=\"blahblah\" --iscrypted\n")
115
class F17_TestCase(F15_TestCase):
116
def runTest(self, iscrypted=False):
118
F15_TestCase.runTest(self, iscrypted=iscrypted)
120
self.assert_parse("bootloader --location=mbr --boot-drive=/dev/sda",
121
"bootloader --location=mbr --boot-drive=/dev/sda\n")
122
self.assert_parse("bootloader --location=mbr --boot-drive=sda",
123
"bootloader --location=mbr --boot-drive=sda\n")
124
self.assert_parse("bootloader --location=mbr --boot-drive=/dev/disk/by-path/pci-0000:00:0e.0-scsi-0:0:0:0",
125
"bootloader --location=mbr --boot-drive=/dev/disk/by-path/pci-0000:00:0e.0-scsi-0:0:0:0\n")
127
self.assert_parse_error("bootloader --location=mbr --boot-drive=sda,sdb", KickstartValueError)
129
class F18_TestCase(F17_TestCase):
130
def runTest(self, iscrypted=False):
132
F17_TestCase.runTest(self, iscrypted=iscrypted)
134
self.assert_parse("bootloader --location=mbr --timeout=5 --append=\"rhgb quiet\"")
135
self.assert_parse("bootloader --location=mbr --timeout=5 --leavebootorder --append=\"rhgb quiet\"",
136
"bootloader --append=\"rhgb quiet\" --location=mbr --timeout=5 --leavebootorder\n")
138
class RHEL5_TestCase(FC4_TestCase):
139
def runTest(self, iscrypted=False):
140
FC4_TestCase.runTest(self, iscrypted)
142
self.assert_parse("bootloader --hvargs=bleh",
143
"bootloader --location=mbr --hvargs=\"bleh\"\n")
144
self.assert_parse("bootloader --hvargs=\"bleh bleh\"",
145
"bootloader --location=mbr --hvargs=\"bleh bleh\"\n")
146
self.assert_parse_error("bootloader --hvargs", KickstartParseError)
148
class RHEL6_TestCase(F12_TestCase):
149
def runTest(self, iscrypted=False):
151
F12_TestCase.runTest(self, iscrypted=True)
154
self.assert_parse("bootloader --password=blahblah --iscrypted", "bootloader --location=mbr --password=\"blahblah\" --iscrypted\n")
155
self.assert_parse("bootloader --md5pass=blahblah", "bootloader --location=mbr --password=\"blahblah\" --iscrypted\n")
157
class F19_TestCase(F18_TestCase):
158
def runTest(self, iscrypted=False):
160
F18_TestCase.runTest(self, iscrypted=iscrypted)
162
self.assert_parse("bootloader --location=mbr --timeout=5 --append=\"rhgb quiet\"")
163
self.assert_parse("bootloader --location=mbr --timeout=5 --extlinux --append=\"rhgb quiet\"",
164
"bootloader --append=\"rhgb quiet\" --location=mbr --timeout=5 --extlinux\n")
166
class F21_TestCase(F19_TestCase):
167
def runTest(self, iscrypted=False):
169
F19_TestCase.runTest(self, iscrypted=iscrypted)
171
self.assert_parse("bootloader --disabled", "bootloader --disabled\n")
172
self.assert_parse("bootloader --location=mbr --disabled", "bootloader --disabled\n")
173
self.assert_parse("bootloader --location=mbr --nombr", "bootloader --location=mbr --nombr\n")
175
class RHEL7_TestCase(F19_TestCase):
176
def runTest(self, iscrypted=False):
178
F19_TestCase.runTest(self, iscrypted=iscrypted)
180
self.assert_parse("bootloader --disabled", "bootloader --disabled\n")
181
self.assert_parse("bootloader --location=mbr --disabled", "bootloader --disabled\n")
184
if __name__ == "__main__":