From: Michal Wajdeczko <michal.wajdeczko@intel.com>
To: linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com
Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>,
Rae Moar <rmoar@google.com>, David Gow <davidgow@google.com>,
Lucas De Marchi <lucas.demarchi@intel.com>
Subject: [PATCH v2 2/6] kunit: Add macro to conditionally expose declarations to tests
Date: Tue, 27 Aug 2024 00:20:11 +0200 [thread overview]
Message-ID: <20240826222015.1484-3-michal.wajdeczko@intel.com> (raw)
In-Reply-To: <20240826222015.1484-1-michal.wajdeczko@intel.com>
The DECLARE_IF_KUNIT macro will introduces identifiers only if
CONFIG_KUNIT is enabled. Otherwise if CONFIG_KUNIT is not enabled
no identifiers from the param list will be defined.
Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Reviewed-by: Rae Moar <rmoar@google.com>
Reviewed-by: David Gow <davidgow@google.com>
---
Cc: Lucas De Marchi <lucas.demarchi@intel.com>
---
include/kunit/visibility.h | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/include/kunit/visibility.h b/include/kunit/visibility.h
index 0dfe35feeec6..1c23773f826c 100644
--- a/include/kunit/visibility.h
+++ b/include/kunit/visibility.h
@@ -11,6 +11,13 @@
#define _KUNIT_VISIBILITY_H
#if IS_ENABLED(CONFIG_KUNIT)
+ /**
+ * DECLARE_IF_KUNIT - A macro that introduces identifiers only if
+ * CONFIG_KUNIT is enabled. Otherwise if CONFIG_KUNIT is not enabled
+ * no identifiers will be defined.
+ * @body: identifiers to be introduced conditionally
+ */
+ #define DECLARE_IF_KUNIT(body...) body
/**
* VISIBLE_IF_KUNIT - A macro that sets symbols to be static if
* CONFIG_KUNIT is not enabled. Otherwise if CONFIG_KUNIT is enabled
@@ -26,6 +33,7 @@
#define EXPORT_SYMBOL_IF_KUNIT(symbol) EXPORT_SYMBOL_NS(symbol, \
EXPORTED_FOR_KUNIT_TESTING)
#else
+ #define DECLARE_IF_KUNIT(body...)
#define VISIBLE_IF_KUNIT static
#define EXPORT_SYMBOL_IF_KUNIT(symbol)
#endif
--
2.43.0
next prev parent reply other threads:[~2024-08-26 22:20 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-26 22:20 [PATCH v2 0/6] kunit: Add macros to help write more complex tests Michal Wajdeczko
2024-08-26 22:20 ` [PATCH v2 1/6] kunit: Introduce kunit_is_running() Michal Wajdeczko
2024-08-26 22:20 ` Michal Wajdeczko [this message]
2024-08-27 13:45 ` [PATCH v2 2/6] kunit: Add macro to conditionally expose declarations to tests Lucas De Marchi
2024-08-27 19:56 ` Michal Wajdeczko
2024-08-26 22:20 ` [PATCH v2 3/6] kunit: Add macro to conditionally expose expressions " Michal Wajdeczko
2024-08-27 19:04 ` Rae Moar
2024-08-27 19:47 ` Michal Wajdeczko
2024-08-26 22:20 ` [PATCH v2 4/6] kunit: Allow function redirection outside of the KUnit thread Michal Wajdeczko
2024-08-27 14:46 ` Lucas De Marchi
2024-08-27 20:30 ` Michal Wajdeczko
2024-08-29 15:56 ` Michal Wajdeczko
2024-08-26 22:20 ` [PATCH v2 5/6] kunit: Add example with alternate function redirection method Michal Wajdeczko
2024-08-27 14:18 ` Lucas De Marchi
2024-08-26 22:20 ` [PATCH v2 6/6] kunit: Add some selftests for global stub redirection macros Michal Wajdeczko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240826222015.1484-3-michal.wajdeczko@intel.com \
--to=michal.wajdeczko@intel.com \
--cc=davidgow@google.com \
--cc=kunit-dev@googlegroups.com \
--cc=linux-kselftest@vger.kernel.org \
--cc=lucas.demarchi@intel.com \
--cc=rmoar@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox