summaryrefslogtreecommitdiffstats
path: root/tests/ts/libfdisk/mkpart-full
blob: 05b2b4793e3b0aa61fd1c7add3bcd553f50c0305 (plain)
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
#!/bin/bash
#
# This file is part of util-linux.
#
# This file is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This file is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
#
# Create partition in non-interactive mode; like mkpart, but partition is fully
# specifuied by partno, start and size.
#

TS_TOPDIR="${0%/*}/../.."
TS_DESC="mkpart-full"

. $TS_TOPDIR/functions.sh
ts_init "$*"

TESTPROG="$TS_HELPER_LIBFDISK_MKPART_FULLSPEC"
ts_check_test_command "$TESTPROG"
ts_check_test_command "$TS_CMD_SFDISK"
ts_check_test_command "$TS_CMD_WIPEFS"

TEST_IMAGE_NAME=$(ts_image_init 15)

ts_init_subtest "mbr-primary"
ts_run $TESTPROG --label mbr --device ${TEST_IMAGE_NAME} \
	1,2048,2048 \
	2,4096,2048 \
	3,6144,2048 \
	4,8192,22528 \
	>> $TS_OUTPUT 2>> $TS_ERRLOG
$TS_CMD_SFDISK --list ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>> $TS_ERRLOG
ts_fdisk_clean ${TEST_IMAGE_NAME}
ts_finalize_subtest

$TS_CMD_WIPEFS --all --force ${TEST_IMAGE_NAME} &> /dev/null


ts_init_subtest "mbr-primary-nopartno"
ts_run $TESTPROG --label mbr --device ${TEST_IMAGE_NAME} -- \
	-,2048,2048 \
	-,4096,2048 \
	-,6144,2048 \
	-,8192,22528 \
	>> $TS_OUTPUT 2>> $TS_ERRLOG
$TS_CMD_SFDISK --list ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>> $TS_ERRLOG
ts_fdisk_clean ${TEST_IMAGE_NAME}
ts_finalize_subtest

$TS_CMD_WIPEFS --all --force ${TEST_IMAGE_NAME} &> /dev/null

## no extended but partno > 4 requested
ts_init_subtest "mbr-err-primary"
ts_run $TESTPROG --label mbr --device ${TEST_IMAGE_NAME} \
	1,2048,2048 \
	2,4096,2048 \
	7,6144,2048 \
	>> $TS_OUTPUT 2>> $TS_ERRLOG
$TS_CMD_SFDISK --list ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>> $TS_ERRLOG
ts_fdisk_clean ${TEST_IMAGE_NAME}
ts_finalize_subtest

$TS_CMD_WIPEFS --all --force ${TEST_IMAGE_NAME} &> /dev/null

## no extended but partno > 4 requested
ts_init_subtest "mbr-err-nospace"
ts_run $TESTPROG --label mbr --device ${TEST_IMAGE_NAME} \
	1,2048,2048 \
	2,4096,2048 \
	3,4096,2048 \
	>> $TS_OUTPUT 2>> $TS_ERRLOG
$TS_CMD_SFDISK --list ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>> $TS_ERRLOG
ts_fdisk_clean ${TEST_IMAGE_NAME}
ts_finalize_subtest

$TS_CMD_WIPEFS --all --force ${TEST_IMAGE_NAME} &> /dev/null


ts_init_subtest "mbr-logical"
ts_run $TESTPROG --label mbr --device ${TEST_IMAGE_NAME} \
	1,2048,2048 \
	2,4096,2048 \
	3,6144,2048 \
	4,8192,22528 \
	5,10240,2048 \
	6,14336,2048 \
	7,18432,12288 \
       	>> $TS_OUTPUT 2>> $TS_ERRLOG
$TS_CMD_SFDISK --list ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>> $TS_ERRLOG
ts_fdisk_clean ${TEST_IMAGE_NAME}
ts_finalize_subtest

$TS_CMD_WIPEFS --all --force ${TEST_IMAGE_NAME} &> /dev/null

ts_init_subtest "mbr-nopartno"
ts_run $TESTPROG --label mbr --device ${TEST_IMAGE_NAME} -- \
	-,2048,2048 \
	-,4096,2048 \
	-,6144,2048 \
	-,8192,22528 \
	-,10240,2048 \
	-,14336,2048 \
	-,18432,12288 \
       	>> $TS_OUTPUT 2>> $TS_ERRLOG
$TS_CMD_SFDISK --list ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>> $TS_ERRLOG
ts_fdisk_clean ${TEST_IMAGE_NAME}
ts_finalize_subtest

$TS_CMD_WIPEFS --all --force ${TEST_IMAGE_NAME} &> /dev/null

