1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
|
From: Daniel Swarbrick <dswarbrick@debian.org>
Date: Tue, 26 Aug 2025 14:42:06 +0200
Subject: Fix test skipping on big-endian archs
Origin: https://github.com/mdlayher/netlink/pull/228
---
conn_linux_error_test.go | 4 ++--
message_test.go | 5 +++--
nlenc/int_test.go | 5 +++--
nltest/nltest_test.go | 4 ++--
4 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/conn_linux_error_test.go b/conn_linux_error_test.go
index 97e6227..d7e9cfd 100644
--- a/conn_linux_error_test.go
+++ b/conn_linux_error_test.go
@@ -4,13 +4,13 @@
package netlink_test
import (
- "encoding/binary"
"os"
"testing"
"github.com/google/go-cmp/cmp"
"github.com/mdlayher/netlink"
"github.com/mdlayher/netlink/nltest"
+ "golang.org/x/sys/cpu"
"golang.org/x/sys/unix"
)
@@ -115,7 +115,7 @@ func TestConnReceiveErrorLinux(t *testing.T) {
}
func skipBigEndian(t *testing.T) {
- if binary.ByteOrder(binary.NativeEndian) == binary.BigEndian {
+ if cpu.IsBigEndian {
t.Skip("skipping test on big-endian system")
}
}
diff --git a/message_test.go b/message_test.go
index 7a4b08d..ff7ed0c 100644
--- a/message_test.go
+++ b/message_test.go
@@ -2,10 +2,11 @@ package netlink
import (
"bytes"
- "encoding/binary"
"errors"
"reflect"
"testing"
+
+ "golang.org/x/sys/cpu"
)
func TestHeaderFlagsString(t *testing.T) {
@@ -474,7 +475,7 @@ func TestValidate(t *testing.T) {
}
func skipBigEndian(t *testing.T) {
- if binary.ByteOrder(binary.NativeEndian) == binary.BigEndian {
+ if cpu.IsBigEndian {
t.Skip("skipping test on big-endian system")
}
}
diff --git a/nlenc/int_test.go b/nlenc/int_test.go
index 09b9c08..cd6bb25 100644
--- a/nlenc/int_test.go
+++ b/nlenc/int_test.go
@@ -2,9 +2,10 @@ package nlenc
import (
"bytes"
- "encoding/binary"
"fmt"
"testing"
+
+ "golang.org/x/sys/cpu"
)
func TestUintPanic(t *testing.T) {
@@ -456,7 +457,7 @@ func TestInt32(t *testing.T) {
}
func skipBigEndian(t *testing.T) {
- if NativeEndian() == binary.BigEndian {
+ if cpu.IsBigEndian {
t.Skip("skipping test on big-endian system")
}
}
diff --git a/nltest/nltest_test.go b/nltest/nltest_test.go
index 3e251ac..49a45b4 100644
--- a/nltest/nltest_test.go
+++ b/nltest/nltest_test.go
@@ -2,7 +2,6 @@ package nltest_test
import (
"bytes"
- "encoding/binary"
"errors"
"io"
"reflect"
@@ -11,6 +10,7 @@ import (
"github.com/google/go-cmp/cmp"
"github.com/mdlayher/netlink"
"github.com/mdlayher/netlink/nltest"
+ "golang.org/x/sys/cpu"
)
func TestConnSend(t *testing.T) {
@@ -537,7 +537,7 @@ var noop = func(req []netlink.Message) ([]netlink.Message, error) {
}
func skipBigEndian(t *testing.T) {
- if binary.ByteOrder(binary.NativeEndian) == binary.BigEndian {
+ if cpu.IsBigEndian {
t.Skip("skipping test on big-endian system")
}
}
|