if (unary_assert->expected_true)
string_stream_add(stream,
KUNIT_SUBTEST_INDENT "Expected %s to be true, but is false\n",
unary_assert->condition); else
string_stream_add(stream,
KUNIT_SUBTEST_INDENT "Expected %s to be false, but is true\n",
unary_assert->condition);
kunit_assert_print_msg(message, stream);
}
EXPORT_SYMBOL_GPL(kunit_unary_assert_format);
if (!ptr_assert->value) {
string_stream_add(stream,
KUNIT_SUBTEST_INDENT "Expected %s is not null, but is\n",
ptr_assert->text);
} elseif (IS_ERR(ptr_assert->value)) {
string_stream_add(stream,
KUNIT_SUBTEST_INDENT "Expected %s is not error, but is: %ld\n",
ptr_assert->text,
PTR_ERR(ptr_assert->value));
}
kunit_assert_print_msg(message, stream);
}
EXPORT_SYMBOL_GPL(kunit_ptr_not_err_assert_format);
/* Checks if `text` is a literal representing `value`, e.g. "5" and 5 */
VISIBLE_IF_KUNIT bool is_literal(constchar *text, longlong value)
{ char *buffer; int len; bool ret;
len = snprintf(NULL, 0, "%lld", value); if (strlen(text) != len) returnfalse;
buffer = kmalloc(len+1, GFP_KERNEL); if (!buffer) returnfalse;
/* Checks if KUNIT_EXPECT_STREQ() args were string literals. * Note: `text` will have ""s where as `value` will not.
*/
VISIBLE_IF_KUNIT bool is_str_literal(constchar *text, constchar *value)
{ int len;
len = strlen(text); if (len < 2) returnfalse; if (text[0] != '\"' || text[len - 1] != '\"') returnfalse;
/* Adds a hexdump of a buffer to a string_stream comparing it with * a second buffer. The different bytes are marked with <>.
*/
VISIBLE_IF_KUNIT void kunit_assert_hexdump(struct string_stream *stream, constvoid *buf, constvoid *compared_buf, const size_t len)
{
size_t i; const u8 *buf1 = buf; const u8 *buf2 = compared_buf;
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.