summaryrefslogtreecommitdiff
path: root/test/ec_gtest.h
diff options
context:
space:
mode:
Diffstat (limited to 'test/ec_gtest.h')
-rw-r--r--test/ec_gtest.h35
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 */