Unit Testing #1008
Replies: 32 comments
-
In the code on GitHub it is the correct version, however this document has it set to |
Beta Was this translation helpful? Give feedback.
-
Thanks for reporting! Fixed in 0aaeb52. |
Beta Was this translation helpful? Give feedback.
-
The initial |
Beta Was this translation helpful? Give feedback.
-
Since |
Beta Was this translation helpful? Give feedback.
-
Oooh I see you're using |
Beta Was this translation helpful? Give feedback.
-
Hello, i'm writing an os in rust for a school project and all your work is really helpful, thank you. I started to look for unit tests but from the os environnement and not from the host machine like you show here. Unfortunately you will talk about that in the next post and i cannot find any informations on the internet. Can you give me some hints so I dont have to wait for the next post ? |
Beta Was this translation helpful? Give feedback.
-
@orpheeantoniadis Look into Note that my kernel was based off of the first edition series of Phil's kernel, so the kernel was built as a static library instead of a binary. I believe it will be easier to integrate |
Beta Was this translation helpful? Give feedback.
-
@robert-w-gries Thanks for your answer, I will look what you send. I am not following Phil's blog because we have a system programming course about that in my school but my kernel looks more like first edition but in 32-bit mode. |
Beta Was this translation helpful? Give feedback.
-
As always, great post! For anyone interested, proptest recently added no_std and alloc support proptest-rs/proptest#48 and theres a rust-lang rfc for custom test frameworks rust-lang/rfcs#2318 |
Beta Was this translation helpful? Give feedback.
-
Thanks, fixed in cb1fa39.
The method is not strictly necessary, it just makes the following code snippets less verbose (as you noticed, |
Beta Was this translation helpful? Give feedback.
-
@orpheeantoniadis Thanks!
I don't have worked out the details yet, but my plan is to do something much simpler than
So this won't be a way of running unit tests in the target environment, but rather a way of writing a few high-level integration tests to verify that the components work correctly with the hardware (e.g. that adding a page table entry makes the corresponding page accessible). |
Beta Was this translation helpful? Give feedback.
-
@memoryruins Thanks! Never heard of |
Beta Was this translation helpful? Give feedback.
-
In ESALP we're going to output the test-anything-protocol to the serial bus to do integration testing. |
Beta Was this translation helpful? Give feedback.
-
Cool! The test-anything-protocal seems really fitting. Do you use some tool to verify the test output? |
Beta Was this translation helpful? Give feedback.
-
In https://os.phil-opp.com/unit-testing/#unit-tests-for the |
Beta Was this translation helpful? Give feedback.
-
For some reason P.S. I'm trying to have VGA related code (including tests) in a separate file.
|
Beta Was this translation helpful? Give feedback.
-
@phil-opp , could you please explain how to build a test suite if the target embedded platform has a different byte order? For example, the embedded circuit has big endian while workstation which is used for coding has little endian. I understand that "safe Rust" code is not supposed to have such problems... But "bare metal" will have some. And doesn't the statement |
Beta Was this translation helpful? Give feedback.
-
I guess, that might be covered by the "integration tests" article. https://os.phil-opp.com/integration-tests/ Please consider extending the |
Beta Was this translation helpful? Give feedback.
-
The width and height are deduced by type inference. The return type of |
Beta Was this translation helpful? Give feedback.
-
That's really strange. Maybe you accidentally put the |
Beta Was this translation helpful? Give feedback.
-
As long as you're not working with individual bytes of integers, the endianess difference shouldn't matter since both your code and your tests are compiled for the same platform with same endianess. For testing platform specific parts you need to run the tests on the target architecture as described in the “Integration Tests” post. You can also use the |
Beta Was this translation helpful? Give feedback.
-
I get the following error:
Not clear why, also not clear where I'm supposed to put the line #![feature(extern_crate_item_prelude)]. Tried it at several places, but doesn't seem to work where ever I put it. What am I doing wrong? |
Beta Was this translation helpful? Give feedback.
-
@arjanvaneersel Do you have your code online somewhere so that I can take a look? |
Beta Was this translation helpful? Give feedback.
-
@arjanvaneersel I believe you are using edition 2018. You could add |
Beta Was this translation helpful? Give feedback.
-
@bjorn3 adding #![feature(extern_crate_item_prelude)] to main.rs solved the issue. |
Beta Was this translation helpful? Give feedback.
-
Why does this post suggest using #[cfg(test)]
extern crate std; instead of #![cfg_attr(not(test), no_std)] |
Beta Was this translation helpful? Give feedback.
-
Note that the |
Beta Was this translation helpful? Give feedback.
-
@kballard The problem is that the |
Beta Was this translation helpful? Give feedback.
-
@phil-opp Really? I went with |
Beta Was this translation helpful? Give feedback.
-
@kballard Yeah, I think is because the 2018 edition does not require I created #500 to move this crate to the 2018 edition. As soon as we're on Rust 2018, we will use the |
Beta Was this translation helpful? Give feedback.
-
This is a general purpose comment thread for the “Unit Testing” post.
Beta Was this translation helpful? Give feedback.
All reactions