-
Notifications
You must be signed in to change notification settings - Fork 69
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
Resolve issues for unit tests on 32 bits #1095
Conversation
888f9cd
to
12202aa
Compare
@@ -312,6 +315,7 @@ mod tests { | |||
#[test] | |||
fn protect() { | |||
serial_test(|| { | |||
let test_memory_size = MMAP_CHUNK_BYTES * 2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inside the with_cleanup( || { ... })
block, it computes the number of pages to mmap separately (the expression pages_per_chunk * 2
). We have to manually make sure this size is the same as MMAP_CHUNK_BYTES * 2
which is the definition of test_memory_size
.
It is better if we can hoist the computations before the invocation of with_cleanup
, like how you changed other test cases, and compute the number of pages to mmap and mprotect from the test_memory_size
. That will make the two values dependent on each other, and make the test case more robust. For example:
let test_memory_bytes = MMAP_CHUNK_BYTES * 2;
let protect_memory_bytes = test_memory_bytes / 2; // Now this depends on test_memory_bytes
let test_memory_pages = test_memory_bytes >> LOG_BYTES_IN_PAGE as usize; // This also depends on test_memory_bytes
let protect_memory_pages = protect_memory_bytes >> LOG_BYTES_IN_PAGE as usize; // This also depends on test_memory_bytes
with_cleanup(|| {
// ...
mmapper.ensure_mapped(FIXED_ADDRESS, test_memory_pages).unwrap();
mmapper.protect(FIXED_ADDRESS, protect_memory_pages);
// ...
}, || {
memory::munmap(FIXED_ADDRESS, test_memory_pages).unwrap();
})
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This PR resolves a few issues we recently saw for running unit tests in our CI.
Make raw_memory_freelist only compiled in 64bits. This mitigates the issue we saw in RawMemoryFreeList can't get more space from mmap #1091 for raw_memory_freelist tests.