summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCraig Hesling <hesling@chromium.org>2019-12-18 11:09:38 -0800
committerCommit Bot <commit-bot@chromium.org>2019-12-23 15:07:37 +0000
commitd2d4825f22d16cec6c827d415b68a2c0e7f820d5 (patch)
treeb4dcd6c1407a45ca7d34c006a788fcf92d0f599e
parent890d57187e8280417426d2cbb03dc011a49e33aa (diff)
downloadchrome-ec-d2d4825f22d16cec6c827d415b68a2c0e7f820d5.tar.gz
test/compile_time_macros: Add BIT and BIT_ULL
This is really just for completeness. BRANCH=all BUG=none TEST=make buildall TEST=make run-compile_time_macros Change-Id: I8f0166ce502b310d9491fd83cde31072ee2530ef Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1974550 Tested-by: Craig Hesling <hesling@chromium.org> Auto-Submit: Craig Hesling <hesling@chromium.org> Commit-Queue: Jett Rink <jettrink@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1979588 Tested-by: Tim Wawrzynczak <twawrzynczak@chromium.org> Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org> Commit-Queue: Tim Wawrzynczak <twawrzynczak@chromium.org>
-rw-r--r--test/compile_time_macros.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/compile_time_macros.c b/test/compile_time_macros.c
index 28e7af500b..9ef52bc7e3 100644
--- a/test/compile_time_macros.c
+++ b/test/compile_time_macros.c
@@ -9,6 +9,25 @@
#include "test_util.h"
+static int test_BIT(void)
+{
+ TEST_EQ(BIT(0), 0x00000001U, "%u");
+ TEST_EQ(BIT(25), 0x02000000U, "%u");
+ TEST_EQ(BIT(31), 0x80000000U, "%u");
+
+ return EC_SUCCESS;
+}
+
+static int test_BIT_ULL(void)
+{
+ TEST_EQ(BIT_ULL(0), 0x0000000000000001ULL, "%Lu");
+ TEST_EQ(BIT_ULL(25), 0x0000000002000000ULL, "%Lu");
+ TEST_EQ(BIT_ULL(50), 0x0004000000000000ULL, "%Lu");
+ TEST_EQ(BIT_ULL(63), 0x8000000000000000ULL, "%Lu");
+
+ return EC_SUCCESS;
+}
+
static int test_GENMASK(void)
{
TEST_EQ(GENMASK(0, 0), 0x00000001U, "%u");
@@ -40,6 +59,8 @@ void run_test(void)
{
test_reset();
+ RUN_TEST(test_BIT);
+ RUN_TEST(test_BIT_ULL);
RUN_TEST(test_GENMASK);
RUN_TEST(test_GENMASK_ULL);