From 42c08cb2dac102509491810361e239fbde52b9e0 Mon Sep 17 00:00:00 2001 From: Albert Chaulk Date: Tue, 2 Apr 2013 14:38:07 -0700 Subject: Add MTD test script So the quick & dirty hack is to just modify the cgpt command to be cgpt -N= 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 Reviewed-by: Randall Spangler Commit-Queue: Albert Chaulk Tested-by: Albert Chaulk (cherry picked from commit 53fd488fc772e2ed964331fe98eaa21d2a1e471b) Change-Id: Id7af245cc0e8c2dc00fe9ceab9ce0be0e47882ec Reviewed-on: https://gerrit.chromium.org/gerrit/49796 Reviewed-by: Randall Spangler Commit-Queue: Albert Chaulk Tested-by: Albert Chaulk --- Makefile | 1 + tests/run_cgpt_tests.sh | 51 +++++++++++++++++++++++++++++-------------------- 2 files changed, 31 insertions(+), 21 deletions(-) diff --git a/Makefile b/Makefile index 1aad0ae2..403b4d62 100644 --- a/Makefile +++ b/Makefile @@ -997,6 +997,7 @@ runcgpttests: test_setup .PHONY: runtestscripts runtestscripts: test_setup genfuzztestcases tests/run_cgpt_tests.sh ${BUILD_RUN}/cgpt/cgpt + tests/run_cgpt_tests.sh ${BUILD_RUN}/cgpt/cgpt -N=512,32,1,3 tests/run_preamble_tests.sh tests/run_rsa_tests.sh tests/run_vbutil_kernel_arg_tests.sh 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 -- cgit v1.2.1