[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250520082435.2255639-4-tzungbi@kernel.org>
Date: Tue, 20 May 2025 08:24:30 +0000
From: Tzung-Bi Shih <tzungbi@...nel.org>
To: bleung@...omium.org,
brendan.higgins@...ux.dev,
davidgow@...gle.com
Cc: tzungbi@...nel.org,
rmoar@...gle.com,
rostedt@...dmis.org,
mhiramat@...nel.org,
naveen@...nel.org,
anil.s.keshavamurthy@...el.com,
davem@...emloft.net,
chrome-platform@...ts.linux.dev,
linux-kselftest@...r.kernel.org,
kunit-dev@...glegroups.com,
linux-trace-kernel@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [RFC PATCH 3/7] platform/chrome: kunit: cros_ec_i2c: Use static stub instead
For running the tests:
$ ./tools/testing/kunit/kunit.py run \
--arch=x86_64 \
--kconfig_add CONFIG_CHROME_PLATFORMS=y \
--kconfig_add CONFIG_CROS_EC=y \
--kconfig_add CONFIG_I2C=y \
--kconfig_add CONFIG_CROS_EC_I2C=y \
--kconfig_add CONFIG_CROS_KUNIT_EC_I2C_TEST=y \
cros_ec_i2c*
Signed-off-by: Tzung-Bi Shih <tzungbi@...nel.org>
---
drivers/platform/chrome/Kconfig | 1 -
drivers/platform/chrome/cros_ec.c | 6 ++++++
drivers/platform/chrome/cros_ec_i2c_test.c | 10 +++++-----
3 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/drivers/platform/chrome/Kconfig b/drivers/platform/chrome/Kconfig
index 5e0b44fb7ca7..bf10c0625be8 100644
--- a/drivers/platform/chrome/Kconfig
+++ b/drivers/platform/chrome/Kconfig
@@ -331,7 +331,6 @@ config CROS_KUNIT_EC_I2C_TEST
tristate "Kunit tests for ChromeOS EC over I2C" if !KUNIT_ALL_TESTS
depends on KUNIT && CROS_EC
default KUNIT_ALL_TESTS
- depends on KUNIT_FTRACE_STUBS
depends on CROS_EC_I2C
help
Kunit tests for ChromeOS EC over I2C.
diff --git a/drivers/platform/chrome/cros_ec.c b/drivers/platform/chrome/cros_ec.c
index 110771a8645e..62327fa0ff34 100644
--- a/drivers/platform/chrome/cros_ec.c
+++ b/drivers/platform/chrome/cros_ec.c
@@ -18,6 +18,8 @@
#include <linux/slab.h>
#include <linux/suspend.h>
+#include <kunit/static_stub.h>
+
#include "cros_ec.h"
static struct cros_ec_platform ec_p = {
@@ -179,6 +181,8 @@ static int cros_ec_ready_event(struct notifier_block *nb,
*/
int cros_ec_register(struct cros_ec_device *ec_dev)
{
+ KUNIT_STATIC_STUB_REDIRECT(cros_ec_register, ec_dev);
+
struct device *dev = ec_dev->dev;
int err = 0;
@@ -318,6 +322,8 @@ EXPORT_SYMBOL(cros_ec_register);
*/
void cros_ec_unregister(struct cros_ec_device *ec_dev)
{
+ KUNIT_STATIC_STUB_REDIRECT(cros_ec_unregister, ec_dev);
+
platform_device_unregister(ec_dev->pd);
platform_device_unregister(ec_dev->ec);
mutex_destroy(&ec_dev->lock);
diff --git a/drivers/platform/chrome/cros_ec_i2c_test.c b/drivers/platform/chrome/cros_ec_i2c_test.c
index 3a7f1a17d82d..5d41cdeec4b7 100644
--- a/drivers/platform/chrome/cros_ec_i2c_test.c
+++ b/drivers/platform/chrome/cros_ec_i2c_test.c
@@ -3,7 +3,7 @@
* Kunit tests for ChromeOS Embedded Controller I2C interface.
*/
#include <kunit/test.h>
-#include <kunit/ftrace_stub.h>
+#include <kunit/static_stub.h>
#include <linux/i2c.h>
#include <linux/platform_data/cros_ec_proto.h>
@@ -106,8 +106,8 @@ static int cros_ec_i2c_test_init(struct kunit *test)
I2C_BOARD_INFO("cros-ec-i2c", I2C_ADDR),
};
- kunit_activate_ftrace_stub(test, cros_ec_register, fake_cros_ec_register);
- kunit_activate_ftrace_stub(test, cros_ec_unregister, fake_cros_ec_unregister);
+ kunit_activate_static_stub(test, cros_ec_register, fake_cros_ec_register);
+ kunit_activate_static_stub(test, cros_ec_unregister, fake_cros_ec_unregister);
priv = kunit_kzalloc(test, sizeof(*priv), GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, priv);
@@ -142,8 +142,8 @@ static void cros_ec_i2c_test_exit(struct kunit *test)
i2c_del_adapter(priv->fake_adap);
- kunit_deactivate_ftrace_stub(test, cros_ec_register);
- kunit_deactivate_ftrace_stub(test, cros_ec_unregister);
+ kunit_deactivate_static_stub(test, cros_ec_register);
+ kunit_deactivate_static_stub(test, cros_ec_unregister);
}
static int cros_ec_i2c_test_cmd_xfer_init(struct kunit *test)
--
2.49.0.1101.gccaa498523-goog
Powered by blists - more mailing lists