diff options
author | Tom Hughes <tomhughes@chromium.org> | 2023-03-16 15:22:57 -0700 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2023-03-24 23:26:58 +0000 |
commit | f874f77064dabd7252c652765e626829c2c39c1f (patch) | |
tree | 41aa74c4353544f2bf16f2b810141a11e89ed5a0 /test | |
parent | 2f43481a9e5cd627496121fd4c2f7d6d95989618 (diff) | |
download | chrome-ec-f874f77064dabd7252c652765e626829c2c39c1f.tar.gz |
test: Add a wrapper for googletest
This wrapper makes it possible for unit tests that want to use
googletest just need to include "ec_test.h". All googletest test cases
will automatically be run. Failure/success is printed in the same format
as traditional EC tests for compatibility.
BRANCH=none
BUG=b:254530679
TEST=make BOARD=bloonchipper test-fpsensor_hw -j
TEST=make BOARD=dartmonkey test-fpsensor_hw -j
Change-Id: I96bfd2067ad53412998184657b5a6cbb1e24126a
Signed-off-by: Tom Hughes <tomhughes@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4348158
Reviewed-by: Andrea Grandi <agrandi@google.com>
Reviewed-by: Firas Sammoura <fsammoura@google.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/ec_gtest.h | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/test/ec_gtest.h b/test/ec_gtest.h new file mode 100644 index 0000000000..bf30a35724 --- /dev/null +++ b/test/ec_gtest.h @@ -0,0 +1,35 @@ +/* Copyright 2023 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/** + * @file + * @brief Tests that want to utilize googletest should include this header file. + * + * There's no need to include the googletest header files directly. + */ + +#ifndef __CROS_EC_TEST_EC_GTEST_H +#define __CROS_EC_TEST_EC_GTEST_H + +#include <gtest/gtest.h> + +static inline void run_all_googletest_tests() +{ + testing::InitGoogleTest(); + + int ret = RUN_ALL_TESTS(); + + if (ret == 0) + printf("Pass!\n"); + else + printf("Fail!\n"); +} + +extern "C" void run_test(int, const char **) +{ + run_all_googletest_tests(); +} + +#endif /* __CROS_EC_TEST_EC_GTEST_H */ |