summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBill Richardson <wfrichar@chromium.org>2012-03-19 12:47:18 -0700
committerGerrit <chrome-bot@google.com>2012-03-20 10:26:44 -0700
commit72e344d5cdc67e4eb129bb1308ce0e5cca503d2d (patch)
tree8dba5f6525994472b83f548a815e02033f9a51fd /tests
parente62e316ecf34b17a65e7781335ed206d0ffbb679 (diff)
downloadvboot-72e344d5cdc67e4eb129bb1308ce0e5cca503d2d.tar.gz
Major refactoring of vbutil_kernel
This started out as a simple fix for a minor bug and turned into a nearly complete rewrite. Now that it's done I'm not sure it really matters. This version is a lot cleaner about handling command-line args, but isn't otherwise noticeably better. Sigh. BUG=none TEST=manual make make runtests Change-Id: I9c194e9c0e6418488635989ef666bc83c6e39816 Reviewed-on: https://gerrit.chromium.org/gerrit/18268 Commit-Ready: Bill Richardson <wfrichar@chromium.org> Tested-by: Bill Richardson <wfrichar@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'tests')
-rwxr-xr-xtests/run_vbutil_kernel_arg_tests.sh106
1 files changed, 105 insertions, 1 deletions
diff --git a/tests/run_vbutil_kernel_arg_tests.sh b/tests/run_vbutil_kernel_arg_tests.sh
index bba3b488..7f59ef91 100755
--- a/tests/run_vbutil_kernel_arg_tests.sh
+++ b/tests/run_vbutil_kernel_arg_tests.sh
@@ -12,6 +12,7 @@
. "$(dirname "$0")/common.sh"
# directories
+DEVKEYS="${ROOT_DIR}/tests/devkeys"
DATA_DIR="${SCRIPT_DIR}/preamble_tests/data"
TMPDIR="${TEST_DIR}/vbutil_kernel_arg_tests_dir"
[ -d "${TMPDIR}" ] || mkdir -p "${TMPDIR}"
@@ -43,7 +44,7 @@ while [ "$k" -lt "${#KERN_VALS[*]}" ]; do
while [ "$b" -lt "${#BOOT_VALS[*]}" ]; do
echo -n "pack kern_${k}_${b}.vblock ... "
: $(( tests++ ))
- ${UTIL_DIR}/vbutil_kernel --pack "${TMPDIR}/kern_${k}_${b}.vblock" \
+ "${UTIL_DIR}/vbutil_kernel" --pack "${TMPDIR}/kern_${k}_${b}.vblock" \
--keyblock "${KEYBLOCK}" \
--signprivate "${SIGNPRIVATE}" \
--version 1 \
@@ -86,6 +87,109 @@ for v in ${TMPDIR}/kern_*.vblock; do
fi
done
+
+
+# Test repacking a USB image for the SSD, the way the installer does.
+
+set -e
+# Pack for USB
+USB_KERN="${TMPDIR}/usb_kern.bin"
+USB_KEYBLOCK="${DEVKEYS}/recovery_kernel.keyblock"
+USB_SIGNPRIVATE="${DEVKEYS}/recovery_kernel_data_key.vbprivk"
+USB_SIGNPUBKEY="${DEVKEYS}/recovery_key.vbpubk"
+echo -n "pack USB kernel ... "
+: $(( tests++ ))
+"${UTIL_DIR}/vbutil_kernel" \
+ --pack "${USB_KERN}" \
+ --keyblock "${USB_KEYBLOCK}" \
+ --signprivate "${USB_SIGNPRIVATE}" \
+ --version 1 \
+ --config "${CONFIG}" \
+ --bootloader "${BIG}" \
+ --vmlinuz "${BIG}" \
+ --arch arm
+if [ "$?" -ne 0 ]; then
+ echo -e "${COL_RED}FAILED${COL_STOP}"
+ : $(( errs++ ))
+else
+ echo -e "${COL_GREEN}PASSED${COL_STOP}"
+fi
+
+# And verify it.
+echo -n "verify USB kernel ... "
+: $(( tests++ ))
+"${UTIL_DIR}/vbutil_kernel" \
+ --verify "${USB_KERN}" \
+ --signpubkey "${USB_SIGNPUBKEY}" >/dev/null
+if [ "$?" -ne 0 ]; then
+ echo -e "${COL_RED}FAILED${COL_STOP}"
+ : $(( errs++ ))
+else
+ echo -e "${COL_GREEN}PASSED${COL_STOP}"
+fi
+
+# Now we re-sign the same image using the normal keys. This is the kernel
+# image that is put on the hard disk by the installer. Note: To save space on
+# the USB image, we're only emitting the new verfication block, and the
+# installer just replaces that part of the hard disk's kernel partition.
+SSD_KERN="${TMPDIR}/ssd_kern.bin"
+SSD_KEYBLOCK="${DEVKEYS}/kernel.keyblock"
+SSD_SIGNPRIVATE="${DEVKEYS}/kernel_data_key.vbprivk"
+SSD_SIGNPUBKEY="${DEVKEYS}/kernel_subkey.vbpubk"
+echo -n "repack to SSD kernel ... "
+: $(( tests++ ))
+"${UTIL_DIR}/vbutil_kernel" \
+ --repack "${SSD_KERN}" \
+ --vblockonly \
+ --keyblock "${SSD_KEYBLOCK}" \
+ --signprivate "${SSD_SIGNPRIVATE}" \
+ --oldblob "${TMPDIR}/usb_kern.bin" >/dev/null
+if [ "$?" -ne 0 ]; then
+ echo -e "${COL_RED}FAILED${COL_STOP}"
+ : $(( errs++ ))
+else
+ echo -e "${COL_GREEN}PASSED${COL_STOP}"
+fi
+
+# To verify it, we have to replace the vblock from the original image.
+tempfile="${TMPDIR}/foo.bin"
+cat "${SSD_KERN}" > "$tempfile"
+dd if="${USB_KERN}" bs=65536 skip=1 >> $tempfile 2>/dev/null
+
+echo -n "verify SSD kernel ... "
+: $(( tests++ ))
+"${UTIL_DIR}/vbutil_kernel" \
+ --verify "$tempfile" \
+ --signpubkey "${SSD_SIGNPUBKEY}" >/dev/null
+if [ "$?" -ne 0 ]; then
+ echo -e "${COL_RED}FAILED${COL_STOP}"
+ : $(( errs++ ))
+else
+ echo -e "${COL_GREEN}PASSED${COL_STOP}"
+fi
+
+# Finally make sure that the kernel command line stays good.
+orig=$(cat "${CONFIG}" | tr '\012' ' ')
+packed=$("${UTIL_DIR}/dump_kernel_config" "${USB_KERN}")
+echo -n "check USB kernel config ..."
+: $(( tests++ ))
+if [ "$orig" != "$packed" ]; then
+ echo -e "${COL_RED}FAILED${COL_STOP}"
+ : $(( errs++ ))
+else
+ echo -e "${COL_GREEN}PASSED${COL_STOP}"
+fi
+
+repacked=$("${UTIL_DIR}/dump_kernel_config" "${tempfile}")
+echo -n "check SSD kernel config ..."
+: $(( tests++ ))
+if [ "$orig" != "$packed" ]; then
+ echo -e "${COL_RED}FAILED${COL_STOP}"
+ : $(( errs++ ))
+else
+ echo -e "${COL_GREEN}PASSED${COL_STOP}"
+fi
+
# Summary
ME=$(basename "$0")
if [ "$errs" -ne 0 ]; then