Skip to content

Commit

Permalink
fix: Made the go testsuite skip PCAP related tests, if the library is…
Browse files Browse the repository at this point in the history
… not installed.

fixes: #1567
  • Loading branch information
chrisdutz committed May 17, 2024
1 parent 80b3384 commit ebbcedd
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions plc4go/spi/transports/pcap/TransportInstance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ func TestTransportInstance_Close(t *testing.T) {
}

func TestTransportInstance_Connect(t *testing.T) {
if !IsPcapAvailable() {
t.Skip("LibPCAP (unix/linux/mac) or NPcap (windows) is not installed, skipping test")
}

type fields struct {
DefaultBufferedTransportInstance transportUtils.DefaultBufferedTransportInstance
transportFile string
Expand Down Expand Up @@ -337,3 +341,13 @@ func TestTransportInstance_Write(t *testing.T) {
})
}
}

func IsPcapAvailable() (result bool) {
defer func() {
if err := recover(); err != nil {
result = false
}
}()
pcap.Version()
return true
}

0 comments on commit ebbcedd

Please sign in to comment.