summaryrefslogtreecommitdiff
path: root/zephyr/test/drivers/common/src/test_mocks.c
diff options
context:
space:
mode:
authorYuval Peress <peress@google.com>2022-07-24 21:31:52 -0600
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-07-25 20:51:37 +0000
commitc16f255ef203b67eb31cb727a98f96e3fbce1d4b (patch)
tree7f6b5f11e5221b9588795cd56dfd6db8dad90cc9 /zephyr/test/drivers/common/src/test_mocks.c
parent3524a1f7eb23533a4a6cffd4c69bd07cf1b43129 (diff)
downloadchrome-ec-c16f255ef203b67eb31cb727a98f96e3fbce1d4b.tar.gz
zephyr: test: migrate drivers test to twister
1. Move the common test logic to drivers/common with its own CMakeLists.txt 2. Move the drivers test suites to drivers/default with its own CMakeLists.txt 3. Add a Kconfig for each suite that can enable it, use Zephyr's add_subdirectory_ifdef to control which suites get added to the biary and verify that at least 1 suite was added. 4. Add a check for ZMAKE_PROJECT_NAME to still allow zmake commands 5. Add testcase.yaml which runs all the tests BRANCH=none BUG=b:240093007 TEST=./twister --coverage -p native_posix -T zephyr/test/drivers Signed-off-by: Yuval Peress <peress@google.com> Change-Id: Ib9d4ea4a8431539391cc5349a7a8fd7a7d21f120 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3784043 Reviewed-by: Tristan Honscheid <honscheid@google.com> Commit-Queue: Tristan Honscheid <honscheid@google.com>
Diffstat (limited to 'zephyr/test/drivers/common/src/test_mocks.c')
-rw-r--r--zephyr/test/drivers/common/src/test_mocks.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/zephyr/test/drivers/common/src/test_mocks.c b/zephyr/test/drivers/common/src/test_mocks.c
new file mode 100644
index 0000000000..f8bbb1a6c1
--- /dev/null
+++ b/zephyr/test/drivers/common/src/test_mocks.c
@@ -0,0 +1,35 @@
+/* Copyright 2021 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.
+ */
+
+#include <ztest.h>
+
+#include "test/drivers/test_mocks.h"
+
+DEFINE_FFF_GLOBALS;
+
+/* Mocks for common/init_rom.c */
+DEFINE_FAKE_VALUE_FUNC(const void *, init_rom_map, const void *, int);
+DEFINE_FAKE_VOID_FUNC(init_rom_unmap, const void *, int);
+DEFINE_FAKE_VALUE_FUNC(int, init_rom_copy, int, int, int);
+
+/* Mocks for common/system.c */
+DEFINE_FAKE_VALUE_FUNC(int, system_jumped_late);
+
+/**
+ * @brief Reset all the fakes before each test.
+ */
+static void fff_reset_rule_before(const struct ztest_unit_test *test,
+ void *data)
+{
+ ARG_UNUSED(test);
+ ARG_UNUSED(data);
+
+ RESET_FAKE(init_rom_map);
+ RESET_FAKE(init_rom_unmap);
+ RESET_FAKE(init_rom_copy);
+ RESET_FAKE(system_jumped_late);
+}
+
+ZTEST_RULE(fff_reset_rule, fff_reset_rule_before, NULL);