Bill Richardson | f1372d9 | 2010-06-11 09:15:55 -0700 | [diff] [blame] | 1 | #!/bin/bash -eu |
| 2 | |
| 3 | # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| 4 | # Use of this source code is governed by a BSD-style license that can be |
| 5 | # found in the LICENSE file. |
| 6 | # |
Bill Richardson | 263ffdf | 2012-08-24 14:39:21 -0700 | [diff] [blame^] | 7 | # Run tests for cgpt utility. |
Bill Richardson | f1372d9 | 2010-06-11 09:15:55 -0700 | [diff] [blame] | 8 | |
| 9 | # Load common constants and variables. |
| 10 | . "$(dirname "$0")/common.sh" |
| 11 | |
Bill Richardson | 263ffdf | 2012-08-24 14:39:21 -0700 | [diff] [blame^] | 12 | CGPT=$(readlink -f "$1") |
| 13 | [ -x "$CGPT" ] || error "Can't execute $CGPT" |
Bill Richardson | 793e1b4 | 2010-08-20 07:58:43 -0700 | [diff] [blame] | 14 | |
| 15 | # Run tests in a dedicated directory for easy cleanup or debugging. |
| 16 | DIR="${TEST_DIR}/cgpt_test_dir" |
| 17 | [ -d "$DIR" ] || mkdir -p "$DIR" |
Bill Richardson | 263ffdf | 2012-08-24 14:39:21 -0700 | [diff] [blame^] | 18 | warning "testing $CGPT in $DIR" |
Bill Richardson | 793e1b4 | 2010-08-20 07:58:43 -0700 | [diff] [blame] | 19 | cd "$DIR" |
Bill Richardson | f1372d9 | 2010-06-11 09:15:55 -0700 | [diff] [blame] | 20 | |
| 21 | echo "Create an empty file to use as the device..." |
| 22 | NUM_SECTORS=1000 |
Bill Richardson | 793e1b4 | 2010-08-20 07:58:43 -0700 | [diff] [blame] | 23 | DEV=fake_dev.bin |
Bill Richardson | 23429d3 | 2012-04-30 11:33:13 -0700 | [diff] [blame] | 24 | rm -f ${DEV} |
Bill Richardson | f1372d9 | 2010-06-11 09:15:55 -0700 | [diff] [blame] | 25 | dd if=/dev/zero of=${DEV} conv=notrunc bs=512 count=${NUM_SECTORS} 2>/dev/null |
Bill Richardson | f1372d9 | 2010-06-11 09:15:55 -0700 | [diff] [blame] | 26 | |
| 27 | |
| 28 | echo "Create a bunch of partitions, using the real GUID types..." |
| 29 | DATA_START=100 |
| 30 | DATA_SIZE=20 |
| 31 | DATA_LABEL="data stuff" |
| 32 | DATA_GUID='ebd0a0a2-b9e5-4433-87c0-68b6b72699c7' |
| 33 | DATA_NUM=1 |
| 34 | |
| 35 | KERN_START=200 |
| 36 | KERN_SIZE=30 |
| 37 | KERN_LABEL="kernel stuff" |
| 38 | KERN_GUID='fe3a2a5d-4f32-41a7-b725-accc3285a309' |
| 39 | KERN_NUM=2 |
| 40 | |
| 41 | ROOTFS_START=300 |
| 42 | ROOTFS_SIZE=40 |
| 43 | ROOTFS_LABEL="rootfs stuff" |
| 44 | ROOTFS_GUID='3cb8e202-3b7e-47dd-8a3c-7ff2a13cfcec' |
| 45 | ROOTFS_NUM=3 |
| 46 | |
| 47 | ESP_START=400 |
| 48 | ESP_SIZE=50 |
| 49 | ESP_LABEL="ESP stuff" |
| 50 | ESP_GUID='c12a7328-f81f-11d2-ba4b-00a0c93ec93b' |
| 51 | ESP_NUM=4 |
| 52 | |
| 53 | FUTURE_START=500 |
| 54 | FUTURE_SIZE=60 |
| 55 | FUTURE_LABEL="future stuff" |
| 56 | FUTURE_GUID='2e0a753d-9e48-43b0-8337-b15192cb1b5e' |
| 57 | FUTURE_NUM=5 |
| 58 | |
| 59 | RANDOM_START=600 |
| 60 | RANDOM_SIZE=70 |
| 61 | RANDOM_LABEL="random stuff" |
| 62 | RANDOM_GUID='2364a860-bf63-42fb-a83d-9ad3e057fcf5' |
| 63 | RANDOM_NUM=6 |
| 64 | |
Bill Richardson | 263ffdf | 2012-08-24 14:39:21 -0700 | [diff] [blame^] | 65 | $CGPT create ${DEV} |
Bill Richardson | f1372d9 | 2010-06-11 09:15:55 -0700 | [diff] [blame] | 66 | |
Bill Richardson | 263ffdf | 2012-08-24 14:39:21 -0700 | [diff] [blame^] | 67 | $CGPT add -b ${DATA_START} -s ${DATA_SIZE} -t ${DATA_GUID} \ |
Bill Richardson | f1372d9 | 2010-06-11 09:15:55 -0700 | [diff] [blame] | 68 | -l "${DATA_LABEL}" ${DEV} |
Bill Richardson | 263ffdf | 2012-08-24 14:39:21 -0700 | [diff] [blame^] | 69 | $CGPT add -b ${KERN_START} -s ${KERN_SIZE} -t ${KERN_GUID} \ |
Bill Richardson | f1372d9 | 2010-06-11 09:15:55 -0700 | [diff] [blame] | 70 | -l "${KERN_LABEL}" ${DEV} |
Bill Richardson | 263ffdf | 2012-08-24 14:39:21 -0700 | [diff] [blame^] | 71 | $CGPT add -b ${ROOTFS_START} -s ${ROOTFS_SIZE} -t ${ROOTFS_GUID} \ |
Bill Richardson | f1372d9 | 2010-06-11 09:15:55 -0700 | [diff] [blame] | 72 | -l "${ROOTFS_LABEL}" ${DEV} |
Bill Richardson | 263ffdf | 2012-08-24 14:39:21 -0700 | [diff] [blame^] | 73 | $CGPT add -b ${ESP_START} -s ${ESP_SIZE} -t ${ESP_GUID} \ |
Bill Richardson | f1372d9 | 2010-06-11 09:15:55 -0700 | [diff] [blame] | 74 | -l "${ESP_LABEL}" ${DEV} |
Bill Richardson | 263ffdf | 2012-08-24 14:39:21 -0700 | [diff] [blame^] | 75 | $CGPT add -b ${FUTURE_START} -s ${FUTURE_SIZE} -t ${FUTURE_GUID} \ |
Bill Richardson | f1372d9 | 2010-06-11 09:15:55 -0700 | [diff] [blame] | 76 | -l "${FUTURE_LABEL}" ${DEV} |
Bill Richardson | 263ffdf | 2012-08-24 14:39:21 -0700 | [diff] [blame^] | 77 | $CGPT add -b ${RANDOM_START} -s ${RANDOM_SIZE} -t ${RANDOM_GUID} \ |
Bill Richardson | f1372d9 | 2010-06-11 09:15:55 -0700 | [diff] [blame] | 78 | -l "${RANDOM_LABEL}" ${DEV} |
| 79 | |
| 80 | |
| 81 | echo "Extract the start and size of given partitions..." |
| 82 | |
Bill Richardson | 263ffdf | 2012-08-24 14:39:21 -0700 | [diff] [blame^] | 83 | X=$($CGPT show -b -i $DATA_NUM ${DEV}) |
| 84 | Y=$($CGPT show -s -i $DATA_NUM ${DEV}) |
Bill Richardson | 3430b32 | 2010-11-29 14:24:51 -0800 | [diff] [blame] | 85 | [ "$X $Y" = "$DATA_START $DATA_SIZE" ] || error |
Bill Richardson | f1372d9 | 2010-06-11 09:15:55 -0700 | [diff] [blame] | 86 | |
Bill Richardson | 263ffdf | 2012-08-24 14:39:21 -0700 | [diff] [blame^] | 87 | X=$($CGPT show -b -i $KERN_NUM ${DEV}) |
| 88 | Y=$($CGPT show -s -i $KERN_NUM ${DEV}) |
Bill Richardson | 3430b32 | 2010-11-29 14:24:51 -0800 | [diff] [blame] | 89 | [ "$X $Y" = "$KERN_START $KERN_SIZE" ] || error |
Bill Richardson | f1372d9 | 2010-06-11 09:15:55 -0700 | [diff] [blame] | 90 | |
Bill Richardson | 263ffdf | 2012-08-24 14:39:21 -0700 | [diff] [blame^] | 91 | X=$($CGPT show -b -i $ROOTFS_NUM ${DEV}) |
| 92 | Y=$($CGPT show -s -i $ROOTFS_NUM ${DEV}) |
Bill Richardson | 3430b32 | 2010-11-29 14:24:51 -0800 | [diff] [blame] | 93 | [ "$X $Y" = "$ROOTFS_START $ROOTFS_SIZE" ] || error |
Bill Richardson | f1372d9 | 2010-06-11 09:15:55 -0700 | [diff] [blame] | 94 | |
Bill Richardson | 263ffdf | 2012-08-24 14:39:21 -0700 | [diff] [blame^] | 95 | X=$($CGPT show -b -i $ESP_NUM ${DEV}) |
| 96 | Y=$($CGPT show -s -i $ESP_NUM ${DEV}) |
Bill Richardson | 3430b32 | 2010-11-29 14:24:51 -0800 | [diff] [blame] | 97 | [ "$X $Y" = "$ESP_START $ESP_SIZE" ] || error |
Bill Richardson | f1372d9 | 2010-06-11 09:15:55 -0700 | [diff] [blame] | 98 | |
Bill Richardson | 263ffdf | 2012-08-24 14:39:21 -0700 | [diff] [blame^] | 99 | X=$($CGPT show -b -i $FUTURE_NUM ${DEV}) |
| 100 | Y=$($CGPT show -s -i $FUTURE_NUM ${DEV}) |
Bill Richardson | 3430b32 | 2010-11-29 14:24:51 -0800 | [diff] [blame] | 101 | [ "$X $Y" = "$FUTURE_START $FUTURE_SIZE" ] || error |
Bill Richardson | f1372d9 | 2010-06-11 09:15:55 -0700 | [diff] [blame] | 102 | |
Bill Richardson | 263ffdf | 2012-08-24 14:39:21 -0700 | [diff] [blame^] | 103 | X=$($CGPT show -b -i $RANDOM_NUM ${DEV}) |
| 104 | Y=$($CGPT show -s -i $RANDOM_NUM ${DEV}) |
Bill Richardson | 3430b32 | 2010-11-29 14:24:51 -0800 | [diff] [blame] | 105 | [ "$X $Y" = "$RANDOM_START $RANDOM_SIZE" ] || error |
Bill Richardson | f1372d9 | 2010-06-11 09:15:55 -0700 | [diff] [blame] | 106 | |
| 107 | |
| 108 | echo "Set the boot partition.." |
Bill Richardson | 263ffdf | 2012-08-24 14:39:21 -0700 | [diff] [blame^] | 109 | $CGPT boot -i ${KERN_NUM} ${DEV} >/dev/null |
Bill Richardson | f1372d9 | 2010-06-11 09:15:55 -0700 | [diff] [blame] | 110 | |
| 111 | echo "Check the PMBR's idea of the boot partition..." |
Bill Richardson | 263ffdf | 2012-08-24 14:39:21 -0700 | [diff] [blame^] | 112 | X=$($CGPT boot ${DEV}) |
| 113 | Y=$($CGPT show -u -i $KERN_NUM $DEV) |
Bill Richardson | 3430b32 | 2010-11-29 14:24:51 -0800 | [diff] [blame] | 114 | [ "$X" = "$Y" ] || error |
| 115 | |
| 116 | |
| 117 | echo "Test the cgpt prioritize command..." |
| 118 | |
| 119 | # Input: sequence of priorities |
| 120 | # Output: ${DEV} has kernel partitions with the given priorities |
| 121 | make_pri() { |
| 122 | local idx=0 |
Bill Richardson | 263ffdf | 2012-08-24 14:39:21 -0700 | [diff] [blame^] | 123 | $CGPT create ${DEV} |
Bill Richardson | 3430b32 | 2010-11-29 14:24:51 -0800 | [diff] [blame] | 124 | for pri in "$@"; do |
| 125 | idx=$((idx+1)) |
Bill Richardson | 263ffdf | 2012-08-24 14:39:21 -0700 | [diff] [blame^] | 126 | $CGPT add -t kernel -l "kern$idx" -b $((100 + 2 * $idx)) -s 1 -P $pri ${DEV} |
Bill Richardson | 3430b32 | 2010-11-29 14:24:51 -0800 | [diff] [blame] | 127 | done |
| 128 | } |
| 129 | |
| 130 | # Output: returns string containing priorities of all kernels |
| 131 | get_pri() { |
| 132 | echo $( |
Bill Richardson | 263ffdf | 2012-08-24 14:39:21 -0700 | [diff] [blame^] | 133 | for idx in $($CGPT find -t kernel ${DEV} | sed -e s@${DEV}@@); do |
| 134 | $CGPT show -i $idx -P ${DEV} |
Bill Richardson | 3430b32 | 2010-11-29 14:24:51 -0800 | [diff] [blame] | 135 | done |
| 136 | ) |
| 137 | } |
| 138 | |
| 139 | # Input: list of priorities |
| 140 | # Operation: expects ${DEV} to contain those kernel priorities |
| 141 | assert_pri() { |
| 142 | local expected="$*" |
| 143 | local actual=$(get_pri) |
| 144 | [ "$actual" = "$expected" ] || \ |
| 145 | error 1 "expected priority \"$expected\", actual priority \"$actual\"" |
| 146 | } |
| 147 | |
| 148 | |
| 149 | # no kernels at all. This should do nothing. |
Bill Richardson | 263ffdf | 2012-08-24 14:39:21 -0700 | [diff] [blame^] | 150 | $CGPT create ${DEV} |
| 151 | $CGPT add -t rootfs -b 100 -s 1 ${DEV} |
| 152 | $CGPT prioritize ${DEV} |
Bill Richardson | 3430b32 | 2010-11-29 14:24:51 -0800 | [diff] [blame] | 153 | assert_pri "" |
| 154 | |
| 155 | # common install/upgrade sequence |
| 156 | make_pri 2 0 0 |
Bill Richardson | 263ffdf | 2012-08-24 14:39:21 -0700 | [diff] [blame^] | 157 | $CGPT prioritize -i 1 ${DEV} |
Bill Richardson | 3430b32 | 2010-11-29 14:24:51 -0800 | [diff] [blame] | 158 | assert_pri 1 0 0 |
Bill Richardson | 263ffdf | 2012-08-24 14:39:21 -0700 | [diff] [blame^] | 159 | $CGPT prioritize -i 2 ${DEV} |
Bill Richardson | 3430b32 | 2010-11-29 14:24:51 -0800 | [diff] [blame] | 160 | assert_pri 1 2 0 |
Bill Richardson | 263ffdf | 2012-08-24 14:39:21 -0700 | [diff] [blame^] | 161 | $CGPT prioritize -i 1 ${DEV} |
Bill Richardson | 3430b32 | 2010-11-29 14:24:51 -0800 | [diff] [blame] | 162 | assert_pri 2 1 0 |
Bill Richardson | 263ffdf | 2012-08-24 14:39:21 -0700 | [diff] [blame^] | 163 | $CGPT prioritize -i 2 ${DEV} |
Bill Richardson | 3430b32 | 2010-11-29 14:24:51 -0800 | [diff] [blame] | 164 | assert_pri 1 2 0 |
| 165 | |
| 166 | # lots of kernels, all same starting priority, should go to priority 1 |
| 167 | make_pri 8 8 8 8 8 8 8 8 8 8 8 0 0 8 |
Bill Richardson | 263ffdf | 2012-08-24 14:39:21 -0700 | [diff] [blame^] | 168 | $CGPT prioritize ${DEV} |
Bill Richardson | 3430b32 | 2010-11-29 14:24:51 -0800 | [diff] [blame] | 169 | assert_pri 1 1 1 1 1 1 1 1 1 1 1 0 0 1 |
| 170 | |
| 171 | # now raise them all up again |
Bill Richardson | 263ffdf | 2012-08-24 14:39:21 -0700 | [diff] [blame^] | 172 | $CGPT prioritize -P 4 ${DEV} |
Bill Richardson | 3430b32 | 2010-11-29 14:24:51 -0800 | [diff] [blame] | 173 | assert_pri 4 4 4 4 4 4 4 4 4 4 4 0 0 4 |
| 174 | |
| 175 | # set one of them higher, should leave the rest alone |
Bill Richardson | 263ffdf | 2012-08-24 14:39:21 -0700 | [diff] [blame^] | 176 | $CGPT prioritize -P 5 -i 3 ${DEV} |
Bill Richardson | 3430b32 | 2010-11-29 14:24:51 -0800 | [diff] [blame] | 177 | assert_pri 4 4 5 4 4 4 4 4 4 4 4 0 0 4 |
| 178 | |
| 179 | # set one of them lower, should bring the rest down |
Bill Richardson | 263ffdf | 2012-08-24 14:39:21 -0700 | [diff] [blame^] | 180 | $CGPT prioritize -P 3 -i 4 ${DEV} |
Bill Richardson | 3430b32 | 2010-11-29 14:24:51 -0800 | [diff] [blame] | 181 | assert_pri 1 1 2 3 1 1 1 1 1 1 1 0 0 1 |
| 182 | |
| 183 | # raise a group by including the friends of one partition |
Bill Richardson | 263ffdf | 2012-08-24 14:39:21 -0700 | [diff] [blame^] | 184 | $CGPT prioritize -P 6 -i 1 -f ${DEV} |
Bill Richardson | 3430b32 | 2010-11-29 14:24:51 -0800 | [diff] [blame] | 185 | assert_pri 6 6 4 5 6 6 6 6 6 6 6 0 0 6 |
| 186 | |
| 187 | # resurrect one, should not affect the others |
| 188 | make_pri 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |
Bill Richardson | 263ffdf | 2012-08-24 14:39:21 -0700 | [diff] [blame^] | 189 | $CGPT prioritize -i 2 ${DEV} |
Bill Richardson | 3430b32 | 2010-11-29 14:24:51 -0800 | [diff] [blame] | 190 | assert_pri 0 1 0 0 0 0 0 0 0 0 0 0 0 0 |
| 191 | |
| 192 | # resurrect one and all its friends |
| 193 | make_pri 0 0 0 0 0 0 0 0 1 2 0 0 0 0 |
Bill Richardson | 263ffdf | 2012-08-24 14:39:21 -0700 | [diff] [blame^] | 194 | $CGPT prioritize -P 5 -i 2 -f ${DEV} |
Bill Richardson | 3430b32 | 2010-11-29 14:24:51 -0800 | [diff] [blame] | 195 | assert_pri 5 5 5 5 5 5 5 5 3 4 5 5 5 5 |
| 196 | |
| 197 | # no options should maintain the same order |
Bill Richardson | 263ffdf | 2012-08-24 14:39:21 -0700 | [diff] [blame^] | 198 | $CGPT prioritize ${DEV} |
Bill Richardson | 3430b32 | 2010-11-29 14:24:51 -0800 | [diff] [blame] | 199 | assert_pri 3 3 3 3 3 3 3 3 1 2 3 3 3 3 |
| 200 | |
| 201 | # squish all the ranks |
| 202 | make_pri 1 1 2 2 3 3 4 4 5 5 0 6 7 7 |
Bill Richardson | 263ffdf | 2012-08-24 14:39:21 -0700 | [diff] [blame^] | 203 | $CGPT prioritize -P 6 ${DEV} |
Bill Richardson | 3430b32 | 2010-11-29 14:24:51 -0800 | [diff] [blame] | 204 | assert_pri 1 1 1 1 2 2 3 3 4 4 0 5 6 6 |
| 205 | |
| 206 | # squish the ranks by not leaving room |
| 207 | make_pri 1 1 2 2 3 3 4 4 5 5 0 6 7 7 |
Bill Richardson | 263ffdf | 2012-08-24 14:39:21 -0700 | [diff] [blame^] | 208 | $CGPT prioritize -P 7 -i 3 ${DEV} |
Bill Richardson | 3430b32 | 2010-11-29 14:24:51 -0800 | [diff] [blame] | 209 | assert_pri 1 1 7 1 2 2 3 3 4 4 0 5 6 6 |
| 210 | |
| 211 | # squish the ranks while bringing the friends along |
| 212 | make_pri 1 1 2 2 3 3 4 4 5 5 0 6 7 7 |
Bill Richardson | 263ffdf | 2012-08-24 14:39:21 -0700 | [diff] [blame^] | 213 | $CGPT prioritize -P 6 -i 3 -f ${DEV} |
Bill Richardson | 3430b32 | 2010-11-29 14:24:51 -0800 | [diff] [blame] | 214 | assert_pri 1 1 6 6 1 1 2 2 3 3 0 4 5 5 |
| 215 | |
| 216 | # squish them pretty hard |
| 217 | make_pri 1 1 2 2 3 3 4 4 5 5 0 6 7 7 |
Bill Richardson | 263ffdf | 2012-08-24 14:39:21 -0700 | [diff] [blame^] | 218 | $CGPT prioritize -P 2 ${DEV} |
Bill Richardson | 3430b32 | 2010-11-29 14:24:51 -0800 | [diff] [blame] | 219 | assert_pri 1 1 1 1 1 1 1 1 1 1 0 1 2 2 |
| 220 | |
| 221 | # squish them really really hard (nobody gets reduced to zero, though) |
| 222 | make_pri 1 1 2 2 3 3 4 4 5 5 0 6 7 7 |
Bill Richardson | 263ffdf | 2012-08-24 14:39:21 -0700 | [diff] [blame^] | 223 | $CGPT prioritize -P 1 -i 3 ${DEV} |
Bill Richardson | 3430b32 | 2010-11-29 14:24:51 -0800 | [diff] [blame] | 224 | assert_pri 1 1 1 1 1 1 1 1 1 1 0 1 1 1 |
| 225 | |
| 226 | # squish if we try to go too high |
| 227 | make_pri 15 15 14 14 13 13 12 12 11 11 10 10 9 9 8 8 7 7 6 6 5 5 4 4 3 3 2 2 1 1 0 |
Bill Richardson | 263ffdf | 2012-08-24 14:39:21 -0700 | [diff] [blame^] | 228 | $CGPT prioritize -i 3 ${DEV} |
Bill Richardson | 3430b32 | 2010-11-29 14:24:51 -0800 | [diff] [blame] | 229 | assert_pri 14 14 15 13 12 12 11 11 10 10 9 9 8 8 7 7 6 6 5 5 4 4 3 3 2 2 1 1 1 1 0 |
Bill Richardson | 263ffdf | 2012-08-24 14:39:21 -0700 | [diff] [blame^] | 230 | $CGPT prioritize -i 5 ${DEV} |
Bill Richardson | 3430b32 | 2010-11-29 14:24:51 -0800 | [diff] [blame] | 231 | assert_pri 13 13 14 12 15 11 10 10 9 9 8 8 7 7 6 6 5 5 4 4 3 3 2 2 1 1 1 1 1 1 0 |
| 232 | # but if I bring friends I don't have to squish |
Bill Richardson | 263ffdf | 2012-08-24 14:39:21 -0700 | [diff] [blame^] | 233 | $CGPT prioritize -i 1 -f ${DEV} |
Bill Richardson | 3430b32 | 2010-11-29 14:24:51 -0800 | [diff] [blame] | 234 | assert_pri 15 15 13 12 14 11 10 10 9 9 8 8 7 7 6 6 5 5 4 4 3 3 2 2 1 1 1 1 1 1 0 |
Bill Richardson | f1372d9 | 2010-06-11 09:15:55 -0700 | [diff] [blame] | 235 | |
Bill Richardson | 23429d3 | 2012-04-30 11:33:13 -0700 | [diff] [blame] | 236 | |
| 237 | # Now make sure that we don't need write access if we're just looking. |
| 238 | echo "Test read vs read-write access..." |
| 239 | chmod 0444 ${DEV} |
| 240 | |
| 241 | # These should fail |
Bill Richardson | 263ffdf | 2012-08-24 14:39:21 -0700 | [diff] [blame^] | 242 | $CGPT create -z ${DEV} 2>/dev/null && error |
| 243 | $CGPT add -i 2 -P 3 ${DEV} 2>/dev/null && error |
| 244 | $CGPT repair ${DEV} 2>/dev/null && error |
| 245 | $CGPT prioritize -i 3 ${DEV} 2>/dev/null && error |
Bill Richardson | 23429d3 | 2012-04-30 11:33:13 -0700 | [diff] [blame] | 246 | |
| 247 | # Most 'boot' usage should fail too. |
Bill Richardson | 263ffdf | 2012-08-24 14:39:21 -0700 | [diff] [blame^] | 248 | $CGPT boot -p ${DEV} 2>/dev/null && error |
Bill Richardson | 23429d3 | 2012-04-30 11:33:13 -0700 | [diff] [blame] | 249 | dd if=/dev/zero of=fake_mbr.bin bs=100 count=1 2>/dev/null |
Bill Richardson | 263ffdf | 2012-08-24 14:39:21 -0700 | [diff] [blame^] | 250 | $CGPT boot -b fake_mbr.bin ${DEV} 2>/dev/null && error |
| 251 | $CGPT boot -i 2 ${DEV} 2>/dev/null && error |
Bill Richardson | 23429d3 | 2012-04-30 11:33:13 -0700 | [diff] [blame] | 252 | |
| 253 | # These should pass |
Bill Richardson | 263ffdf | 2012-08-24 14:39:21 -0700 | [diff] [blame^] | 254 | $CGPT boot ${DEV} >/dev/null |
| 255 | $CGPT show ${DEV} >/dev/null |
| 256 | $CGPT find -t kernel ${DEV} >/dev/null |
Bill Richardson | 23429d3 | 2012-04-30 11:33:13 -0700 | [diff] [blame] | 257 | |
Bill Richardson | f1372d9 | 2010-06-11 09:15:55 -0700 | [diff] [blame] | 258 | echo "Done." |
| 259 | |
| 260 | happy "All tests passed." |