Skip to content

big endian support broken(?) #1376

@umlaeute

Description

@umlaeute

Describe the bug

it seems that python-can fails the test-suite on big-endian machines.

See https://ci.debian.net/data/autopkgtest/testing/s390x/p/python-can/24833388/log.gz (see below for an excerpt)

To Reproduce

run the test-suite on a big-endian architecture.

Expected behavior

big-endian is supported.

Additional context

OS and version Debian/GNU Linux/unstable (as of 2022-08-15)
Python version 3.10
python-can version 4.0.0
python-can interface/s (if applicable) n.n.
Architecture s390x
Traceback and logs
_______ SocketCANTest.test_build_bcm_header_sizeof_long_8_alignof_long_8 _______

self = <test.test_socketcan.SocketCANTest testMethod=test_build_bcm_header_sizeof_long_8_alignof_long_8>

    @unittest.skipIf(
        not (
            ctypes.sizeof(ctypes.c_long) == 8 and ctypes.alignment(ctypes.c_long) == 8
        ),
        "Should only run on platforms where sizeof(long) == 8 and alignof(long) == 8",
    )
    def test_build_bcm_header_sizeof_long_8_alignof_long_8(self):
        expected_result = (
            b"\x02\x00\x00\x00\x00\x00\x00\x00"
            b"\x00\x00\x00\x00\x00\x00\x00\x00"
            b"\x00\x00\x00\x00\x00\x00\x00\x00"
            b"\x00\x00\x00\x00\x00\x00\x00\x00"
            b"\x00\x00\x00\x00\x00\x00\x00\x00"
            b"\x00\x00\x00\x00\x00\x00\x00\x00"
            b"\x01\x04\x00\x00\x01\x00\x00\x00"
        )
    
>       self.assertEqual(
            expected_result,
            build_bcm_header(
                opcode=CAN_BCM_TX_DELETE,
                flags=0,
                count=0,
                ival1_seconds=0,
                ival1_usec=0,
                ival2_seconds=0,
                ival2_usec=0,
                can_id=0x401,
                nframes=1,
            ),
        )
E       AssertionError: b'\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00[176 chars]\x00' != b'\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00[176 chars]\x01'

test_socketcan.py:290: AssertionError

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions