Linux Kernel Selftest development
 help / color / mirror / Atom feed
From: Michal Wajdeczko <michal.wajdeczko@intel.com>
To: linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com
Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>,
	Rae Moar <rmoar@google.com>, David Gow <davidgow@google.com>,
	Lucas De Marchi <lucas.demarchi@intel.com>
Subject: [PATCH v2 0/6] kunit: Add macros to help write more complex tests
Date: Tue, 27 Aug 2024 00:20:09 +0200	[thread overview]
Message-ID: <20240826222015.1484-1-michal.wajdeczko@intel.com> (raw)

v1: https://groups.google.com/g/kunit-dev/c/f4LIMLyofj8
v2: make it more complex and attempt to be thread safe
    s/FIXED_STUB/GLOBAL_STUB (David, Lucas)
    make it little more thread safe (Rae, David)
    wait until stub call finishes before test end (David)
    wait until stub call finishes before changing stub (David)
    allow stub deactivation (Rae)
    prefer kunit log (David)
    add simple selftest (Michal)
    also introduce ONLY_IF_KUNIT macro (Michal)

Sample output from the tests:

    $ tools/testing/kunit/kunit.py run *example*.*global* \
        --kunitconfig lib/kunit/.kunitconfig --raw_output

    KTAP version 1
    1..1
    # example: initializing suite
    KTAP version 1
    # Subtest: example
    # module: kunit_example_test
    1..1
    # example_global_stub_test: initializing
    # example_global_stub_test: add_two: redirecting to subtract_one
    # example_global_stub_test: add_two: redirecting to subtract_one
    # example_global_stub_test: cleaning up
    ok 1 example_global_stub_test
    # example: exiting suite
    ok 1 example

    $ tools/testing/kunit/kunit.py run *global*.*global* \
        --kunitconfig lib/kunit/.kunitconfig --raw_output

    KTAP version 1
    1..1
        KTAP version 1
        # Subtest: kunit_global_stub
        # module: kunit_test
        1..4
        # kunit_global_stub_test_activate: real_void_func: redirecting to replacement_void_func
        # kunit_global_stub_test_activate: real_func: redirecting to replacement_func
        # kunit_global_stub_test_activate: real_func: redirecting to replacement_func
        # kunit_global_stub_test_activate: real_func: redirecting to other_replacement_func
        # kunit_global_stub_test_activate: real_func: redirecting to other_replacement_func
        # kunit_global_stub_test_activate: real_func: redirecting to super_replacement_func
        # kunit_global_stub_test_activate: real_func: redirecting to super_replacement_func
        ok 1 kunit_global_stub_test_activate
        ok 2 kunit_global_stub_test_deactivate
        # kunit_global_stub_test_slow_deactivate: real_func: redirecting to slow_replacement_func
        # kunit_global_stub_test_slow_deactivate: real_func: redirecting to slow_replacement_func
        # kunit_global_stub_test_slow_deactivate: waiting for slow_replacement_func
        # kunit_global_stub_test_slow_deactivate.speed: slow
        ok 3 kunit_global_stub_test_slow_deactivate
        # kunit_global_stub_test_slow_replace: real_func: redirecting to slow_replacement_func
        # kunit_global_stub_test_slow_replace: real_func: redirecting to slow_replacement_func
        # kunit_global_stub_test_slow_replace: waiting for slow_replacement_func
        # kunit_global_stub_test_slow_replace: real_func: redirecting to other_replacement_func
        # kunit_global_stub_test_slow_replace.speed: slow
        ok 4 kunit_global_stub_test_slow_replace
    # kunit_global_stub: pass:4 fail:0 skip:0 total:4
    # Totals: pass:4 fail:0 skip:0 total:4
    ok 1 kunit_global_stub

Cc: Rae Moar <rmoar@google.com>
Cc: David Gow <davidgow@google.com>
Cc: Lucas De Marchi <lucas.demarchi@intel.com>

Michal Wajdeczko (6):
  kunit: Introduce kunit_is_running()
  kunit: Add macro to conditionally expose declarations to tests
  kunit: Add macro to conditionally expose expressions to tests
  kunit: Allow function redirection outside of the KUnit thread
  kunit: Add example with alternate function redirection method
  kunit: Add some selftests for global stub redirection macros

 include/kunit/static_stub.h    | 158 ++++++++++++++++++++
 include/kunit/test-bug.h       |  12 +-
 include/kunit/visibility.h     |  16 +++
 lib/kunit/kunit-example-test.c |  67 +++++++++
 lib/kunit/kunit-test.c         | 254 ++++++++++++++++++++++++++++++++-
 lib/kunit/static_stub.c        |  49 +++++++
 6 files changed, 553 insertions(+), 3 deletions(-)

-- 
2.43.0


             reply	other threads:[~2024-08-26 22:20 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-26 22:20 Michal Wajdeczko [this message]
2024-08-26 22:20 ` [PATCH v2 1/6] kunit: Introduce kunit_is_running() Michal Wajdeczko
2024-08-26 22:20 ` [PATCH v2 2/6] kunit: Add macro to conditionally expose declarations to tests Michal Wajdeczko
2024-08-27 13:45   ` Lucas De Marchi
2024-08-27 19:56     ` Michal Wajdeczko
2024-08-26 22:20 ` [PATCH v2 3/6] kunit: Add macro to conditionally expose expressions " Michal Wajdeczko
2024-08-27 19:04   ` Rae Moar
2024-08-27 19:47     ` Michal Wajdeczko
2024-08-26 22:20 ` [PATCH v2 4/6] kunit: Allow function redirection outside of the KUnit thread Michal Wajdeczko
2024-08-27 14:46   ` Lucas De Marchi
2024-08-27 20:30     ` Michal Wajdeczko
2024-08-29 15:56       ` Michal Wajdeczko
2024-08-26 22:20 ` [PATCH v2 5/6] kunit: Add example with alternate function redirection method Michal Wajdeczko
2024-08-27 14:18   ` Lucas De Marchi
2024-08-26 22:20 ` [PATCH v2 6/6] kunit: Add some selftests for global stub redirection macros Michal Wajdeczko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240826222015.1484-1-michal.wajdeczko@intel.com \
    --to=michal.wajdeczko@intel.com \
    --cc=davidgow@google.com \
    --cc=kunit-dev@googlegroups.com \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=lucas.demarchi@intel.com \
    --cc=rmoar@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox