Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Register
  • Sign in
  • L linux
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • Deployments
    • Deployments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • Kirill Smelkov
  • linux
  • Repository
You need to sign in or sign up before continuing.
  • linux
  • lib
  • kunit
  • assert.c
Find file BlameHistoryPermalink
  • Maíra Canal's avatar
    kunit: Introduce KUNIT_EXPECT_MEMEQ and KUNIT_EXPECT_MEMNEQ macros · b8a926be
    Maíra Canal authored Oct 25, 2022
    
    
    Currently, in order to compare memory blocks in KUnit, the KUNIT_EXPECT_EQ
    or KUNIT_EXPECT_FALSE macros are used in conjunction with the memcmp
    function, such as:
        KUNIT_EXPECT_EQ(test, memcmp(foo, bar, size), 0);
    
    Although this usage produces correct results for the test cases, when
    the expectation fails, the error message is not very helpful,
    indicating only the return of the memcmp function.
    
    Therefore, create a new set of macros KUNIT_EXPECT_MEMEQ and
    KUNIT_EXPECT_MEMNEQ that compare memory blocks until a specified size.
    In case of expectation failure, those macros print the hex dump of the
    memory blocks, making it easier to debug test failures for memory blocks.
    
    That said, the expectation
    
        KUNIT_EXPECT_EQ(test, memcmp(foo, bar, size), 0);
    
    would translate to the expectation
    
        KUNIT_EXPECT_MEMEQ(test, foo, bar, size);
    
    Signed-off-by: default avatarMaíra Canal <mairacanal@riseup.net>
    Reviewed-by: default avatarDaniel Latypov <dlatypov@google.com>
    Reviewed-by: default avatarMuhammad Usama Anjum <usama.anjum@collabora.com>
    Reviewed-by: default avatarDavid Gow <davidgow@google.com>
    Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
    b8a926be
GitLab Nexedi Edition | About GitLab | About Nexedi | 沪ICP备2021021310号-2 | 沪ICP备2021021310号-7