Debian Codegraph @

tests/ts/fdisk/resize

raw
1 #!/bin/bash
2 #
3 # This file is part of util-linux.
4 #
5 # Copyright (C) 2023 Thomas Weißschuh <[email protected]>
6 #
7 # This file is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
11 #
12 # This file is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
16 #
17 #
18
19 TS_TOPDIR="${0%/*}/../.."
20 TS_DESC="resize"
21
22 . "$TS_TOPDIR"/functions.sh
23 ts_init "$*"
24
25 ts_check_test_command "$TS_CMD_FDISK"
26
27 TEST_IMAGE_NAME=$(ts_image_init 10)
28
29 function print_layout {
30 echo -ne "\n---layout----------\n" >> "$TS_OUTPUT"
31 "$TS_CMD_FDISK" -l "${TEST_IMAGE_NAME}" >> "$TS_OUTPUT" 2>> "$TS_ERRLOG"
32 echo -ne "-------------------\n\n" >> "$TS_OUTPUT"
33
34 ts_fdisk_clean "${TEST_IMAGE_NAME}"
35 }
36
37 function test_fdisk() {
38 "$TS_CMD_FDISK" --noauto-pt "${TEST_IMAGE_NAME}" &> /dev/null
39 }
40
41 ts_log "Create initial partitions"
42 echo -e "g\nn\n\n\n+1M\nn\n\n8192\n+1M\nw\n" | test_fdisk
43
44 print_layout
45
46 ts_log "Grow first to max"
47 echo -e "e\n1\n\nw\n" | test_fdisk
48
49 print_layout
50
51 ts_log "Grow second to max"
52 echo -e "e\n2\n\nw\n" | test_fdisk
53
54 print_layout
55
56 ts_log "Resize first to 4096 bytes"
57 echo -e "e\n1\n4K\nw\n" | test_fdisk
58
59 print_layout
60
61 ts_log "Resize second to 8 sectors"
62 echo -e "e\n2\n8S\nw\n" | test_fdisk
63
64 print_layout
65
66 ts_finalize