Skip to content

tests: make the tcpserver test big-endian clean#287

Open
obbardc wants to merge 1 commit into
sccn:devfrom
obbardc:wip/obbardc/fix-s390x-FTBFS-upstream
Open

tests: make the tcpserver test big-endian clean#287
obbardc wants to merge 1 commit into
sccn:devfrom
obbardc:wip/obbardc/fix-s390x-FTBFS-upstream

Conversation

@obbardc

@obbardc obbardc commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

The tcpserver unit test hard-codes little-endian byte patterns and reads a wire length prefix through a host-order pointer cast, so it fails on big-endian hosts (e.g. s390x). The library itself is endian-correct; only the test fixtures assume a little-endian host.

This patch contains two fixes:

  • check_streamfeed_100_response() reads the 2-byte info-length prefix of the portable binary archive via reinterpret_cast<const uint16_t>. The portable archive always serialises integers little-endian on the wire, so on a big-endian host this reads the length byte-swapped (e.g. 0x7102 instead of 0x0271), making the subsequent size check fail. Decode the two bytes explicitly as little-endian instead.

  • The "basic" string-channel case compares against TESTPAT_TIMESTAMP, the little-endian encoding of the timestamp double. String streams carry zero-size values, so the server performs no endian conversion and emits the timestamp in host byte order; the expected pattern must therefore be byte-reversed on big-endian hosts.

No behavioural changes on little-endian hosts.

The tcpserver unit test hard-codes little-endian byte patterns and reads
a wire length prefix through a host-order pointer cast, so it fails on
big-endian hosts (e.g. s390x). The library itself is endian-correct; only
the test fixtures assume a little-endian host.

This patch contains two fixes:

 * check_streamfeed_100_response() reads the 2-byte info-length prefix
   of the portable binary archive via *reinterpret_cast<const uint16_t*>.
   The portable archive always serialises integers little-endian on the
   wire, so on a big-endian host this reads the length byte-swapped (e.g.
   0x7102 instead of 0x0271), making the subsequent size check fail.
   Decode the two bytes explicitly as little-endian instead.

 * The "basic" string-channel case compares against TESTPAT_TIMESTAMP, the
   little-endian encoding of the timestamp double. String streams carry
   zero-size values, so the server performs no endian conversion and emits
   the timestamp in host byte order; the expected pattern must therefore
   be byte-reversed on big-endian hosts.

No behavioural changes on little-endian hosts.

Signed-off-by: Christopher Obbard <obbardc@debian.org>
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.

1 participant