### 6th partition (logical) out of extended
ts_init_subtest "mbr-err-logical"
ts_run $TESTPROG --label mbr --device ${TEST_IMAGE_NAME} \
	1,2048,2048 \
	2,4096,2048 \
	3,6144,2048 \
	4,8192,22528 \
	5,10240,2048 \
	6,4096,2048 \
	7,18432,12288 \
       	>> $TS_OUTPUT 2>> $TS_ERRLOG
$TS_CMD_SFDISK --list ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>> $TS_ERRLOG
ts_fdisk_clean ${TEST_IMAGE_NAME}
ts_finalize_subtest

$TS_CMD_WIPEFS --all --force ${TEST_IMAGE_NAME} &> /dev/null

ts_init_subtest "mbr-space-gap"
ts_run $TESTPROG --label mbr --device ${TEST_IMAGE_NAME} \
	1,2048,2048 \
	2,6144,2048 \
	3,8192,2048 \
	>> $TS_OUTPUT 2>> $TS_ERRLOG
$TS_CMD_SFDISK --list ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>> $TS_ERRLOG
ts_fdisk_clean ${TEST_IMAGE_NAME}
ts_finalize_subtest

$TS_CMD_WIPEFS --all --force ${TEST_IMAGE_NAME} &> /dev/null

ts_init_subtest "gpt"
ts_run $TESTPROG --label gpt --device ${TEST_IMAGE_NAME} \
	1,2048,2048 \
	2,4096,2048 \
	3,6144,2048 \
	4,8192,2048 \
	5,10240,2048 \
	6,12288,2048 \
	7,14336,2048 \
       	>> $TS_OUTPUT 2>> $TS_ERRLOG
$TS_CMD_SFDISK --list ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>> $TS_ERRLOG
ts_fdisk_clean ${TEST_IMAGE_NAME}
ts_finalize_subtest

$TS_CMD_WIPEFS --all --force ${TEST_IMAGE_NAME} &> /dev/null

ts_init_subtest "gpt-nopartno"
ts_run $TESTPROG --label gpt --device ${TEST_IMAGE_NAME} -- \
	-,2048,2048 \
	-,4096,2048 \
	-,6144,2048 \
	-,8192,2048 \
	-,10240,2048 \
	-,12288,2048 \
	-,14336,2048 \
       	>> $TS_OUTPUT 2>> $TS_ERRLOG
$TS_CMD_SFDISK --list ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>> $TS_ERRLOG
ts_fdisk_clean ${TEST_IMAGE_NAME}
ts_finalize_subtest

$TS_CMD_WIPEFS --all --force ${TEST_IMAGE_NAME} &> /dev/null

### 4th partition overlap 4th and 5th
ts_init_subtest "gpt-err-overlap"
ts_run $TESTPROG --label gpt --device ${TEST_IMAGE_NAME} \
	1,2048,2048 \
	2,4096,2048 \
	3,6144,2048 \
	4,5000,2048 \
	5,10240,2048 \
	6,12288,2048 \
	7,14336,2048 \
       	>> $TS_OUTPUT 2>> $TS_ERRLOG
$TS_CMD_SFDISK --list ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>> $TS_ERRLOG
ts_fdisk_clean ${TEST_IMAGE_NAME}
ts_finalize_subtest

$TS_CMD_WIPEFS --all --force ${TEST_IMAGE_NAME} &> /dev/null

ts_init_subtest "gpt-partno-gap"
ts_run $TESTPROG --label gpt --device ${TEST_IMAGE_NAME} \
	1,2048,2048 \
	2,4096,2048 \
	4,6144,2048 \
	5,8192,2048 \
	7,10240,2048 \
	8,12288,2048 \
	9,14336,2048 \
       	>> $TS_OUTPUT 2>> $TS_ERRLOG
$TS_CMD_SFDISK --list ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>> $TS_ERRLOG
ts_fdisk_clean ${TEST_IMAGE_NAME}
ts_finalize_subtest

$TS_CMD_WIPEFS --all --force ${TEST_IMAGE_NAME} &> /dev/null

ts_init_subtest "gpt-space-gap"
ts_run $TESTPROG --label gpt --device ${TEST_IMAGE_NAME} \
	1,2048,2048 \
	2,6144,2048 \
	3,8192,2048 \
	4,12288,2048 \
	5,14336,2048 \
       	>> $TS_OUTPUT 2>> $TS_ERRLOG
$TS_CMD_SFDISK --list ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>> $TS_ERRLOG
ts_fdisk_clean ${TEST_IMAGE_NAME}
ts_finalize_subtest

ts_finalize