summaryrefslogtreecommitdiff
path: root/include/test_util.h
diff options
context:
space:
mode:
authorYuval Peress <peress@chromium.org>2019-10-01 00:51:23 -0600
committerCommit Bot <commit-bot@chromium.org>2019-12-18 01:29:10 +0000
commit61ef5715f654efeefea19c259f3eaf103c86c96d (patch)
tree962a58ba08017d3009c8dc2f552d4bb0f89baabd /include/test_util.h
parent093b5d0f9706268b1a077f87339fd7407345d3fa (diff)
downloadchrome-ec-61ef5715f654efeefea19c259f3eaf103c86c96d.tar.gz
common: Add sensor stillness detector
This change adds a stillness detector for 3d sensors. This will be needed to filter sensor readings when calibrating later. BUG=b:138303429,chromium:1023858 BRANCH=None TEST=buildall with new unit tests Change-Id: I919ae7533fd42b0394de66aa0585e58343a662cc Signed-off-by: Yuval Peress <peress@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1833157 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Diffstat (limited to 'include/test_util.h')
-rw-r--r--include/test_util.h16
1 files changed, 11 insertions, 5 deletions
diff --git a/include/test_util.h b/include/test_util.h
index 23034f918e..e10dcbe259 100644
--- a/include/test_util.h
+++ b/include/test_util.h
@@ -38,16 +38,22 @@
} \
} while (0)
+#if defined(__cplusplus) && !defined(__auto_type)
+#define __auto_type auto
+#endif
+
#define TEST_OPERATOR(a, b, op, fmt) \
do { \
- if (!((a) op (b))) { \
+ __auto_type _a = (a); \
+ __auto_type _b = (b); \
+ if (!(_a op _b)) { \
ccprintf("%d: ASSERSION failed: %s " #op " %s\n", \
__LINE__, #a, #b); \
ccprintf("\t\tEVAL: " fmt " " #op " " fmt "\n", \
- (a), (b)); \
- task_dump_trace(); \
- return EC_ERROR_UNKNOWN; \
- } \
+ _a, _b); \
+ task_dump_trace(); \
+ return EC_ERROR_UNKNOWN; \
+ } \
} while (0)
#define TEST_EQ(a, b, fmt) TEST_OPERATOR(a, b, ==, fmt)