Skip to content

make testsuite pass on bigendian#39

Merged
cathay4t merged 1 commit intorust-netlink:mainfrom
alexanderkjall:test-on-bigendian
Mar 8, 2026
Merged

make testsuite pass on bigendian#39
cathay4t merged 1 commit intorust-netlink:mainfrom
alexanderkjall:test-on-bigendian

Conversation

@alexanderkjall
Copy link
Contributor

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

@gemini-code-assist
Copy link

Summary of Changes

Hello, 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

  • Test Suite Compatibility: The pull request addresses issues preventing the test suite from passing on big-endian systems, specifically targeting two failing tests.
  • mio::tests::test_event_loop: The mio::tests::test_event_loop test is now conditionally compiled to run only on little-endian systems, as its failure cause on big-endian is currently unknown.
  • socket::test::options: Comparisons for socket options in socket::test::options were updated from == 1 to != 0 to correctly handle boolean values on both big-endian and little-endian architectures, resolving an issue where a single byte value was misinterpreted due to endianness.
Changelog
  • src/mio.rs
    • Added #[cfg(target_endian = "little")] to the tests module to skip mio::tests::test_event_loop on big-endian systems.
  • src/socket.rs
    • Modified several Ok(res == 1) expressions to Ok(res != 0) when checking socket option return values, to correctly interpret boolean results regardless of system endianness.
Activity
  • No explicit activity (comments, reviews, or progress updates) was provided in the context.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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")]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

@cathay4t
Copy link
Member

cathay4t commented Mar 8, 2026

Thanks for the patch! Could you also comment your finding on big-endian issue in #4 where we may continue the investigation?

@cathay4t cathay4t merged commit 600033d into rust-netlink:main Mar 8, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants