diff options
author | Raul E Rangel <rrangel@chromium.org> | 2019-05-03 12:48:41 -0600 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2019-05-15 13:36:18 -0700 |
commit | aaba1d5efd51082d143ce2ac64e6caf9cb14d5e5 (patch) | |
tree | 2f270d3141f77192078c6578ef78648491477779 /test/is_enabled.c | |
parent | 1598a615eb150916ea323e212b87298c3a6fcfb6 (diff) | |
download | chrome-ec-aaba1d5efd51082d143ce2ac64e6caf9cb14d5e5.tar.gz |
ec: common: Make IS_ENABLED fail on unknown values
If IS_ENABLED is called with any unknown values, a compiler error will be
thrown. This change requires that the optimizer always be enabled,
otherwise errors will be thrown when a value is not defined.
BUG=none
BRANCH=none
TEST=make runtests TEST_LIST_HOST="is_enabled_error is_enabled"
Change-Id: I1b166311f81d07e48b3665f4bc0e9502d2ccc4c6
Signed-off-by: Raul E Rangel <rrangel@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1592728
Reviewed-by: Jett Rink <jettrink@chromium.org>
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
Diffstat (limited to 'test/is_enabled.c')
-rw-r--r-- | test/is_enabled.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/test/is_enabled.c b/test/is_enabled.c new file mode 100644 index 0000000000..c994d84b45 --- /dev/null +++ b/test/is_enabled.c @@ -0,0 +1,35 @@ +/* Copyright 2019 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + * + * Test the IS_ENABLED macro. + */ +#include "common.h" +#include "test_util.h" + +#undef CONFIG_UNDEFINED +#define CONFIG_BLANK + +static int test_undef(void) +{ + TEST_ASSERT(IS_ENABLED(CONFIG_UNDEFINED) == 0); + + return EC_SUCCESS; +} + +static int test_blank(void) +{ + TEST_ASSERT(IS_ENABLED(CONFIG_BLANK) == 1); + + return EC_SUCCESS; +} + +void run_test(void) +{ + test_reset(); + + RUN_TEST(test_undef); + RUN_TEST(test_blank); + + test_print_result(); +} |