Skip to content

std wanted features & bugfixes #572

Open

Description

@ojeda

Note: there is the "A-rust-for-linux" label in the rust repository: https://github.com/rust-lang/rust/labels/A-rust-for-linux.

Features that we would like to see

Required (we almost certainly want them)

Nice to have (not critical, we could workaround if needed, etc.)

Low priority (we will likely not use them in the end)

  • Make test not depend on std.
    • TODO: try out #![test_runner] + #![reexport_test_harness_main] as suggested by @bjorn3: std wanted features & bugfixes #572 (comment).
    • It would require customizing whatever test needs from std at the moment.
    • It would avoid having to build std for tests.
    • It would allow to run tests in kernel space ("#[test(kernel)]").
    • It would avoid having to wait for Cargo's -Zbuild-std fixes & stabilization.

Done (stabilized, fixed, not needed anymore, etc.)


Bugs that we would like to see fixed

Required (we almost certainly want them)

Nice to have (probably not critical, we could workaround if needed, etc.)

Low priority (we will likely not use them in the end)

Done (stabilized, fixed, or not needed anymore, etc.)

Activity

  1. added
    • toolchainRelated to `rustc`, `bindgen`, `rustdoc`, LLVM, Clippy...
    metaMeta issue.
    on Nov 27, 2021
  2. bjorn3 commented on Nov 27, 2021

    @bjorn3
    Member

    Make test not depend on std.

    For no-std testing there is the unstable #![test_runner] + #![reexport_test_harness_main]. This was implemented in rust-lang/rust#53410. See https://os.phil-opp.com/testing/ for an example. To copy the example there:

    #![feature(custom_test_frameworks)]
    #![test_runner(crate::test_runner)]
    #![reexport_test_harness_main = "test_main"]
    
    #[cfg(test)]
    fn test_runner(tests: &[&dyn Fn()]) {
        println!("Running {} tests", tests.len());
        for test in tests {
            test();
        }
    }
    
    #[no_mangle]
    pub extern "C" fn _start() -> ! {
        println!("Hello World{}", "!");
    
        #[cfg(test)]
        test_main();
    
        loop {}
    }
    
    #[test_case]
    fn trivial_assertion() {
        print!("trivial assertion... ");
        assert_eq!(1, 1);
        println!("[ok]");
    }

    I believe I have already linked it before by the way.

  3. ojeda commented on Nov 27, 2021

    @ojeda
    MemberAuthor

    Thanks! I think you did, yeah. Linked in the list to avoid missing it again :)

    I was filling this one to keep track of some of the bits from the meeting the other day that were not yet in the list.

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

    metaMeta issue.• toolchainRelated to `rustc`, `bindgen`, `rustdoc`, LLVM, Clippy...

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions