From b5ccfaa072dcec53a4a9e5e4106b657877569cd3 Mon Sep 17 00:00:00 2001 From: Anushree R Date: Wed, 10 Jun 2026 20:57:24 +0530 Subject: [PATCH] test(bpf): finish table-driving decode_test.go (#139) --- internal/bpf/decode_test.go | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/internal/bpf/decode_test.go b/internal/bpf/decode_test.go index 8ea032a..06c54cc 100644 --- a/internal/bpf/decode_test.go +++ b/internal/bpf/decode_test.go @@ -1,3 +1,5 @@ +//go:build linux + // Copyright 2026 Optiqor contributors // SPDX-License-Identifier: Apache-2.0 @@ -94,7 +96,7 @@ func TestDecodeTCPEvent(t *testing.T) { SAddr: binary.BigEndian.Uint32([]byte{10, 0, 0, 1}), DAddr: binary.BigEndian.Uint32([]byte{8, 8, 8, 8}), SPort: 54321, - DPort: 443, // already in host byte order (BPF normalizes before writing) + DPort: 443, EventType: TCPEventRTT, RTTUs: 250, } @@ -489,20 +491,4 @@ func TestIsSyscallError(t *testing.T) { } } -func TestTCPEventPortByteOrder(t *testing.T) { - // Verify that ports in TCPEvent are host byte order. - // The BPF program applies bpf_ntohs() to dport before writing, - // so both fields should be readable directly without swapping. - e := TCPEvent{ - SPort: 54321, // ephemeral source port, host order - DPort: 443, // HTTPS destination port, host order (not 47873) - } - if e.DPort == 0xBB01 { // 47873 = 443 byte-swapped - t.Error("DPort is in network byte order; expected host byte order after BPF normalization") - } - if e.DPort != 443 { - t.Errorf("DPort = %d, want 443", e.DPort) - } -} - var _ = net.IPv4(0, 0, 0, 0)