-
Notifications
You must be signed in to change notification settings - Fork 1.1k
ctest: Add roundtrip test. #4560
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
Conversation
197138e
to
1b660f1
Compare
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.
A handful more comments here, but most are small and I think this should be the last round.
ctest-next/src/template.rs
Outdated
Ok(()) | ||
} | ||
|
||
fn _add_roundtrip_test( |
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.
Remove the leading _
, that's not a Rust convention. Any chance you have a background in Python? :)
1b660f1
to
3da3f28
Compare
63e4aa4
to
c4d7a7d
Compare
ctest-next/templates/test.rs
Outdated
input: MaybeUninit<U>, is_padding_byte: *const bool, expected: *mut u8 | ||
) -> U; | ||
} | ||
|
||
const SIZE: usize = size_of::<U>(); | ||
|
||
let is_padding_byte = roundtrip_padding__{{ item.id }}(); | ||
let mut expected = [0u8; SIZE]; |
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.
The expected
function signature can be updated to be called value_bytes
like the C signature, then the expected
array can be called c_value_bytes
.
Also, this value and c_value_bytes
can both be the same type - either a stack array or a vector. Allocating is probably a bit better in case of huge types.
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.
I don't understand what you mean by your second point, that they can be the same type. Which two?
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.
expected
is a [0u8; SIZE]
, c_value_bytes
is a vec![0u8; SIZE];
. They need to store the same amount of data, so might as well make them both a Vec
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.
There's two different variables called c_value_bytes
and its difficult to separate them so that it doesn't matter, so expected
needs a different name.
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.
I'm sorry, I misread that bit. That name was fine, it didn't need to change. expected
or e.g. expected_return
would be fine.
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.
@mbyx ^ mind changing the name back? After that this is good to go
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!
c4d7a7d
to
c7dc200
Compare
c7dc200
to
7d65acc
Compare
7d65acc
to
39d53bb
Compare
Description
Adds a roundtrip test to
ctest-next
.Sources
Checklist
libc-test/semver
have been updated*LAST
or*MAX
areincluded (see #3131)
cd libc-test && cargo test --target mytarget
);especially relevant for platforms that may not be checked in CI