make testsuite pass on bigendian#39
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request aims to improve the compatibility of the test suite with big-endian systems. It specifically addresses two failing tests by temporarily disabling one on big-endian and correcting boolean value comparisons in another to ensure consistent behavior across different endian architectures. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request aims to make the test suite pass on big-endian systems. The changes in src/socket.rs correctly fix boolean checks to be endian-agnostic by changing == 1 to != 0, which is a good improvement. However, the change in src/mio.rs disables a test on big-endian systems. I've provided a suggestion to fix the test instead of disabling it, which would be a more robust solution.
| } | ||
| } | ||
|
|
||
| #[cfg(target_endian = "little")] |
There was a problem hiding this comment.
While disabling this test module on big-endian systems makes the test suite pass, it hides an underlying issue and reduces test coverage. The problem is that the hardcoded netlink message in request_neighbour_dump is little-endian specific, which causes the test to fail on big-endian architectures.
A better approach would be to make the test endian-agnostic by constructing the message at runtime. This would fix the test on big-endian systems and restore test coverage.
Here is a suggested implementation for request_neighbour_dump that should work on all platforms:
fn request_neighbour_dump(socket: &mut Socket) -> std::io::Result<()> {
let mut buf = [0u8; 28];
// nl_msglen = 28
buf[0..4].copy_from_slice(&28u32.to_ne_bytes());
// nl_msgtype = 30 (RTM_GETNEIGH)
buf[4..6].copy_from_slice(&30u16.to_ne_bytes());
// nl_msgflags = NLM_F_REQUEST | NLM_F_DUMP = 0x0301
buf[6..8].copy_from_slice(&0x0301u16.to_ne_bytes());
// The rest is zeroed out, which is fine for seq, pid, and payload for this request.
socket.send(&buf[..], 0)?;
Ok(())
}With this change, you can remove the #[cfg(target_endian = "little")] attribute.
|
Thanks for the patch! Could you also comment your finding on big-endian issue in #4 where we may continue the investigation? |
I'm not the original author, but the patch is placed under the MIT license per: https://salsa.debian.org/rust-team/debcargo-conf/-/blob/master/src/netlink-sys/debian/copyright?ref_type=heads#L10
Original commit message from https://salsa.debian.org/rust-team/debcargo-conf/-/blob/master/src/netlink-sys/debian/patches/bigendian.patch?ref_type=heads
This patch makes the autopkgtests pass on bigendian, it's still far from ideal
but it's an improvement over the situation in testing at the time of writing.
Two tests are addressed, mio::tests::test_event_loop and socket::test::options
I have no clue what is causing test_event_loop to fail so I have simply skipped
that for now.
socket::test::options failed because of what appears to be a kernel issue,
according to the documentation the options are of type int, but retrieving them
seems to retrieve only a single byte. On little endian this byte is placed in
the LSB resulting in 1 for true and 0 for false, but on big endian it is placed
in the MSB resulting in 0x01000000 for true and 0 for false. This patch changes
the comparisions from == 1 to != 0 so they work on both big and little endian.
Author: Peter Michel Green plugwash@debian.org