Testing #1009
Replies: 164 comments 71 replies
-
I'm not sure if I did something wrong, but by following along with this guide exactly I was receiving an error about fmt being undeclared after setting up the CompareMessage implementation. I fixed it by adding |
Beta Was this translation helpful? Give feedback.
-
@leggettc18 You did nothing wrong, I forgot to mention these imports. Fixed in 1f97103. Thanks for reporting! |
Beta Was this translation helpful? Give feedback.
-
I'm unable to run
|
Beta Was this translation helpful? Give feedback.
-
Try I have the same problem but couldn't figure out why the file isn't automatically found. |
Beta Was this translation helpful? Give feedback.
-
@AntoineSebert Do you have a @Beidah Sounds like forgot a |
Beta Was this translation helpful? Give feedback.
-
@phil-opp Yes it's there. The problem seems to have disappread today, and anyway it's not a big deal. |
Beta Was this translation helpful? Give feedback.
-
The recent improvements in the test framework now produce text outputs that are not colored in green, thus making the test result less visible within the terminal. |
Beta Was this translation helpful? Give feedback.
-
Yes, there is! You can use ANSI escape codes for coloring. For example, you can create a type to print something in green: use core::fmt;
struct Green(&'static str);
impl fmt::Display for Green {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "\x1B[32m")?; // prefix code
write!(f, "{}", self.0)?;
write!(f, "\x1B[0m")?; // postfix code
Ok(())
}
} Now you can do I opened #603 for adding this to the post. |
Beta Was this translation helpful? Give feedback.
-
In the process of adding tests, I encountered some strange errors. In this test, I simply created a writer, but failed, and judging from the error message, it seems that it did not execute any tests at all, because I did not see the information printed by test_runner or panic_handler on the console. lws@lsw:/document/project/flandre-os/FlandreOS$ cargo xtest test_default_writer
Compiling flandre_os v0.0.1 (/document/project/flandre-os/FlandreOS)
Finished dev [unoptimized + debuginfo] target(s) in 0.33s
Running target/x86_64-flandre_os/debug/deps/flandre_os-d120248f92b70111
Building bootloader
Compiling bootloader v0.6.0 (/work/tool/rust/cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/bootloader-0.6.0)
Finished release [optimized + debuginfo] target(s) in 0.72s
Running: `qemu-system-x86_64 -drive format=raw,file=/document/project/flandre-os/FlandreOS/target/x86_64-flandre_os/debug/deps/bootimage-flandre_os-d120248f92b70111.bin -device isa-debug-exit,iobase=0xf4,iosize=0x04 -serial stdio -display none test_default_writer`
qemu-system-x86_64: -display none: drive with bus=0, unit=0 (index=0) exists
error: test failed, to rerun pass '--lib'
|
Beta Was this translation helpful? Give feedback.
-
I did all kinds of printing tests and the printing function seemed to work normally, but when I tried to add some tests to ensure that these functions would not be damaged in future modifications, I got the above errors. |
Beta Was this translation helpful? Give feedback.
-
I think passing a test name to |
Beta Was this translation helpful? Give feedback.
-
Yes, as you see from the "Running: What you can do is to run the tests of the library component through |
Beta Was this translation helpful? Give feedback.
-
I tried adding the "x" as you indicated in the above paragraph. The test did not fail. WIth some more fooling about i see that the I have submitted a pull request #610 |
Beta Was this translation helpful? Give feedback.
-
@xj42 Thanks a lot for reporting! I created #611 to fix this. |
Beta Was this translation helpful? Give feedback.
-
Hi, thank you for taking your time and effort into making this brilliant blog! I've learnt so much about operating systems and the Rust language in general! Can't wait to see how this blog unfolds and what new things you'll bring. I just wanted to ask if it is the expected behaviour for It seems to me that perhaps this was the desired behaviour? If so, is there a way for me to send data to the serial port while the QEMU instance is running as normal? |
Beta Was this translation helpful? Give feedback.
-
Hello, when i run the cargo test command i got this error :
my config.toml file :
my json file :
and yes i have :
Thanks you. |
Beta Was this translation helpful? Give feedback.
-
I'm getting a segfault on the first step of adding the test_runner function and running the cargo test. Is there anything that could explain this behavior?? |
Beta Was this translation helpful? Give feedback.
-
hi!
My rust.yml looks like this:
anyone know why this is happening? |
Beta Was this translation helpful? Give feedback.
-
Hi, when I try to pass arguments "-display none" to QUME, and then run the cargo test, it will below error message.
|
Beta Was this translation helpful? Give feedback.
-
The section where we try to print the names of the test functions is not functioning correctly for me. Whenever I use core::any::type_name::(), it only prints the actual type, which is &dyn core::ops::function::Fn() instead of the function's name. |
Beta Was this translation helpful? Give feedback.
-
main.rs:
|
Beta Was this translation helpful? Give feedback.
-
Is it possible to move the testing module such as test_panic_handler, exit_qemu, Testable trait from lib.rs into its own dedicated file? It would make the code more structured and but I've had a problem with test_main(), where I've tried importing it via use crate::test_main() and also included these attributes in the dedicated testing module file: #![feature(custom_test_frameworks)] Anyone have any thoughts? |
Beta Was this translation helpful? Give feedback.
-
Is there a solution so that if the the test panics, can we continue? |
Beta Was this translation helpful? Give feedback.
-
The step after testing is to get coverage data.
|
Beta Was this translation helpful? Give feedback.
-
cargo test gives this: (signal: 11, SIGSEGV: invalid memory reference) |
Beta Was this translation helpful? Give feedback.
-
If anyone else is experience the same issue that I was with Insert into your Make sure you're using the latest nightly compiler. |
Beta Was this translation helpful? Give feedback.
-
both lib.rs and basic_boot.rs contain a entry point function "_start", but cargo test still compile. Why is that? |
Beta Was this translation helpful? Give feedback.
-
I think there's a minor error, in the panic function it said shouldn't return, but there's no semi-column at the end of the function call. I've tried to copy paste the code into my editor and the lsp tells me to add a semi-column. // in tests/basic_boot.rs
#![test_runner(blog_os::test_runner)]
#[panic_handler]
fn panic(info: &PanicInfo) -> ! {
blog_os::test_panic_handler(info)
} |
Beta Was this translation helpful? Give feedback.
-
I am receiving a compilation error whenever I attempt to include the error[E0053]: method `steps_between` has an incompatible type for trait
--> /Users/danielmorozoff/.cargo/registry/src/index.crates.io-6f17d22bba15001f/x86_64-0.14.12/src/addr.rs:382:51
|
382 | fn steps_between(start: &Self, end: &Self) -> Option<usize> {
| ^^^^^^^^^^^^^ expected `(usize, Option<usize>)`, found `Option<usize>`
|
= note: expected signature `fn(&addr::VirtAddr, &addr::VirtAddr) -> (usize, Option<usize>)`
found signature `fn(&addr::VirtAddr, &addr::VirtAddr) -> Option<usize>`
help: change the output type to match the trait
|
382 | fn steps_between(start: &Self, end: &Self) -> (usize, Option<usize>) {
| ~~~~~~~~~~~~~~~~~~~~~~ |
Beta Was this translation helpful? Give feedback.
-
I have a error at the first step trying to run the "cargo test" barely...Has the different error as wrote in this book. UnwhiteCat@uccomputer ~/Codes/rust/blogos $ cargo test
Compiling scopeguard v1.2.0
Compiling bootloader v0.9.29
error[E0152]: duplicate lang item in crate `core` (which `rustc_std_workspace_core` depends on): `sized`
|
= note: the lang item is first defined in crate `core` (which `bootloader` depends on)
= note: first definition in `core` loaded from /home/UnwhiteCat/Codes/rust/blogos/target/x86_64-blog_os/debug/deps/libcore-33e3a870bea73245.rmeta
= note: second definition in `core` loaded from /home/UnwhiteCat/Codes/rust/blogos/target/x86_64-blog_os/debug/deps/libcore-f389adb7b0a7ac1b.rmeta
error[E0152]: duplicate lang item in crate `core` (which `rustc_std_workspace_core` depends on): `sized`
|
= note: the lang item is first defined in crate `core` (which `scopeguard` depends on)
= note: first definition in `core` loaded from /home/UnwhiteCat/Codes/rust/blogos/target/x86_64-blog_os/debug/deps/libcore-33e3a870bea73245.rmeta
= note: second definition in `core` loaded from /home/UnwhiteCat/Codes/rust/blogos/target/x86_64-blog_os/debug/deps/libcore-f389adb7b0a7ac1b.rmeta
For more information about this error, try `rustc --explain E0152`.
error: could not compile `scopeguard` (lib) due to 1 previous error
warning: build failed, waiting for other jobs to finish...
error: could not compile `bootloader` (lib) due to 1 previous error Here is my rustc version. UnwhiteCat@uccomputer ~/Codes/rust/blogos $ rustc --version
rustc 1.85.0-nightly (6b6a867ae 2024-11-27) |
Beta Was this translation helpful? Give feedback.
-
This is a general purpose comment thread for the Testing post.
Beta Was this translation helpful? Give feedback.
All reactions