Skip to content
This repository was archived by the owner on Apr 6, 2020. It is now read-only.
This repository was archived by the owner on Apr 6, 2020. It is now read-only.

Unit testing; what to do about protected components?  #68

Description

@WilsonGiese

I was just messing around a bit, trying to add a cursor back into the new VGA code on my fork, no issues running the code in QEMU, but definitely had issues trying to access VGA hardware registers in test code. I basically broke all VGA tests by causing SIGSEGVs (woo!).

Wondering what the options are for unit testing code that needs to work so close to metal...

In school we wrote components for PintOS, but all the testing was done by running executables in user space. This worked quite well, but its really system testing, not unit testing. Without writing the kernel code to be accommodating of unit testing (lots of traits? Passing around real & mock impls), I'm not seeing how to assert on some aspects of the kernel directly.

Activity

  1. steveklabnik commented on Sep 28, 2016

    @steveklabnik
    Member

    Yes, I think this is an open and interesting question. @withoutboats had a really interesting talk at RustConf about using more traits to enable testing.

    One interesting possibility here: mock out some sort of pic crate.....

  2. WilsonGiese commented on Sep 28, 2016

    @WilsonGiese
    ContributorAuthor

    Is the @withoutboats talk available online anywhere? Not able to find it anywhere :(

  3. withoutboats commented on Sep 28, 2016

    @withoutboats

    @WilsonGiese I believe it will be on the internet soon, but it seems like you understand the idea:

    (lots of traits? Passing around real & mock impls)

    For any interface between modules that you want to be an isolation boundary, instead of taking the other type directly, take a trait-bound type parameter, and then define mock impls in your unit tests.

    I don't know anything about OSdev or I'd post a little practical example (ps. excited to learn something about it at Rust Belt Rust 😉).

  4. WilsonGiese commented on Sep 28, 2016

    @WilsonGiese
    ContributorAuthor

    For any interface between modules that you want to be an isolation boundary, instead of taking the other type directly, take a trait-bound type parameter, and then define mock impls in your unit tests.

    Yeah, this is basically what I was thinking!

    I don't know anything about OSdev

    I'll probably play around a little and see what I can come up with, concept seems easy enough to test

    I believe it will be on the internet soon

    Awesome, looking forward to listening to your talk @withoutboats 👍

  5. steveklabnik commented on Sep 28, 2016

    @steveklabnik
    Member

    (ps. excited to learn something about it at Rust Belt Rust 😉).

    🎊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions