Debian Codegraph @

tests/ts/fdisk/sunlabel

raw
1 #!/bin/bash
2
3 #
4 # This file is part of util-linux.
5 #
6 # This file is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10 #
11 # This file is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16
17 TS_TOPDIR="${0%/*}/../.."
18 TS_DESC="sunlabel tests"
19
20 . "$TS_TOPDIR"/functions.sh
21 ts_init "$*"
22
23 ts_check_test_command "$TS_CMD_FDISK"
24 ts_check_test_command "$TS_HELPER_MD5"
25
26 FDISK_CMD_INIT="s\n" # create new sunlabel
27 FDISK_CMD_WRITE_CLOSE="w\nq\n"
28 FDISK_CMD_DELETEALL="d\n1\nd\n2\nd\n3\nd\n4\nd\n5\nd\n6\nd\n7\nd\n8\n" # delete all partitions
29
30 FDISK_CMD_CREATE_PRIMARY="n\n\n\n128\n" # create first partition
31 FDISK_CMD_TOGGLE_READONLY="a\n1\n" # sets first partition as read-only
32 FDISK_CMD_TOGGLE_MOUNTABLE="c\n1\n" # sets first partition as mountable
33 FDISK_CMD_CHANGE_SYSID="t\n4\n" # changes sysid to 4 (SunOS usr)
34 FDISK_CMD_CREATE_SECONDARY="n\n2\n128\n\n" # create secondary partition to the end of disk
35
36 FDISK_OPTIONS="--heads 1 --sectors 63 --units=cylinders"
37
38 function print_layout {
39 $TS_CMD_FDISK ${FDISK_OPTIONS} -x ${TEST_IMAGE_NAME} >> $TS_OUTPUT
40 ts_fdisk_clean ${TEST_IMAGE_NAME}
41 }
42
43 #set -x
44
45 ts_init_subtest "empty-sun-pt"
46 TEST_IMAGE_NAME=$(ts_image_init 10)
47 ts_image_md5sum >> $TS_OUTPUT 2>> $TS_ERRLOG
48
49 echo -e "${FDISK_CMD_INIT}${FDISK_CMD_DELETEALL}${FDISK_CMD_WRITE_CLOSE}" \
50 | $TS_CMD_FDISK --noauto-pt ${FDISK_OPTIONS} ${TEST_IMAGE_NAME} &> /dev/null
51 ts_image_md5sum >> $TS_OUTPUT 2>> $TS_ERRLOG
52
53 print_layout
54 ts_finalize_subtest
55
56
57 ts_init_subtest "create-first-partition"
58 echo -e "${FDISK_CMD_CREATE_PRIMARY}${FDISK_CMD_WRITE_CLOSE}" | \
59 $TS_CMD_FDISK ${FDISK_OPTIONS} ${TEST_IMAGE_NAME} &> /dev/null
60 ts_image_md5sum >> $TS_OUTPUT 2>> $TS_ERRLOG
61
62 print_layout
63 ts_finalize_subtest
64
65 ts_init_subtest "set-partition-sysid"
66 echo -e "${FDISK_CMD_CHANGE_SYSID}${FDISK_CMD_WRITE_CLOSE}" | \
67 $TS_CMD_FDISK ${FDISK_OPTIONS} ${TEST_IMAGE_NAME} &> /dev/null
68 ts_image_md5sum >> $TS_OUTPUT 2>> $TS_ERRLOG
69
70 print_layout
71 ts_finalize_subtest
72
73 ts_init_subtest "set-first-par-readonly"
74 echo -e "${FDISK_CMD_TOGGLE_READONLY}${FDISK_CMD_WRITE_CLOSE}" | \
75 $TS_CMD_FDISK ${FDISK_OPTIONS} ${TEST_IMAGE_NAME} &> /dev/null
76 ts_image_md5sum >> $TS_OUTPUT 2>> $TS_ERRLOG
77
78 print_layout
79 ts_finalize_subtest
80
81 ts_init_subtest "set-first-par-mountable"
82 echo -e "${FDISK_CMD_TOGGLE_MOUNTABLE}${FDISK_CMD_WRITE_CLOSE}" | \
83 $TS_CMD_FDISK ${FDISK_OPTIONS} ${TEST_IMAGE_NAME} &> /dev/null
84 ts_image_md5sum >> $TS_OUTPUT 2>> $TS_ERRLOG
85
86 print_layout
87 ts_finalize_subtest
88
89 ts_init_subtest "create-second-partition"
90 echo -e "${FDISK_CMD_CREATE_SECONDARY}${FDISK_CMD_WRITE_CLOSE}" | \
91 $TS_CMD_FDISK ${FDISK_OPTIONS} ${TEST_IMAGE_NAME} >> $TS_OUTPUT 2>> $TS_ERRLOG
92 ts_image_md5sum >> $TS_OUTPUT 2>> $TS_ERRLOG
93
94 print_layout
95 ts_finalize_subtest
96
97 ts_init_subtest "delete-all-partitions"
98 echo -e "${FDISK_CMD_DELETEALL}${FDISK_CMD_WRITE_CLOSE}" | \
99 $TS_CMD_FDISK ${FDISK_OPTIONS} ${TEST_IMAGE_NAME} &> /dev/null
100 ts_image_md5sum >> $TS_OUTPUT 2>> $TS_ERRLOG
101 ts_finalize_subtest
102
103
104 ts_finalize