summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHung-Te Lin <hungte@chromium.org>2020-10-13 15:03:20 +0800
committerCommit Bot <commit-bot@chromium.org>2020-11-09 19:38:16 +0000
commit788f1341b3065de0a694dba9df17de501d31bbce (patch)
tree1a017d8f38028e8a8365e43eb3eed5e545706804
parentfec72c3f7148f124dec2f6d8eb02b2ec4e6b6a20 (diff)
downloadvboot-788f1341b3065de0a694dba9df17de501d31bbce.tar.gz
futility: update: support multi-line quirks
To support loading quirks from external files, we want to skip tab (\t) and new line characters (\n, \r). BRANCH=none BUG=b:169284414 TEST=make runtests Change-Id: If314d6cf36907837ce9c36b73337976ee0c6fad1 Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2467305 Reviewed-by: Karthikeyan Ramasubramanian <kramasub@chromium.org> Commit-Queue: Karthikeyan Ramasubramanian <kramasub@chromium.org> Signed-off-by: Martin Roth <martinroth@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2527301 Tested-by: Martin Roth <martinroth@google.com> Reviewed-by: Martin Roth <martinroth@google.com> Commit-Queue: Martin Roth <martinroth@google.com>
-rw-r--r--futility/updater.c8
-rwxr-xr-xtests/futility/test_update.sh5
2 files changed, 11 insertions, 2 deletions
diff --git a/futility/updater.c b/futility/updater.c
index 8048a5b7..3e3dce2d 100644
--- a/futility/updater.c
+++ b/futility/updater.c
@@ -188,14 +188,18 @@ static int setup_config_quirks(const char *quirks, struct updater_config *cfg)
int r = 0;
char *buf = strdup(quirks);
char *token;
+ const char *delimiters = ", \n\r\t";
- token = strtok(buf, ", ");
- for (; token; token = strtok(NULL, ", ")) {
+ token = strtok(buf, delimiters);
+ for (; token; token = strtok(NULL, delimiters)) {
const char *name = token;
char *equ = strchr(token, '=');
int i, value = 1;
struct quirk_entry *entry = cfg->quirks;
+ if (!*name)
+ continue;
+
if (equ) {
*equ = '\0';
value = strtol(equ + 1, NULL, 0);
diff --git a/tests/futility/test_update.sh b/tests/futility/test_update.sh
index 57b3f460..655bab4a 100755
--- a/tests/futility/test_update.sh
+++ b/tests/futility/test_update.sh
@@ -327,6 +327,11 @@ test_update "Full update (--quirks enlarge_image)" \
"${FROM_IMAGE}.large" "${TMP}.expected.large" --quirks enlarge_image \
-i "${TO_IMAGE}" --wp=0 --sys_props 0,0x10001,1
+test_update "Full update (multi-line --quirks enlarge_image)" \
+ "${FROM_IMAGE}.large" "${TMP}.expected.large" --quirks '
+ enlarge_image
+ ' -i "${TO_IMAGE}" --wp=0 --sys_props 0,0x10001,1
+
test_update "Full update (--quirks unlock_me_for_update)" \
"${FROM_IMAGE}" "${TMP}.expected.me_unlocked" \
--quirks unlock_me_for_update \