Add the --nombr bootloader option in pykickstart
[pykickstart.git] / tests / commands / partition.py
blob6c81b9e2f2fd6ff78af22120000215b8e1984845
2 # Martin Gracik <mgracik@redhat.com>
4 # Copyright 2009 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 import unittest
22 from tests.baseclass import *
24 class FC3_TestCase(CommandTest):
25 command = "partition"
27 def runTest(self):
28 if "--bytes-per-inode" in self.optionList:
29 self.bytesPerInode = " --bytes-per-inode=4096"
30 else:
31 self.bytesPerInode = ""
33 # pass
34 self.assert_parse("part /home", "part /home%s\n" % self.bytesPerInode)
36 if "--start" in self.optionList:
37 self.assert_parse("partition raid.1 --active --asprimary --start=0 --end=10 --fstype=ext3 --noformat",
38 "part raid.1 --active --asprimary --end=10 --fstype=\"ext3\" --noformat%s\n" % self.bytesPerInode)
39 else:
40 self.assert_parse("partition raid.1 --active --asprimary --fstype=ext3 --noformat",
41 "part raid.1 --active --asprimary --fstype=\"ext3\" --noformat%s\n" % self.bytesPerInode)
43 self.assert_parse("part pv.1 --ondisk=sda --onpart=sda1 --recommended",
44 "part pv.1 --ondisk=sda --onpart=sda1 --recommended%s\n" % self.bytesPerInode)
45 self.assert_parse("part pv.1 --ondrive=sda --usepart=sda1 --recommended",
46 "part pv.1 --ondisk=sda --onpart=sda1 --recommended%s\n" % self.bytesPerInode)
47 self.assert_parse("part / --onbiosdisk=hda --size=100", "part / --onbiosdisk=hda --size=100%s\n" % self.bytesPerInode)
48 self.assert_parse("part swap --grow --maxsize=100", "part swap --grow --maxsize=100%s\n" % self.bytesPerInode)
50 # does not remove the /dev/ part
51 self.assert_parse("part /usr --ondisk=/dev/sda --recommended --noformat --active",
52 "part /usr --active --noformat --ondisk=/dev/sda --recommended%s\n" % self.bytesPerInode)
54 # fail
55 # missing mountpoint
56 self.assert_parse_error("part", KickstartValueError)
57 self.assert_parse_error("part --ondisk=sda --size=100", KickstartValueError)
59 int_params = ["size", "maxsize"]
60 if "--start" in self.optionList:
61 int_params += ["start", "end"]
62 for opt in int_params:
63 # integer argument required
64 self.assert_parse_error("part / --%s=string" % opt, KickstartParseError)
65 # value required
66 self.assert_parse_error("part / --%s" % opt, KickstartParseError)
68 for opt in ("fstype", "onbiosdisk", "ondisk", "ondrive", "onpart", "usepart"):
69 # value required
70 self.assert_parse_error("part / --%s" % opt, KickstartParseError)
72 # only one argument allowed
73 self.assert_parse_error("part / /home /usr", KickstartValueError)
74 # unknown option
75 self.assert_parse_error("part /home --unknown=value", KickstartParseError)
77 class FC4_TestCase(FC3_TestCase):
78 def runTest(self):
79 # run FC3 test case
80 FC3_TestCase.runTest(self)
82 if "--bytes-per-inode" in self.optionList:
83 # pass
84 self.assert_parse("part /home --bytes-per-inode=2048 --fsoptions=blah --label=home",
85 "part /home --bytes-per-inode=2048 --fsoptions=\"blah\" --label=home\n")
87 # fail
88 # --bytes-per-inode requires int argument
89 self.assert_parse_error("part /home --bytes-per-inode=string", KickstartParseError)
90 self.assert_parse_error("part /home --bytes-per-inode", KickstartParseError)
92 # missing required arguments
93 for opt in ("--fsoptions", "--label"):
94 if opt in self.optionList:
95 self.assert_parse_error("part /home %s" % opt, KickstartParseError)
97 class RHEL5_TestCase(FC4_TestCase):
98 def runTest(self):
99 # run FC4 test case
100 FC4_TestCase.runTest(self)
102 # pass
103 self.assert_parse("part / --encrypted --passphrase=blahblah",
104 "part / --bytes-per-inode=4096 --encrypted --passphrase=\"blahblah\"\n")
106 # fail
107 # missing required --passphrase argument
108 self.assert_parse_error("part / --encrypted --passphrase", KickstartParseError)
110 class F9_TestCase(FC3_TestCase):
111 def runTest(self, start_end=True):
112 # run FC3 test case
113 FC3_TestCase.runTest(self)
115 # pass
116 self.assert_parse("part / --encrypted --passphrase=blahblah",
117 "part / --encrypted --passphrase=\"blahblah\"\n")
118 self.assert_parse("part /home --fsprofile=blah", "part /home --fsprofile=\"blah\"\n")
120 # deprecated
121 self.assert_deprecated("part", "--bytes-per-inode")
123 # fail
124 # missing required --passphrase argument
125 self.assert_parse_error("part / --encrypted --passphrase", KickstartParseError)
126 # missing required --fsprofile argument
127 self.assert_parse_error("part / --fsprofile", KickstartParseError)
129 class F12_TestCase(F9_TestCase):
130 def runTest(self):
131 # Run F9 test case
132 F9_TestCase.runTest(self)
134 # pass
135 self.assert_parse("part / --escrowcert=\"http://x/y\"", "part /\n")
136 self.assert_parse("part / --encrypted --backuppassphrase",
137 "part / --encrypted\n")
138 self.assert_parse("part / --encrypted --escrowcert=\"http://x/y\"",
139 "part / --encrypted --escrowcert=\"http://x/y\"\n")
140 self.assert_parse("part / --encrypted --escrowcert=\"http://x/y\" "
141 "--backuppassphrase",
142 "part / --encrypted --escrowcert=\"http://x/y\" "
143 "--backuppassphrase\n")
144 self.assert_parse("part / --encrypted --escrowcert=http://x/y",
145 "part / --encrypted --escrowcert=\"http://x/y\"\n")
147 # fail
148 self.assert_parse_error("part / --escrowcert")
149 self.assert_parse_error("part / --escrowcert --backuppassphrase")
150 self.assert_parse_error("part / --encrypted --escrowcert "
151 "--backuppassphrase")
152 self.assert_parse_error("part / --backuppassphrase=False")
153 self.assert_parse_error("part / --backuppassphrase=True")
155 class RHEL6_TestCase(F12_TestCase):
156 def runTest(self):
157 F12_TestCase.runTest(self)
159 self.assert_parse("part / --encrypted --cipher=3-rot13",
160 "part / --encrypted --cipher=\"3-rot13\"\n")
161 # Allowed here, but anaconda should complain. Note how we throw out
162 # cipher from the output if there's no --encrypted.
163 self.assert_parse("part / --cipher=3-rot13",
164 "part /\n")
166 self.assert_parse_error("part / --cipher")
168 self.assert_parse("part swap --hibernation")
169 self.assert_parse("part swap --recommended --hibernation")
171 class F14_TestCase(F12_TestCase):
172 def runTest(self):
173 F12_TestCase.runTest(self)
174 self.assert_removed("partition", "--bytes-per-inode")
175 self.assert_removed("partition", "--start")
176 self.assert_removed("partition", "--end")
178 class F17_TestCase(F14_TestCase):
179 def runTest(self):
180 F14_TestCase.runTest(self)
181 self.assert_parse("part /foo --resize --size 500 --onpart=sda3",
182 "part /foo --onpart=sda3 --size=500 --resize\n")
184 # no onpart or size
185 self.assert_parse_error("part /foo --resize")
187 # no onpart
188 self.assert_parse_error("part /foo --size=999 --resize")
190 # no size
191 self.assert_parse_error("part /foo --onpart=LABEL=var --resize")
193 class F18_TestCase(F17_TestCase):
194 def runTest(self):
195 F17_TestCase.runTest(self)
196 self.assert_parse("part swap --hibernation")
197 self.assert_parse("part swap --recommended")
198 self.assert_parse("part swap --recommended --hibernation")
200 self.assert_parse("part / --encrypted --cipher=3-rot13",
201 "part / --encrypted --cipher=\"3-rot13\"\n")
202 # Allowed here, but anaconda should complain. Note how we throw out
203 # cipher from the output if there's no --encrypted.
204 self.assert_parse("part / --cipher=3-rot13",
205 "part /\n")
207 self.assert_parse_error("part / --cipher")
209 if __name__ == "__main__":
210 unittest.main()