Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

std wanted features & bugfixes #572

Open
2 of 3 tasks
ojeda opened this issue Nov 27, 2021 · 2 comments
Open
2 of 3 tasks

std wanted features & bugfixes #572

ojeda opened this issue Nov 27, 2021 · 2 comments
Labels
meta Meta issue. • toolchain Related to `rustc`, `bindgen`, `rustdoc`, LLVM, Clippy...

Comments

@ojeda
Copy link
Member

ojeda commented Nov 27, 2021

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.)

@ojeda ojeda added • toolchain Related to `rustc`, `bindgen`, `rustdoc`, LLVM, Clippy... meta Meta issue. labels Nov 27, 2021
@bjorn3
Copy link
Member

bjorn3 commented Nov 27, 2021

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.

@ojeda
Copy link
Member Author

ojeda commented Nov 27, 2021

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
Labels
meta Meta issue. • toolchain Related to `rustc`, `bindgen`, `rustdoc`, LLVM, Clippy...
Development

No branches or pull requests

2 participants