You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by cd...@apache.org on 2024/05/17 15:52:49 UTC

(plc4x) branch develop updated: fix: Made the go testsuite skip PCAP related tests, if the library is not installed.

This is an automated email from the ASF dual-hosted git repository.

cdutz pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/plc4x.git


The following commit(s) were added to refs/heads/develop by this push:
     new ebbcedd59f fix: Made the go testsuite skip PCAP related tests, if the library is not installed.
ebbcedd59f is described below

commit ebbcedd59fa6295e4c1e137c40b4ce9a48c1e7ab
Author: Christofer Dutz <cd...@apache.org>
AuthorDate: Fri May 17 17:52:41 2024 +0200

    fix: Made the go testsuite skip PCAP related tests, if the library is not installed.
    
    fixes: #1567
---
 plc4go/spi/transports/pcap/TransportInstance_test.go | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/plc4go/spi/transports/pcap/TransportInstance_test.go b/plc4go/spi/transports/pcap/TransportInstance_test.go
index 0cd1e9a292..bf511c74f0 100644
--- a/plc4go/spi/transports/pcap/TransportInstance_test.go
+++ b/plc4go/spi/transports/pcap/TransportInstance_test.go
@@ -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
@@ -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
+}