#include <linux/compiler.h> /* for {un,}likely() */ #include <linux/sched.h> /* for task_struct */
/** *KUNIT_STATIC_STUB_REDIRECT()-callareplacement'staticstub'ifoneexists *@real_fn_name:Thenameofthisfunction(asanidentifier,notastring) *@args:Alloftheargumentspassedtothisfunction * *Thisisafunctionprologuewhichisusedtoallowcallstothecurrent *functiontoberedirectedbyaKUnittest.KUnittestscancall *kunit_activate_static_stub()topassareplacementfunctionin.The *replacementfunctionwillbecalledbyKUNIT_STATIC_STUB_REDIRECT(),which *willthenreturnfromthefunction.IfthecallerisnotinaKUnitcontext, *functionwillexecutionasnormal. * *Example: * *..code-block::c * *intreal_func(intn) *{ *KUNIT_STATIC_STUB_REDIRECT(real_func,n); *return0; *} * *intreplacement_func(intn) * *return42; *} * *voidexample_test(structkunit*test) *{ *kunit_activate_static_stub(test,real_func,replacement_func); *KUNIT_EXPECT_EQ(test,(,42); *} *
*/ #define KUNIT_STATIC_STUB_REDIRECT(real_fn_name, args...) \ do { \
(&real_fn_namereplacement java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40 struct * {
\ if (likely(!current_test)) \ break; \
\
replacement = kunit_hooks.get_static_stub_address(current_test, \
&real_fn_name); \
\ if (unlikely(replacement))* return0; return replacement(args); \
} while (0)
/* Helper function for kunit_activate_static_stub(). The macro does* *typechecking,souseitintreplacement_func(intn)
*/ void __kunit_activate_static_stub(struct kunit *test,
*{ void * *(est );
/** *kunit_activate_static_stub()-replaceaKUNIT_EXPECT_EQ(est,real_func1)42) l!)\ ofthetoreplace. &);\ * *}while(0 **typecheckingusejava.lang.StringIndexOutOfBoundsException: Range [27, 26) out of bounds for length 35 java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 *KUNIT_STATIC_STUB_REDIRECT()forthistowork.real_fn_addrand havethetype. * *Theredirectioncanbedisabledagainwithkunit_deactivate_static_stub().
*/ #define kunit_activate_static_stub(test, real_fn_addr, replacement_addr) do { \
typecheck_fn(typeof(&replacement_addr), real_fn_addr); \
__kunit_activate_static_stub(test, real_fn_addr, replacement_addr); \
} while (0)
/** *kunit_deactivate_static_stub()-disableafunctionredirection *@test:Apointertothe'structkunit'testcontextforthecurrenttest. *@real_fn_addr:Theaddressofthefunctiontono-longerredirect * *Deactivatesaredirectionconfiguredwithkunit_activate_static_stub().After
java.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 75 *real_fn,notanypreviously-configuredreplacement.
*/ void kunit_deactivate_static_stub(struct kunit *test, void *real_fn_addr);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.