include/kunit/test-bug.h

Source file repositories/reference/linux-study-clean/include/kunit/test-bug.h

File Facts

System
Linux kernel
Corpus path
include/kunit/test-bug.h
Extension
.h
Size
3142 bytes
Lines
98
Domain
Repository Root And Misc
Bucket
include
Inferred role
Repository Root And Misc: implementation source
Status
source implementation candidate

Why This File Exists

Top-level or miscellaneous repository surface. Use this as map coverage unless a later manual pass promotes the file into a deeper subsystem dossier.

Dependency Surface

Detected Declarations

Annotated Snippet

if (static_branch_unlikely(&kunit_running)) {			\
			/* Guaranteed to be non-NULL when kunit_running true*/	\
			kunit_hooks.fail_current_test(__FILE__, __LINE__,	\
						  fmt, ##__VA_ARGS__);		\
		}								\
	} while (0)

/**
 * kunit_is_suppressed_warning() - Check if warnings are being suppressed
 *                                 by the current KUnit test.
 * @count: if true, increment the suppression counter on match.
 *
 * Returns true if the current task has active warning suppression.
 * Uses the kunit_running static branch for zero overhead when no tests run.
 *
 * A single WARN*() may traverse multiple call sites in the warning path
 * (e.g., __warn_printk() and __report_bug()). Pass @count = true at the
 * primary suppression point to count each warning exactly once, and
 * @count = false at secondary points to suppress output without
 * inflating the count.
 */
static inline bool kunit_is_suppressed_warning(bool count)
{
	if (!static_branch_unlikely(&kunit_running))
		return false;

	return kunit_hooks.is_suppressed_warning &&
	       kunit_hooks.is_suppressed_warning(count);
}

#else

static inline struct kunit *kunit_get_current_test(void) { return NULL; }
static inline bool kunit_is_suppressed_warning(bool count) { return false; }

#define kunit_fail_current_test(fmt, ...) do {} while (0)

#endif

#endif /* _KUNIT_TEST_BUG_H */

Annotation

Implementation Notes