diff options
author | Albert Chaulk <achaulk@chromium.org> | 2013-04-02 14:38:07 -0700 |
---|---|---|
committer | ChromeBot <chrome-bot@google.com> | 2013-07-16 13:19:03 -0700 |
commit | 42c08cb2dac102509491810361e239fbde52b9e0 (patch) | |
tree | b02a783e11269bfac8a84d02b3b987857688f7a1 /tests | |
parent | 4464354b7805b7d81667d79624275f525b5a8b11 (diff) | |
download | vboot-42c08cb2dac102509491810361e239fbde52b9e0.tar.gz |
Add MTD test script
So the quick & dirty hack is to just modify the cgpt command to be
cgpt -N=<MTD magic> <rest of the commands>
There are a couple limitations of the MTD command versions that will cause
them to always fail, so they're skipped if the second argument is empty - boot,
adding unknown GUIDs and more than 15 partitions.
BUG=chromium:221745
TEST=MTD version of run_cgpt_tests.sh passes
BRANCH=none
Original-Change-Id: Ida0debdefdc736f38e616801f6a40e67d393f405
Reviewed-on: https://gerrit.chromium.org/gerrit/47177
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Albert Chaulk <achaulk@chromium.org>
Tested-by: Albert Chaulk <achaulk@chromium.org>
(cherry picked from commit 53fd488fc772e2ed964331fe98eaa21d2a1e471b)
Change-Id: Id7af245cc0e8c2dc00fe9ceab9ce0be0e47882ec
Reviewed-on: https://gerrit.chromium.org/gerrit/49796
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Albert Chaulk <achaulk@chromium.org>
Tested-by: Albert Chaulk <achaulk@chromium.org>
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/run_cgpt_tests.sh | 51 |
1 files changed, 30 insertions, 21 deletions
diff --git a/tests/run_cgpt_tests.sh b/tests/run_cgpt_tests.sh index 445070a4..847c0813 100755 --- a/tests/run_cgpt_tests.sh +++ b/tests/run_cgpt_tests.sh @@ -12,6 +12,9 @@ CGPT=$(readlink -f "$1") [ -x "$CGPT" ] || error "Can't execute $CGPT" +MTD="${2:-}" +CGPT="${CGPT} ${MTD}" + # Run tests in a dedicated directory for easy cleanup or debugging. DIR="${TEST_DIR}/cgpt_test_dir" [ -d "$DIR" ] || mkdir -p "$DIR" @@ -122,22 +125,25 @@ $CGPT add -i 1 -t reserved ${DEV} || error X=$($CGPT show -t -i 1 ${DEV} | tr 'A-Z' 'a-z') [ "$X" = "$FUTURE_GUID" ] || error # arbitrary value -$CGPT add -i 1 -t 610a563a-a55c-4ae0-ab07-86e5bb9db67f ${DEV} || error -X=$($CGPT show -t -i 1 ${DEV}) -[ "$X" = "610A563A-A55C-4AE0-AB07-86E5BB9DB67F" ] || error +if [ -z "$MTD" ]; then + $CGPT add -i 1 -t 610a563a-a55c-4ae0-ab07-86e5bb9db67f ${DEV} || error + X=$($CGPT show -t -i 1 ${DEV}) + [ "$X" = "610A563A-A55C-4AE0-AB07-86E5BB9DB67F" ] || error +fi $CGPT add -i 1 -t data ${DEV} || error X=$($CGPT show -t -i 1 ${DEV} | tr 'A-Z' 'a-z') [ "$X" = "$DATA_GUID" ] || error -echo "Set the boot partition.." -$CGPT boot -i ${KERN_NUM} ${DEV} >/dev/null - -echo "Check the PMBR's idea of the boot partition..." -X=$($CGPT boot ${DEV}) -Y=$($CGPT show -u -i $KERN_NUM $DEV) -[ "$X" = "$Y" ] || error +if [ -z "$MTD" ]; then + echo "Set the boot partition.." + $CGPT boot -i ${KERN_NUM} ${DEV} >/dev/null + echo "Check the PMBR's idea of the boot partition..." + X=$($CGPT boot ${DEV}) + Y=$($CGPT show -u -i $KERN_NUM $DEV) + [ "$X" = "$Y" ] || error +fi echo "Test the cgpt prioritize command..." @@ -170,7 +176,6 @@ assert_pri() { error 1 "expected priority \"$expected\", actual priority \"$actual\"" } - # no kernels at all. This should do nothing. $CGPT create ${DEV} $CGPT add -t rootfs -b 100 -s 1 ${DEV} @@ -248,15 +253,17 @@ make_pri 1 1 2 2 3 3 4 4 5 5 0 6 7 7 $CGPT prioritize -P 1 -i 3 ${DEV} assert_pri 1 1 1 1 1 1 1 1 1 1 0 1 1 1 -# squish if we try to go too high -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 -$CGPT prioritize -i 3 ${DEV} -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 -$CGPT prioritize -i 5 ${DEV} -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 -# but if I bring friends I don't have to squish -$CGPT prioritize -i 1 -f ${DEV} -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 +if [ -z "$MTD" ]; then # MTD doesn't support this many partitions + # squish if we try to go too high + 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 + $CGPT prioritize -i 3 ${DEV} + 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 + $CGPT prioritize -i 5 ${DEV} + 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 + # but if I bring friends I don't have to squish + $CGPT prioritize -i 1 -f ${DEV} + 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 +fi # Now make sure that we don't need write access if we're just looking. @@ -276,7 +283,9 @@ $CGPT boot -b fake_mbr.bin ${DEV} 2>/dev/null && error $CGPT boot -i 2 ${DEV} 2>/dev/null && error # These should pass -$CGPT boot ${DEV} >/dev/null +if [ -z "$MTD" ]; then + $CGPT boot ${DEV} >/dev/null +fi $CGPT show ${DEV} >/dev/null $CGPT find -t kernel ${DEV} >/dev/null |