lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CANiq72mJjB_ubHx-y316o7b0KNjdHOrA9Wz0ievRvoTi1jVR5A@mail.gmail.com>
Date:   Tue, 1 Aug 2023 16:44:32 +0200
From:   Miguel Ojeda <miguel.ojeda.sandonis@...il.com>
To:     David Gow <davidgow@...gle.com>,
        José Expósito <jose.exposito89@...il.com>
Cc:     Brendan Higgins <brendan.higgins@...ux.dev>,
        Miguel Ojeda <ojeda@...nel.org>,
        Alex Gaynor <alex.gaynor@...il.com>,
        Wedson Almeida Filho <wedsonaf@...il.com>,
        Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>,
        Benno Lossin <benno.lossin@...ton.me>,
        Björn Roy Baron <bjorn3_gh@...tonmail.com>,
        linux-kselftest@...r.kernel.org, kunit-dev@...glegroups.com,
        rust-for-linux@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/3] rust: macros: add macro to easily run KUnit tests

On Thu, Jul 20, 2023 at 8:40 AM David Gow <davidgow@...gle.com> wrote:
>
> The only difference with user-space tests is that instead of using
> `#[cfg(test)]`, `#[kunit_tests(kunit_test_suit_name)]` is used.

I may be missing something, but this does not appear to map the
`assert*!`s to the KUnit APIs, is that correct? (i.e. like we do for
`rustdoc`-tests).

I made an assertion fail, and it seems to use the standard library
macros, thus panicking and ending up in `BUG()` (rather than a failed
test):

    rust_kernel: panicked at 'assertion failed: `(left == right)`
      left: `true`,
     right: `false`', rust/kernel/kunit.rs:329:1
    ------------[ cut here ]------------
    kernel BUG at rust/helpers.c:34!

Then the test times out eventually and things break:

        # rust_test_kunit_kunit_tests: try timed out
    ------------[ cut here ]------------
    refcount_t: addition on 0; use-after-free.

> +    // Add `#[cfg(CONFIG_KUNIT)]` before the module declaration.
> +    let config_kunit = "#[cfg(CONFIG_KUNIT)]".to_owned().parse().unwrap();
> +    tokens.insert(
> +        0,
> +        TokenTree::Group(Group::new(Delimiter::None, config_kunit)),
> +    );

I wonder about compile-time here with this approach. As far as I
understand, having the `cfg` explicitly outside the proc macro would
avoid invoking it.

Do we know the potential compile-time impact, especially when we will
have many tests?
ventually it would be ideal to have an approach closer to the
`rustdoc` one, where the compiler finds the tests for us and we
generate the needed code in the build system, i.e. outside a proc
macro.

Cheers,
Miguel

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