summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorTom Hughes <tomhughes@chromium.org>2022-07-11 09:40:53 -0700
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-07-12 17:04:21 +0000
commitc0f4b8bec7ccb755fb1151b01816d6cf5d26fdfa (patch)
tree3a48094d415e60a523e66a5439f981c4ca9d5385 /test
parent262627097854b564194376107cc47217fdb87a74 (diff)
downloadchrome-ec-c0f4b8bec7ccb755fb1151b01816d6cf5d26fdfa.tar.gz
test/printf: Fix invalid %p format test
When the size passed to crec_vsnprintf is 0, the function will immediately return with -EC_ERROR_INVAL, which is not testing the code path that these tests were intending. Change the size to the size of the output buffer so the code in vfnprintf is executed. Note that crec_vsnprintf always adds a terminating NUL, so the buffer is modified even though the format was incorrect. BRANCH=none BUG=b:238433667, b:234181908 TEST=make buildall Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: Iade22f224f7f946c3c345f47e0496cd3f1754b63 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3756175 Reviewed-by: Denis Brockus <dbrockus@chromium.org>
Diffstat (limited to 'test')
-rw-r--r--test/printf.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/test/printf.c b/test/printf.c
index 388e0c7e80..8ad84f46c4 100644
--- a/test/printf.c
+++ b/test/printf.c
@@ -291,11 +291,11 @@ test_static int test_vsnprintf_pointers(void)
T(expect_success("55005e00", "%pP", ptr));
T(expect_success(err_str, "%P", ptr));
/* %p by itself is invalid */
- T(expect(EC_ERROR_INVAL, NO_BYTES_TOUCHED, false, 0, "%p"));
+ T(expect(EC_ERROR_INVAL, "", false, sizeof(output), "%p"));
/* %p with an unknown suffix is invalid */
- T(expect(EC_ERROR_INVAL, NO_BYTES_TOUCHED, false, 0, "%p "));
+ T(expect(EC_ERROR_INVAL, "", false, sizeof(output), "%p "));
/* %p with an unknown suffix is invalid */
- T(expect(EC_ERROR_INVAL, NO_BYTES_TOUCHED, false, 0, "%pQ"));
+ T(expect(EC_ERROR_INVAL, "", false, sizeof(output), "%pQ"));
/* Test %pb, binary format */
T(expect_success("0", "%pb", BINARY_VALUE(val, 0)));