From 028f468aff976ef5e76f20133c64ec19cb9d1517 Mon Sep 17 00:00:00 2001 From: Randall Spangler Date: Tue, 19 Aug 2014 14:42:08 -0700 Subject: [PATCH] vboot2: Move vb2_verify_fw inside of futility Update the unit tests which use it to use futility. No functional changes to it, just relocation. Remove the futility test which checks the exact list of supported commands. This doesn't have a good way of handling conditionally-compiled commands, and will be even harder to maintain as we add more commands in the future. Presence of sub-commands is still ensured by the other tests which use them (such as vb2_firmware_tests.sh) BUG=chromium:231547 BRANCH=none TEST=make runtests && VBOOT2=1 make runtests Change-Id: Idddb639276e4c6449d023d40ac7977123113bd28 Signed-off-by: Randall Spangler Reviewed-on: https://chromium-review.googlesource.com/213191 Reviewed-by: Bill Richardson --- Makefile | 10 +++++----- .../cmd_vb2_verify_fw.c | 12 +++++++++++- tests/futility/test_main.sh | 16 ---------------- tests/vb2_firmware_tests.sh | 2 +- 4 files changed, 17 insertions(+), 23 deletions(-) rename utility/vb2_verify_fw.c => futility/cmd_vb2_verify_fw.c (93%) diff --git a/Makefile b/Makefile index fffcfb7b08..70cf79ddd2 100644 --- a/Makefile +++ b/Makefile @@ -490,11 +490,6 @@ UTIL_NAMES += \ utility/signature_digest_utility \ utility/verify_data -ifneq (${VBOOT2},) -UTIL_NAMES += \ - utility/vb2_verify_fw -endif - endif UTIL_BINS_STATIC := $(addprefix ${BUILD}/,${UTIL_NAMES_STATIC}) @@ -550,6 +545,11 @@ FUTIL_SRCS = \ futility/cmd_vbutil_key.c \ futility/cmd_vbutil_keyblock.c +ifneq (${VBOOT2},) +FUTIL_SRCS += \ + futility/cmd_vb2_verify_fw.c +endif + FUTIL_LDS = futility/futility.lds FUTIL_STATIC_OBJS = ${FUTIL_STATIC_SRCS:%.c=${BUILD}/%.o} diff --git a/utility/vb2_verify_fw.c b/futility/cmd_vb2_verify_fw.c similarity index 93% rename from utility/vb2_verify_fw.c rename to futility/cmd_vb2_verify_fw.c index f7ec0b5094..7343d7a4b0 100644 --- a/utility/vb2_verify_fw.c +++ b/futility/cmd_vb2_verify_fw.c @@ -11,6 +11,7 @@ #include "2sysincludes.h" #include "2api.h" +#include "futility.h" const char *progname = "vb2_verify_fw"; @@ -133,12 +134,18 @@ int hash_body(struct vb2_context *ctx) return VB2_SUCCESS; } -int main(int argc, char *argv[]) +int do_vb2_verify_fw(int argc, char *argv[]) { struct vb2_context ctx; uint8_t workbuf[16384]; int rv; + progname = strrchr(argv[0], '/'); + if (progname) + progname++; + else + progname = argv[0]; + if (argc < 4) { fprintf(stderr, "usage: %s \n", progname); @@ -207,3 +214,6 @@ int main(int argc, char *argv[]) return 0; } + +DECLARE_FUTIL_COMMAND(vb2_verify_fw, do_vb2_verify_fw, + "Verifies firmware using vboot2 library"); diff --git a/tests/futility/test_main.sh b/tests/futility/test_main.sh index 62177e68f9..5a09c2820b 100755 --- a/tests/futility/test_main.sh +++ b/tests/futility/test_main.sh @@ -12,22 +12,6 @@ cd "$OUTDIR" # No args returns nonzero exit code "$FUTILITY" && false -# Make sure all built-in commands are listed and have help -expected=\ -'dev_sign_file -dump_fmap -dump_kernel_config -gbb_utility -help -vbutil_firmware -vbutil_kernel -vbutil_key -vbutil_keyblock' -got=$("$FUTILITY" help | - egrep '^[[:space:]]+[^[:space:]]+[[:space:]]+[^[:space:]]+' | - awk '{print $1}') -[ "$expected" = "$got" ] - # It's weird but okay if the command is a full path. "$FUTILITY" /fake/path/to/help > "$TMP" grep Usage "$TMP" diff --git a/tests/vb2_firmware_tests.sh b/tests/vb2_firmware_tests.sh index a32dc6d800..e1981dba7b 100755 --- a/tests/vb2_firmware_tests.sh +++ b/tests/vb2_firmware_tests.sh @@ -52,6 +52,6 @@ ${BIN_DIR}/vbutil_firmware \ echo 'Verifying test firmware using vb2_verify_fw' # Verify the firmware using vboot2 utility -${BIN_DIR}/vb2_verify_fw gbb.test vblock.test body.test +${BIN_DIR}/futility vb2_verify_fw gbb.test vblock.test body.test happy 'vb2_verify_fw succeeded'