From cfcf6656b2de3491f1c9f61dc374f477b214128e Mon Sep 17 00:00:00 2001 From: Joel Kitching Date: Tue, 12 Mar 2019 17:40:09 +0800 Subject: vboot: futility test outputs should use relative directory Not everyone uses /mnt/host/source as their development environment. If running "make runtests" from a different directory, test_show_contents.sh fails, reporting different stdout for the various futility tests that it runs. Update test_show_contents.sh to use relative test paths, and update the expected output of futility runs. Also fix consistency of quoted variables. BUG=b:124141368 TEST=/work/vboot/src/repohooks/pre-upload.py TEST=make clean && make runtests BRANCH=none Change-Id: I35fd81734b6318a506613eb4f04bb7055709feef Signed-off-by: Joel Kitching Reviewed-on: https://chromium-review.googlesource.com/1517062 Commit-Ready: ChromeOS CL Exonerator Bot Tested-by: Joel Kitching Reviewed-by: Hung-Te Lin --- .../show.tests_devkeys_kernel.keyblock | 2 +- .../show.tests_devkeys_root_key.vbprivk | 2 +- .../show.tests_devkeys_root_key.vbpubk | 2 +- .../show.tests_futility_data_bios_mario_mp.bin | 2 +- .../show.tests_futility_data_bios_zgb_mp.bin | 2 +- .../show.tests_futility_data_fw_gbb.bin | 2 +- .../show.tests_futility_data_fw_vblock.bin | 2 +- .../show.tests_futility_data_kern_preamble.bin | 2 +- .../show.tests_futility_data_sample.vbprik2 | 2 +- .../show.tests_futility_data_sample.vbpubk2 | 2 +- .../show.tests_testkeys_key_rsa2048.pem | 2 +- .../show.tests_testkeys_key_rsa8192.pub.pem | 2 +- .../vbutil_key.tests_devkeys_root_key.vbprivk | 2 +- .../vbutil_key.tests_devkeys_root_key.vbpubk | 2 +- .../vbutil_keyblock.tests_devkeys_kernel.keyblock | 2 +- tests/futility/test_show_contents.sh | 51 +++++++++++----------- 16 files changed, 41 insertions(+), 40 deletions(-) (limited to 'tests/futility') diff --git a/tests/futility/expect_output/show.tests_devkeys_kernel.keyblock b/tests/futility/expect_output/show.tests_devkeys_kernel.keyblock index 16d56a7a..69c128e4 100644 --- a/tests/futility/expect_output/show.tests_devkeys_kernel.keyblock +++ b/tests/futility/expect_output/show.tests_devkeys_kernel.keyblock @@ -1,4 +1,4 @@ -Key block: /mnt/host/source/src/platform/vboot_reference/tests/devkeys/kernel.keyblock +Key block: tests/devkeys/kernel.keyblock Signature: ignored Size: 0x4b8 Flags: 7 !DEV DEV !REC diff --git a/tests/futility/expect_output/show.tests_devkeys_root_key.vbprivk b/tests/futility/expect_output/show.tests_devkeys_root_key.vbprivk index 40760ec9..473007bc 100644 --- a/tests/futility/expect_output/show.tests_devkeys_root_key.vbprivk +++ b/tests/futility/expect_output/show.tests_devkeys_root_key.vbprivk @@ -1,4 +1,4 @@ -Private Key file: /mnt/host/source/src/platform/vboot_reference/tests/devkeys/root_key.vbprivk +Private Key file: tests/devkeys/root_key.vbprivk Vboot API: 1.0 Algorithm: 11 RSA8192 SHA512 Key sha1sum: b11d74edd286c144e1135b49e7f0bc20cf041f10 diff --git a/tests/futility/expect_output/show.tests_devkeys_root_key.vbpubk b/tests/futility/expect_output/show.tests_devkeys_root_key.vbpubk index d6f26fba..90dd7c96 100644 --- a/tests/futility/expect_output/show.tests_devkeys_root_key.vbpubk +++ b/tests/futility/expect_output/show.tests_devkeys_root_key.vbpubk @@ -1,4 +1,4 @@ -Public Key file: /mnt/host/source/src/platform/vboot_reference/tests/devkeys/root_key.vbpubk +Public Key file: tests/devkeys/root_key.vbpubk Vboot API: 1.0 Algorithm: 11 RSA8192 SHA512 Key Version: 1 diff --git a/tests/futility/expect_output/show.tests_futility_data_bios_mario_mp.bin b/tests/futility/expect_output/show.tests_futility_data_bios_mario_mp.bin index 6241d7a8..882b9782 100644 --- a/tests/futility/expect_output/show.tests_futility_data_bios_mario_mp.bin +++ b/tests/futility/expect_output/show.tests_futility_data_bios_mario_mp.bin @@ -1,4 +1,4 @@ -BIOS: /mnt/host/source/src/platform/vboot_reference/tests/futility/data/bios_mario_mp.bin +BIOS: tests/futility/data/bios_mario_mp.bin GBB header: GBB Area Version: 1.0 Flags: 0x00000000 diff --git a/tests/futility/expect_output/show.tests_futility_data_bios_zgb_mp.bin b/tests/futility/expect_output/show.tests_futility_data_bios_zgb_mp.bin index 21106855..6a29c909 100644 --- a/tests/futility/expect_output/show.tests_futility_data_bios_zgb_mp.bin +++ b/tests/futility/expect_output/show.tests_futility_data_bios_zgb_mp.bin @@ -1,4 +1,4 @@ -BIOS: /mnt/host/source/src/platform/vboot_reference/tests/futility/data/bios_zgb_mp.bin +BIOS: tests/futility/data/bios_zgb_mp.bin GBB header: GBB Version: 1.0 Flags: 0x00000000 diff --git a/tests/futility/expect_output/show.tests_futility_data_fw_gbb.bin b/tests/futility/expect_output/show.tests_futility_data_fw_gbb.bin index 74ebc98c..ea202bfd 100644 --- a/tests/futility/expect_output/show.tests_futility_data_fw_gbb.bin +++ b/tests/futility/expect_output/show.tests_futility_data_fw_gbb.bin @@ -1,4 +1,4 @@ -GBB header: /mnt/host/source/src/platform/vboot_reference/tests/futility/data/fw_gbb.bin +GBB header: tests/futility/data/fw_gbb.bin Version: 1.1 Flags: 0x00000039 Regions: offset size diff --git a/tests/futility/expect_output/show.tests_futility_data_fw_vblock.bin b/tests/futility/expect_output/show.tests_futility_data_fw_vblock.bin index 67ee12fe..da764fb5 100644 --- a/tests/futility/expect_output/show.tests_futility_data_fw_vblock.bin +++ b/tests/futility/expect_output/show.tests_futility_data_fw_vblock.bin @@ -1,4 +1,4 @@ -Key block: /mnt/host/source/src/platform/vboot_reference/tests/futility/data/fw_vblock.bin +Key block: tests/futility/data/fw_vblock.bin Signature: ignored Size: 0x8b8 Flags: 7 !DEV DEV !REC diff --git a/tests/futility/expect_output/show.tests_futility_data_kern_preamble.bin b/tests/futility/expect_output/show.tests_futility_data_kern_preamble.bin index c6486839..3dba77ff 100644 --- a/tests/futility/expect_output/show.tests_futility_data_kern_preamble.bin +++ b/tests/futility/expect_output/show.tests_futility_data_kern_preamble.bin @@ -1,4 +1,4 @@ -Kernel partition: /mnt/host/source/src/platform/vboot_reference/tests/futility/data/kern_preamble.bin +Kernel partition: tests/futility/data/kern_preamble.bin Key block: Signature: ignored Size: 0x5b8 diff --git a/tests/futility/expect_output/show.tests_futility_data_sample.vbprik2 b/tests/futility/expect_output/show.tests_futility_data_sample.vbprik2 index 059972c7..4e0cb3a7 100644 --- a/tests/futility/expect_output/show.tests_futility_data_sample.vbprik2 +++ b/tests/futility/expect_output/show.tests_futility_data_sample.vbprik2 @@ -1,4 +1,4 @@ -Private key file: /mnt/host/source/src/platform/vboot_reference/tests/futility/data/sample.vbprik2 +Private key file: tests/futility/data/sample.vbprik2 Vboot API: 2.1 Desc: "sample vb21 keypair" Signature Algorithm: 5 RSA8192 diff --git a/tests/futility/expect_output/show.tests_futility_data_sample.vbpubk2 b/tests/futility/expect_output/show.tests_futility_data_sample.vbpubk2 index cd5654f0..4a7ee4a2 100644 --- a/tests/futility/expect_output/show.tests_futility_data_sample.vbpubk2 +++ b/tests/futility/expect_output/show.tests_futility_data_sample.vbpubk2 @@ -1,4 +1,4 @@ -Public Key file: /mnt/host/source/src/platform/vboot_reference/tests/futility/data/sample.vbpubk2 +Public Key file: tests/futility/data/sample.vbpubk2 Vboot API: 2.1 Desc: "sample vb21 keypair" Signature Algorithm: 5 RSA8192 diff --git a/tests/futility/expect_output/show.tests_testkeys_key_rsa2048.pem b/tests/futility/expect_output/show.tests_testkeys_key_rsa2048.pem index f3069968..08a8a2bf 100644 --- a/tests/futility/expect_output/show.tests_testkeys_key_rsa2048.pem +++ b/tests/futility/expect_output/show.tests_testkeys_key_rsa2048.pem @@ -1,3 +1,3 @@ -Private Key file: /mnt/host/source/src/platform/vboot_reference/tests/testkeys/key_rsa2048.pem +Private Key file: tests/testkeys/key_rsa2048.pem Key length: 2048 Key sha1sum: bfb2fa9188a87bf766dd7c313ea6802553b646b6 diff --git a/tests/futility/expect_output/show.tests_testkeys_key_rsa8192.pub.pem b/tests/futility/expect_output/show.tests_testkeys_key_rsa8192.pub.pem index 8b4993a4..41c14ec0 100644 --- a/tests/futility/expect_output/show.tests_testkeys_key_rsa8192.pub.pem +++ b/tests/futility/expect_output/show.tests_testkeys_key_rsa8192.pub.pem @@ -1,3 +1,3 @@ -Public Key file: /mnt/host/source/src/platform/vboot_reference/tests/testkeys/key_rsa8192.pub.pem +Public Key file: tests/testkeys/key_rsa8192.pub.pem Key length: 8192 Key sha1sum: f1afa44a1aed0d0e9ff630579df920a725e9de5e diff --git a/tests/futility/expect_output/vbutil_key.tests_devkeys_root_key.vbprivk b/tests/futility/expect_output/vbutil_key.tests_devkeys_root_key.vbprivk index fa020be5..bc116074 100644 --- a/tests/futility/expect_output/vbutil_key.tests_devkeys_root_key.vbprivk +++ b/tests/futility/expect_output/vbutil_key.tests_devkeys_root_key.vbprivk @@ -1,2 +1,2 @@ -Private Key file: /mnt/host/source/src/platform/vboot_reference/tests/devkeys/root_key.vbprivk +Private Key file: tests/devkeys/root_key.vbprivk Algorithm: 11 RSA8192 SHA512 diff --git a/tests/futility/expect_output/vbutil_key.tests_devkeys_root_key.vbpubk b/tests/futility/expect_output/vbutil_key.tests_devkeys_root_key.vbpubk index b0cd54a1..ad2bd19f 100644 --- a/tests/futility/expect_output/vbutil_key.tests_devkeys_root_key.vbpubk +++ b/tests/futility/expect_output/vbutil_key.tests_devkeys_root_key.vbpubk @@ -1,4 +1,4 @@ -Public Key file: /mnt/host/source/src/platform/vboot_reference/tests/devkeys/root_key.vbpubk +Public Key file: tests/devkeys/root_key.vbpubk Algorithm: 11 RSA8192 SHA512 Key Version: 1 Key sha1sum: b11d74edd286c144e1135b49e7f0bc20cf041f10 diff --git a/tests/futility/expect_output/vbutil_keyblock.tests_devkeys_kernel.keyblock b/tests/futility/expect_output/vbutil_keyblock.tests_devkeys_kernel.keyblock index 0dfa9737..b25c7f2c 100644 --- a/tests/futility/expect_output/vbutil_keyblock.tests_devkeys_kernel.keyblock +++ b/tests/futility/expect_output/vbutil_keyblock.tests_devkeys_kernel.keyblock @@ -1,4 +1,4 @@ -Key block file: /mnt/host/source/src/platform/vboot_reference/tests/devkeys/kernel.keyblock +Key block file: tests/devkeys/kernel.keyblock Signature valid Flags: 7 !DEV DEV !REC Data key algorithm: 4 RSA2048 SHA256 diff --git a/tests/futility/test_show_contents.sh b/tests/futility/test_show_contents.sh index f24c434d..e0403622 100755 --- a/tests/futility/test_show_contents.sh +++ b/tests/futility/test_show_contents.sh @@ -3,11 +3,11 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -me=${0##*/} +me="${0##*/}" TMP="$me.tmp" # Work in scratch directory -cd "$OUTDIR" +cd "${OUTDIR}" # Test 'futility show' against expected output SHOW_FILES=" @@ -29,12 +29,12 @@ for file in $SHOW_FILES; do outfile="show.${file//\//_}" gotfile="${OUTDIR}/${outfile}" wantfile="${SRCDIR}/tests/futility/expect_output/${outfile}" - ${FUTILITY} show "${SRCDIR}/${file}" | tee "${gotfile}" + ( cd "${SRCDIR}" && ${FUTILITY} show "${file}" ) | tee "${gotfile}" # Uncomment this to update the expected output - #cp ${gotfile} ${wantfile} + #cp "${gotfile}" "${wantfile}" - diff ${wantfile} ${gotfile} + diff "${wantfile}" "${gotfile}" done @@ -48,12 +48,13 @@ for file in $VBUTIL_KEY_FILES; do outfile="vbutil_key.${file//\//_}" gotfile="${OUTDIR}/${outfile}" wantfile="${SRCDIR}/tests/futility/expect_output/${outfile}" - ${FUTILITY} vbutil_key --unpack "${SRCDIR}/${file}" | tee "${gotfile}" + ( cd "${SRCDIR}" && ${FUTILITY} vbutil_key --unpack "${file}" ) \ + | tee "${gotfile}" # Uncomment this to update the expected output - #cp ${gotfile} ${wantfile} + #cp "${gotfile}" "${wantfile}" - diff ${wantfile} ${gotfile} + diff "${wantfile}" "${gotfile}" done @@ -62,18 +63,18 @@ file="tests/devkeys/kernel.keyblock" outfile="vbutil_keyblock.${file//\//_}" gotfile="${OUTDIR}/${outfile}" wantfile="${SRCDIR}/tests/futility/expect_output/${outfile}" -${FUTILITY} vbutil_keyblock --unpack "${SRCDIR}/${file}" \ - --signpubkey "${SRCDIR}/tests/devkeys/kernel_subkey.vbpubk" \ +( cd "${SRCDIR}" && ${FUTILITY} vbutil_keyblock --unpack "${file}" \ + --signpubkey "tests/devkeys/kernel_subkey.vbpubk" ) \ | tee "${gotfile}" # Uncomment this to update the expected output -#cp ${gotfile} ${wantfile} +#cp "${gotfile}" "${wantfile}" -diff ${wantfile} ${gotfile} +diff "${wantfile}" "${gotfile}" # Test 'futility vbutil_firmware' against expected output -KEYDIR=${SRCDIR}/tests/devkeys +KEYDIR="${SRCDIR}/tests/devkeys" outfile="vbutil_firmware.verify" gotfile="${OUTDIR}/${outfile}" wantfile="${SRCDIR}/tests/futility/expect_output/${outfile}" @@ -81,26 +82,26 @@ wantfile="${SRCDIR}/tests/futility/expect_output/${outfile}" # Create a firmware blob and vblock. Version and flags are just # arbitrary non-zero numbers so we can verify they're printed # properly. -dd bs=1024 count=16 if=/dev/urandom of=${TMP}.fw_main -${FUTILITY} vbutil_firmware --vblock ${TMP}.vblock.old \ - --keyblock ${KEYDIR}/firmware.keyblock \ - --signprivate ${KEYDIR}/firmware_data_key.vbprivk \ +dd bs=1024 count=16 if=/dev/urandom of="${TMP}.fw_main" +${FUTILITY} vbutil_firmware --vblock "${TMP}.vblock.old" \ + --keyblock "${KEYDIR}/firmware.keyblock" \ + --signprivate "${KEYDIR}/firmware_data_key.vbprivk" \ --version 12 \ - --fv ${TMP}.fw_main \ - --kernelkey ${KEYDIR}/kernel_subkey.vbpubk \ + --fv "${TMP}.fw_main" \ + --kernelkey "${KEYDIR}/kernel_subkey.vbpubk" \ --flags 42 # Verify -${FUTILITY} vbutil_firmware --verify ${TMP}.vblock.old \ - --signpubkey ${KEYDIR}/root_key.vbpubk \ - --fv ${TMP}.fw_main | tee "${gotfile}" +${FUTILITY} vbutil_firmware --verify "${TMP}.vblock.old" \ + --signpubkey "${KEYDIR}/root_key.vbpubk" \ + --fv "${TMP}.fw_main" | tee "${gotfile}" # Uncomment this to update the expected output -#cp ${gotfile} ${wantfile} +#cp "${gotfile}" "${wantfile}" -diff ${wantfile} ${gotfile} +diff "${wantfile}" "${gotfile}" # cleanup -rm -rf ${TMP}* +rm -rf "${TMP}*" exit 0 -- cgit v1.2.1