Skip to content

Commit

Permalink
HID: uclogic: Use KUNIT_EXPECT_MEMEQ
Browse files Browse the repository at this point in the history
Commit b8a926b ("kunit: Introduce KUNIT_EXPECT_MEMEQ and
KUNIT_EXPECT_MEMNEQ macros") introduced a new macro to compare blocks of
memory and, if the test fails, print the result in a human friendly
format. For example, this is the output of a test failure:

 Expected res == params->expected, but
     res ==
      01  02  aa  00  00  00  03  bb  00 <00> 00  04  05
     params->expected ==
      01  02  aa  00  00  00  03  bb  00 <01> 00  04  05

Use this new macro to replace KUNIT_EXPECT_EQ + memcmp.

Signed-off-by: José Expósito <jose.exposito89@gmail.com>
Reviewed-by: Maíra Canal <mairacanal@riseup.net>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
  • Loading branch information
José Expósito authored and Jiri Kosina committed Jan 18, 2023
1 parent 9266a88 commit f5379a0
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions drivers/hid/hid-uclogic-rdesc-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,7 @@ static void hid_test_uclogic_template(struct kunit *test)
params->param_list,
params->param_num);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, res);
KUNIT_EXPECT_EQ(test, 0,
memcmp(res, params->expected, params->template_size));
KUNIT_EXPECT_MEMEQ(test, res, params->expected, params->template_size);
kfree(res);
}

Expand Down

0 comments on commit f5379a0

Please sign in to comment.