~registry/pykickstart/trunk

« back to all changes in this revision

Viewing changes to tests/commands/bootloader.py

  • Committer: Chris Lumens
  • Date: 2014-10-22 14:19:44 UTC
  • Revision ID: git-v1:982498c0647c4bc3b4460209d4a76698c0eb6f8c
Add a note that the repo has moved.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#
2
 
# Chris Lumens <clumens@redhat.com>
3
 
#
4
 
# Copyright 2009-2014 Red Hat, Inc.
5
 
#
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.
12
 
#
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. 
19
 
#
20
 
import unittest
21
 
from tests.baseclass import *
22
 
 
23
 
from pykickstart.errors import *
24
 
 
25
 
class FC3_TestCase(CommandTest):
26
 
    command = "bootloader"
27
 
 
28
 
    def runTest(self, iscrypted=False):
29
 
        if "--linear" in self.optionList:
30
 
            linear = "--linear "
31
 
        else:
32
 
            linear = ""
33
 
 
34
 
        # pass
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)
38
 
 
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")
43
 
 
44
 
        for loc in ["mbr", "partition", "none", "boot"]:
45
 
            self.assert_parse("bootloader --location=%s" % loc, "bootloader %s--location=%s\n" % (linear, loc))
46
 
 
47
 
        if "--lba32" in self.optionList:
48
 
            self.assert_parse("bootloader --lba32", "bootloader %s--location=mbr --lba32\n" % linear)
49
 
 
50
 
        self.assert_parse("bootloader --password=blahblah", "bootloader %s--location=mbr --password=\"blahblah\"\n" % linear)
51
 
        if not iscrypted:
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)
55
 
 
56
 
        if "--useLilo" in self.optionList:
57
 
            self.assert_parse("bootloader --useLilo", "bootloader %s--location=mbr --useLilo\n" % linear)
58
 
            self.assert_parse("lilo")
59
 
 
60
 
        # fail
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)
66
 
 
67
 
class FC4_TestCase(FC3_TestCase):
68
 
    def runTest(self, iscrypted=False):
69
 
        # Run parent tests
70
 
        FC3_TestCase.runTest(self, iscrypted)
71
 
 
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")
76
 
 
77
 
class F8_TestCase(FC4_TestCase):
78
 
    def runTest(self, iscrypted=False):
79
 
        # Run parent tests
80
 
        FC4_TestCase.runTest(self, iscrypted)
81
 
 
82
 
        # pass
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")
85
 
 
86
 
        # fail
87
 
        self.assert_parse_error("bootloader --timeout", KickstartParseError)
88
 
        self.assert_parse_error("bootloader --default", KickstartParseError)
89
 
 
90
 
class F12_TestCase(F8_TestCase):
91
 
    def runTest(self, iscrypted=False):
92
 
        # Run parent tests
93
 
        F8_TestCase.runTest(self, iscrypted)
94
 
 
95
 
        # deprecated
96
 
        self.assert_deprecated("bootloader", "--lba32")
97
 
 
98
 
class F14_TestCase(F12_TestCase):
99
 
    def runTest(self, iscrypted=False):
100
 
        # Run parent tests
101
 
        F12_TestCase.runTest(self, iscrypted)
102
 
 
103
 
        # fail
104
 
        self.assert_parse_error("bootloader --lba32", KickstartParseError)
105
 
 
106
 
class F15_TestCase(F14_TestCase):
107
 
    def runTest(self, iscrypted=False):
108
 
        # Run parent tests
109
 
        F14_TestCase.runTest(self, iscrypted=True)
110
 
 
111
 
        # pass
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")
114
 
 
115
 
class F17_TestCase(F15_TestCase):
116
 
    def runTest(self, iscrypted=False):
117
 
        # run parent tests
118
 
        F15_TestCase.runTest(self, iscrypted=iscrypted)
119
 
 
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")
126
 
 
127
 
        self.assert_parse_error("bootloader --location=mbr --boot-drive=sda,sdb", KickstartValueError)
128
 
 
129
 
class F18_TestCase(F17_TestCase):
130
 
    def runTest(self, iscrypted=False):
131
 
        # run parent tests
132
 
        F17_TestCase.runTest(self, iscrypted=iscrypted)
133
 
 
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")
137
 
 
138
 
class RHEL5_TestCase(FC4_TestCase):
139
 
    def runTest(self, iscrypted=False):
140
 
        FC4_TestCase.runTest(self, iscrypted)
141
 
 
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)
147
 
 
148
 
class RHEL6_TestCase(F12_TestCase):
149
 
    def runTest(self, iscrypted=False):
150
 
        # Run parent tests
151
 
        F12_TestCase.runTest(self, iscrypted=True)
152
 
 
153
 
        # pass
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")
156
 
 
157
 
class F19_TestCase(F18_TestCase):
158
 
    def runTest(self, iscrypted=False):
159
 
        # run parent tests
160
 
        F18_TestCase.runTest(self, iscrypted=iscrypted)
161
 
 
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")
165
 
 
166
 
class F21_TestCase(F19_TestCase):
167
 
    def runTest(self, iscrypted=False):
168
 
        # run parent tests
169
 
        F19_TestCase.runTest(self, iscrypted=iscrypted)
170
 
 
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")
174
 
 
175
 
class RHEL7_TestCase(F19_TestCase):
176
 
    def runTest(self, iscrypted=False):
177
 
        # run parent tests
178
 
        F19_TestCase.runTest(self, iscrypted=iscrypted)
179
 
 
180
 
        self.assert_parse("bootloader --disabled", "bootloader --disabled\n")
181
 
        self.assert_parse("bootloader --location=mbr --disabled", "bootloader --disabled\n")
182
 
 
183
 
 
184
 
if __name__ == "__main__":
185
 
    unittest.main()