-
Notifications
You must be signed in to change notification settings - Fork 6
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
Allocator test harness #52
Comments
I have no idea about this but I will try to take a shot at it. |
@amanjeev it's a pretty big issue, so we probably ought talk about a plan for this, and maybe break it down into multiple issues or something. But, I'm super happy you're willing to tackle it! |
Thanks!
👍 |
Adding notes here so I do not miss them - Basics:
Notes:
|
More insight from @hawkw, adding here for documentation so its not lost: I think what you'll want to do (after rebasing onto master) is write a new struct implementing struct MockFrame {
number: usize, // count the frame numbers for tracking allocations etc.
frame: [u8; FRAME_SIZE], // the frame's actual memory area.
} the frame's base address would be &self.frame[0] as *const _ as usize (the first byte in the frame) and the end address would be &self.frame[PAGE_SIZE] as *const _ as usize We'd probably want to leave the |
Having thought about it a bit more, I think perhaps those methods could be defined on a separate trait that some implementers of |
Seems like it will be. Most usage won't be like this test suite that I am writing, right? Regarding the The compiler tells me -
I do not think I can |
@amanjeev You're going to want to define a newtype. Try something like this: #[macro_use] extern crate hal9000_derive;
#[derive(Address)]
#[address_repr(usize)]
pub struct MockAddress(usize); And then you should be able to use Note that the derive crate for |
I was getting an error of non-primitive cast
My solution was to do this So far, a skeleton is here - |
Would be nice to have some code to make unit testing allocators easier:
At a minimum:
FrameAllocator
implementation that uses system alloc libraries to allocate "frames"(mmap
?)We might also want generic functions that take a generic allocator and make a bunch of assertions, since a lot of the things we'll want to test for correctness should be invariant across allocator implementations.
The text was updated successfully, but these errors were encountered: