blob: 6d0ec9e99282d1a82a1f39b5a2d3b732c8b7e3af (
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
|
#!/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.
#
TS_TOPDIR="${0%/*}/../.."
TS_DESC="MBR - sort"
. "$TS_TOPDIR"/functions.sh
ts_init "$*"
ts_check_test_command "$TS_CMD_FDISK"
# cmd to changes system id to 0x1
FDISK_CMD_WRITE_CLOSE="w\nq\n"
FDISK_CMD_CREATE_DOSLABEL="o\n" #create dos label
FDISK_CMD_CREATE_1PRIMARY="n\np\n1\n4096\n6143\n"
FDISK_CMD_CREATE_2PRIMARY="n\np\n2\n2048\n4095\n"
FDISK_CMD_CREATE_3PRIMARY="n\np\n3\n6144\n8191\n"
FDISK_CMD_CREATE_EXTENDED="n\ne\n\n\n"
FDISK_CMD_CREATE_1LOGICAL="n\n14336\n16383\n"
FDISK_CMD_CREATE_2LOGICAL="n\n22528\n24575\n"
FDISK_CMD_CREATE_3LOGICAL="n\n18432\n20479\n"
FDISK_CMD_CREATE_4LOGICAL="n\n10240\n12287\n"
FDISK_CMD_EXPERT_SORT="x\nf\nr\n"
function print_layout {
echo -ne "\n---layout----------\n" >> $TS_OUTPUT
$TS_CMD_FDISK -x ${TEST_IMAGE_NAME} >> $TS_OUTPUT
echo -ne "-------------------\n\n" >> $TS_OUTPUT
ts_fdisk_clean ${TEST_IMAGE_NAME}
}
#set -x
ts_init_subtest "empty-pt"
TEST_IMAGE_NAME=$(ts_image_init 20) # 20 MiB
echo -e "${FDISK_CMD_CREATE_DOSLABEL}${FDISK_CMD_WRITE_CLOSE}" \
| $TS_CMD_FDISK --noauto-pt ${TEST_IMAGE_NAME} &> /dev/null
print_layout
ts_finalize_subtest
ts_init_subtest "create-primary-partitions"
echo -e "${FDISK_CMD_CREATE_1PRIMARY}${FDISK_CMD_CREATE_2PRIMARY}${FDISK_CMD_CREATE_3PRIMARY}${FDISK_CMD_CREATE_EXTENDED}${FDISK_CMD_WRITE_CLOSE}" \
| $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null
print_layout
ts_finalize_subtest
ts_init_subtest "create-logical-partitions"
echo -e "${FDISK_CMD_CREATE_1LOGICAL}${FDISK_CMD_CREATE_2LOGICAL}${FDISK_CMD_CREATE_3LOGICAL}${FDISK_CMD_CREATE_4LOGICAL}${FDISK_CMD_WRITE_CLOSE}" \
| $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null
print_layout
ts_finalize_subtest
ts_init_subtest "fix-order"
echo -e "${FDISK_CMD_EXPERT_SORT}${FDISK_CMD_WRITE_CLOSE}" \
| $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null
print_layout
ts_finalize_subtest
ts_finalize
|