diff options
author | Tom Hughes <tomhughes@chromium.org> | 2021-09-21 23:46:51 +0000 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-09-23 17:15:21 +0000 |
commit | 541e3dee10752720c2bba7e4d81544eaa284bfc6 (patch) | |
tree | 7dd10e9d76e0ac212e43eb4d3d874f73e9e581c1 | |
parent | da30d626148052f116da26301569f2897c70e66f (diff) | |
download | chrome-ec-541e3dee10752720c2bba7e4d81544eaa284bfc6.tar.gz |
test/utils: Switch to run-time test to fix clang build
The BUILD_ASSERT that was used fails to compile with clang:
error: static_assert expression is not an integral
constant expression
BUILD_ASSERT(str1 != str3)
BRANCH=none
BUG=b:172020503
TEST=make buildall -j
TEST=./test/run_device_tests.py --board dartmonkey --compiler clang
--tests=utils --remote 127.0.0.1:2551
TEST=./test/run_device_tests.py --board dartmonkey --compiler gcc
--tests=utils --remote 127.0.0.1:2551
Signed-off-by: Tom Hughes <tomhughes@chromium.org>
Change-Id: Id93ea45b653b86fd5a79ed565e1fa94ffd317723
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3174596
Reviewed-by: Patrick Georgi <pgeorgi@chromium.org>
-rw-r--r-- | test/utils.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/test/utils.c b/test/utils.c index ede0c807ed..7fe27b4549 100644 --- a/test/utils.c +++ b/test/utils.c @@ -466,7 +466,10 @@ test_static int test_safe_memcmp(void) const char str2[] = "def"; const char str3[] = "abc"; - BUILD_ASSERT(str1 != str3); + /* Verify that the compiler hasn't optimized str1 and str3 to point + * to the same underlying memory. + */ + TEST_NE(str1, str3, "%p"); TEST_EQ(safe_memcmp(NULL, NULL, 0), 0, "%d"); TEST_EQ(safe_memcmp(str1, str2, sizeof(str1)), 1, "%d"); |