-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Closed
Description
Test_parseTCPStats fails on s390x and presumably other big-endian archs (e.g. mips, mips64, ppc64):
=== RUN Test_parseTCPStats
tcpstat_linux_test.go:80: want tcpstat number of bytes in tx queue 42, got 704643072
tcpstat_linux_test.go:83: want tcpstat number of bytes in rx queue 22, got 369098752
--- FAIL: Test_parseTCPStats (0.00s)
This is due to a wrong assumption about the endianness of s390x etc. in the test:
func Test_parseTCPStats(t *testing.T) {
encode := func(m InetDiagMsg) []byte {
var buf bytes.Buffer
err := binary.Write(&buf, binary.LittleEndian, m)
if err != nil {
panic(err)
}
return buf.Bytes()
}
...Most, but not all modern CPUs are little-endian. s390x is big-endian.
This is a regression in v1.4.0 due to #2322. Other functionality related to that PR may also be buggy on s390x, in addition to the failing test.