From 9ab5743831f081d1b4d161fe28be711ef2d01d4c Mon Sep 17 00:00:00 2001 From: Yi Chou Date: Mon, 8 May 2023 11:15:51 +0800 Subject: test_util.h: Add TEST_ASSERT_ARRAY_NE BUG=b:248508087 make runhosttests -j200 >/dev/null Change-Id: I7fa48a68bc8a56fb94649a4a0930ce83df6d9a84 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4506541 Reviewed-by: Tom Hughes Commit-Queue: Yi Chou Tested-by: Yi Chou --- include/test_util.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'include') diff --git a/include/test_util.h b/include/test_util.h index 4f9869ab61..54da6a1d6c 100644 --- a/include/test_util.h +++ b/include/test_util.h @@ -19,6 +19,7 @@ extern "C" { #include "ec_commands.h" #include "math_util.h" #include "stack_trace.h" +#include "string.h" #ifdef CONFIG_ZTEST #include "ec_tasks.h" @@ -115,6 +116,19 @@ extern "C" { } \ } while (0) +#define TEST_ASSERT_ARRAY_NE(s, d, n) \ + do { \ + if (n < 0) \ + return EC_ERROR_UNKNOWN; \ + \ + if (memcmp(&s[0], &d[0], n) == 0) { \ + ccprintf("%s:%d: ASSERT_ARRAY_NE failed\n", __FILE__, \ + __LINE__); \ + task_dump_trace(); \ + return EC_ERROR_UNKNOWN; \ + } \ + } while (0) + #define TEST_ASSERT_MEMSET(d, c, n) \ do { \ if (n < 0) \ -- cgit v1.2.1