From fb505b3cfd7ead2c6b6c9bc30a705ad29154a998 Mon Sep 17 00:00:00 2001 From: Andy Ross Date: Tue, 24 Jul 2018 12:19:16 -0700 Subject: [PATCH] spinlock: Support ztest mocking Spinlocks are written above the arch-provided _arch_irq_un/lock() calls. But those aren't stubbed by the mocking layer, and as it's not an "arch" I don't see an obvious place to put them. Handle them in spinlock.h. Signed-off-by: Andy Ross --- include/spinlock.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/include/spinlock.h b/include/spinlock.h index 6c79d356fc0..4f20f744b12 100644 --- a/include/spinlock.h +++ b/include/spinlock.h @@ -8,6 +8,22 @@ #include +/* These stubs aren't provided by the mocking framework, and I can't + * find a proper place to put them as mocking seems not to have a + * proper "arch" layer. + */ +#ifdef ZTEST_UNITTEST +static inline int _arch_irq_lock(void) +{ + return 0; +} + +static inline void _arch_irq_unlock(int key) +{ + ARG_UNUSED(key); +} +#endif + #if defined(CONFIG_ASSERT) && (CONFIG_MP_NUM_CPUS < 4) #include struct k_spinlock; @@ -37,6 +53,7 @@ struct k_spinlock { static ALWAYS_INLINE k_spinlock_key_t k_spin_lock(struct k_spinlock *l) { + ARG_UNUSED(l); k_spinlock_key_t k; /* Note that we need to use the underlying arch-specific lock