You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by sr...@apache.org on 2023/06/12 10:22:50 UTC
[plc4x] branch develop updated: test(plc4go): hook in testing logger were not done yet
This is an automated email from the ASF dual-hosted git repository.
sruehl 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 4c0e1cb532 test(plc4go): hook in testing logger were not done yet
4c0e1cb532 is described below
commit 4c0e1cb5320e85281ec8374d841770c86e27aec3
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Mon Jun 12 12:22:37 2023 +0200
test(plc4go): hook in testing logger were not done yet
---
plc4go/spi/testutils/DriverTestRunner.go | 33 +++++++++-------------
plc4go/spi/testutils/ParserSerializerTestRunner.go | 3 +-
plc4go/tests/drivers/tests/abeth_driver_test.go | 4 ++-
.../drivers/tests/abeth_parser_serializer_test.go | 2 ++
plc4go/tests/drivers/tests/ads_driver_test.go | 4 ++-
.../drivers/tests/ads_parser_serializer_test.go | 2 ++
.../drivers/tests/bacnet_parser_serializer_test.go | 2 ++
plc4go/tests/drivers/tests/df1_driver_test.go | 4 ++-
.../drivers/tests/df1_parser_serializer_test.go | 2 ++
plc4go/tests/drivers/tests/eip_driver_test.go | 4 ++-
.../drivers/tests/eip_parser_serializer_test.go | 3 ++
plc4go/tests/drivers/tests/firmata_driver_test.go | 5 +++-
.../tests/firmata_parser_serializer_test.go | 2 ++
plc4go/tests/drivers/tests/knxnetip_driver_test.go | 4 ++-
.../tests/knxnetip_parser_serializer_test.go | 2 ++
plc4go/tests/drivers/tests/modbus_driver_test.go | 4 ++-
.../drivers/tests/modbus_parser_serializer_test.go | 2 ++
plc4go/tests/drivers/tests/s7_driver_test.go | 4 ++-
.../drivers/tests/s7_parser_serializer_test.go | 2 ++
19 files changed, 59 insertions(+), 29 deletions(-)
diff --git a/plc4go/spi/testutils/DriverTestRunner.go b/plc4go/spi/testutils/DriverTestRunner.go
index bbc1384b1f..d7900b8ab1 100644
--- a/plc4go/spi/testutils/DriverTestRunner.go
+++ b/plc4go/spi/testutils/DriverTestRunner.go
@@ -24,6 +24,9 @@ import (
"encoding/binary"
"encoding/hex"
"fmt"
+ "github.com/apache/plc4x/plc4go/pkg/api/config"
+ "github.com/apache/plc4x/plc4go/spi/options"
+ "github.com/apache/plc4x/plc4go/spi/options/converter"
"os"
"runtime/debug"
"strconv"
@@ -60,34 +63,23 @@ type XmlParser interface {
Parse(typeName string, xmlString string, parserArguments ...string) (any, error)
}
-type WithOption interface {
- isOption() bool
-}
-
-type _option struct {
-}
-
-func (_option) isOption() bool {
- return true
-}
-
// WithRootTypeParser can be used to output the root type of protocol for better debugging
-func WithRootTypeParser(rootTypeParser func(utils.ReadBufferByteBased) (any, error)) WithOption {
+func WithRootTypeParser(rootTypeParser func(utils.ReadBufferByteBased) (any, error)) config.WithOption {
return withRootTypeParser{rootTypeParser: rootTypeParser}
}
type withRootTypeParser struct {
- _option
+ options.Option
rootTypeParser func(utils.ReadBufferByteBased) (any, error)
}
// WithSkippedTestCases can be used to skip test cases
-func WithSkippedTestCases(skippedTestCases ...string) WithOption {
+func WithSkippedTestCases(skippedTestCases ...string) config.WithOption {
return withSkippedTestCases{skippedTestCases: skippedTestCases}
}
type withSkippedTestCases struct {
- _option
+ options.Option
skippedTestCases []string
}
@@ -485,11 +477,11 @@ const (
StepTypeTerminate StepType = 0x08
)
-func RunDriverTestsuite(t *testing.T, driver plc4go.PlcDriver, testPath string, parser XmlParser, options ...WithOption) {
- t.Log("Extract testsuite options")
+func RunDriverTestsuite(t *testing.T, driver plc4go.PlcDriver, testPath string, parser XmlParser, _options ...config.WithOption) {
+ t.Log("Extract testsuite _options")
var rootTypeParser func(utils.ReadBufferByteBased) (any, error)
skippedTestCasesMap := map[string]bool{}
- for _, withOption := range options {
+ for _, withOption := range _options {
switch option := withOption.(type) {
case withRootTypeParser:
t.Logf("Using root type parser for better output")
@@ -515,8 +507,9 @@ func RunDriverTestsuite(t *testing.T, driver plc4go.PlcDriver, testPath string,
}
// Initialize the driver manager
- driverManager := plc4go.NewPlcDriverManager()
- driverManager.(spi.TransportAware).RegisterTransport(test.NewTransport())
+ driverManager := plc4go.NewPlcDriverManager(_options...)
+ transport := test.NewTransport(converter.WithOptionToInternal(_options...)...)
+ driverManager.(spi.TransportAware).RegisterTransport(transport)
driverManager.RegisterDriver(driver)
t.Logf("Running %d testcases", len(testsuite.testcases))
diff --git a/plc4go/spi/testutils/ParserSerializerTestRunner.go b/plc4go/spi/testutils/ParserSerializerTestRunner.go
index 94f40a4a12..57ca00dfc8 100644
--- a/plc4go/spi/testutils/ParserSerializerTestRunner.go
+++ b/plc4go/spi/testutils/ParserSerializerTestRunner.go
@@ -24,6 +24,7 @@ import (
"encoding/binary"
"encoding/hex"
"fmt"
+ "github.com/apache/plc4x/plc4go/pkg/api/config"
"github.com/pkg/errors"
"os"
"runtime/debug"
@@ -168,7 +169,7 @@ type Parser interface {
Parse(typeName string, arguments []string, io utils.ReadBuffer) (any, error)
}
-func RunParserSerializerTestsuite(t *testing.T, testPath string, parser Parser, options ...WithOption) {
+func RunParserSerializerTestsuite(t *testing.T, testPath string, parser Parser, options ...config.WithOption) {
t.Log("Extract testsuite options")
var rootTypeParser func(utils.ReadBufferByteBased) (any, error)
skippedTestCasesMap := map[string]bool{}
diff --git a/plc4go/tests/drivers/tests/abeth_driver_test.go b/plc4go/tests/drivers/tests/abeth_driver_test.go
index 2d99f4ca73..f1a3ffeed1 100644
--- a/plc4go/tests/drivers/tests/abeth_driver_test.go
+++ b/plc4go/tests/drivers/tests/abeth_driver_test.go
@@ -32,10 +32,12 @@ import (
func TestAbEthDriver(t *testing.T) {
t.Skip("No test yet available")
testutils.SetToTestingLogger(t, readWriteModel.Plc4xModelLog)
+ withCustomLogger := options.WithCustomLogger(testutils.ProduceTestingLogger(t))
testutils.RunDriverTestsuite(
t,
- ads.NewDriver(options.WithCustomLogger(testutils.ProduceTestingLogger(t))),
+ ads.NewDriver(withCustomLogger),
"assets/testing/protocols/abeth/DriverTestsuite.xml",
abethIO.AbethXmlParserHelper{},
+ withCustomLogger,
)
}
diff --git a/plc4go/tests/drivers/tests/abeth_parser_serializer_test.go b/plc4go/tests/drivers/tests/abeth_parser_serializer_test.go
index ab12adbe49..a694d73fe2 100644
--- a/plc4go/tests/drivers/tests/abeth_parser_serializer_test.go
+++ b/plc4go/tests/drivers/tests/abeth_parser_serializer_test.go
@@ -20,6 +20,7 @@
package tests
import (
+ "github.com/apache/plc4x/plc4go/spi/options"
"testing"
abethIO "github.com/apache/plc4x/plc4go/protocols/abeth/readwrite"
@@ -33,5 +34,6 @@ func TestAbEthParserSerializer(t *testing.T) {
t,
"assets/testing/protocols/abeth/ParserSerializerTestsuite.xml",
abethIO.AbethParserHelper{},
+ options.WithCustomLogger(testutils.ProduceTestingLogger(t)),
)
}
diff --git a/plc4go/tests/drivers/tests/ads_driver_test.go b/plc4go/tests/drivers/tests/ads_driver_test.go
index 55da0e8316..fc2513e0c2 100644
--- a/plc4go/tests/drivers/tests/ads_driver_test.go
+++ b/plc4go/tests/drivers/tests/ads_driver_test.go
@@ -37,11 +37,13 @@ func TestAdsDriver(t *testing.T) {
parser := func(readBufferByteBased utils.ReadBufferByteBased) (any, error) {
return readWriteModel.AmsTCPPacketParseWithBuffer(context.Background(), readBufferByteBased)
}
+ withCustomLogger := options.WithCustomLogger(testutils.ProduceTestingLogger(t))
testutils.RunDriverTestsuite(
t,
- ads.NewDriver(options.WithCustomLogger(testutils.ProduceTestingLogger(t))),
+ ads.NewDriver(withCustomLogger),
"assets/testing/protocols/ads/DriverTestsuite.xml",
adsIO.AdsXmlParserHelper{},
testutils.WithRootTypeParser(parser),
+ withCustomLogger,
)
}
diff --git a/plc4go/tests/drivers/tests/ads_parser_serializer_test.go b/plc4go/tests/drivers/tests/ads_parser_serializer_test.go
index 5e6832e3eb..bbe7651d39 100644
--- a/plc4go/tests/drivers/tests/ads_parser_serializer_test.go
+++ b/plc4go/tests/drivers/tests/ads_parser_serializer_test.go
@@ -20,6 +20,7 @@
package tests
import (
+ "github.com/apache/plc4x/plc4go/spi/options"
"testing"
adsIO "github.com/apache/plc4x/plc4go/protocols/ads/readwrite"
@@ -32,5 +33,6 @@ func TestAdsParserSerializer(t *testing.T) {
testutils.RunParserSerializerTestsuite(t,
"assets/testing/protocols/ads/ParserSerializerTestsuite.xml",
adsIO.AdsParserHelper{},
+ options.WithCustomLogger(testutils.ProduceTestingLogger(t)),
)
}
diff --git a/plc4go/tests/drivers/tests/bacnet_parser_serializer_test.go b/plc4go/tests/drivers/tests/bacnet_parser_serializer_test.go
index b498e9ecd6..7a7b809f4d 100644
--- a/plc4go/tests/drivers/tests/bacnet_parser_serializer_test.go
+++ b/plc4go/tests/drivers/tests/bacnet_parser_serializer_test.go
@@ -21,6 +21,7 @@ package tests
import (
readWriteModel "github.com/apache/plc4x/plc4go/protocols/bacnetip/readwrite/model"
+ "github.com/apache/plc4x/plc4go/spi/options"
"testing"
bacnetIO "github.com/apache/plc4x/plc4go/protocols/bacnetip/readwrite"
@@ -33,5 +34,6 @@ func TestBacnetParserSerializer(t *testing.T) {
t,
"assets/testing/protocols/bacnet/ParserSerializerTestsuite.xml",
bacnetIO.BacnetipParserHelper{},
+ options.WithCustomLogger(testutils.ProduceTestingLogger(t)),
)
}
diff --git a/plc4go/tests/drivers/tests/df1_driver_test.go b/plc4go/tests/drivers/tests/df1_driver_test.go
index afd0134d0b..f80fbbc235 100644
--- a/plc4go/tests/drivers/tests/df1_driver_test.go
+++ b/plc4go/tests/drivers/tests/df1_driver_test.go
@@ -32,10 +32,12 @@ import (
func TestDf1Driver(t *testing.T) {
t.Skip("No test yet")
testutils.SetToTestingLogger(t, readWriteModel.Plc4xModelLog)
+ withCustomLogger := options.WithCustomLogger(testutils.ProduceTestingLogger(t))
testutils.RunDriverTestsuite(
t,
- ads.NewDriver(options.WithCustomLogger(testutils.ProduceTestingLogger(t))),
+ ads.NewDriver(withCustomLogger),
"assets/testing/protocols/df1/DriverTestsuite.xml",
df1IO.Df1XmlParserHelper{},
+ withCustomLogger,
)
}
diff --git a/plc4go/tests/drivers/tests/df1_parser_serializer_test.go b/plc4go/tests/drivers/tests/df1_parser_serializer_test.go
index 6c0c6110fd..63cf47f1bb 100644
--- a/plc4go/tests/drivers/tests/df1_parser_serializer_test.go
+++ b/plc4go/tests/drivers/tests/df1_parser_serializer_test.go
@@ -20,6 +20,7 @@
package tests
import (
+ "github.com/apache/plc4x/plc4go/spi/options"
"testing"
df1IO "github.com/apache/plc4x/plc4go/protocols/df1/readwrite"
@@ -33,5 +34,6 @@ func TestDf1ParserSerializer(t *testing.T) {
t,
"assets/testing/protocols/df1/ParserSerializerTestsuite.xml",
df1IO.Df1ParserHelper{},
+ options.WithCustomLogger(testutils.ProduceTestingLogger(t)),
)
}
diff --git a/plc4go/tests/drivers/tests/eip_driver_test.go b/plc4go/tests/drivers/tests/eip_driver_test.go
index 114bade845..a90a55af14 100644
--- a/plc4go/tests/drivers/tests/eip_driver_test.go
+++ b/plc4go/tests/drivers/tests/eip_driver_test.go
@@ -31,10 +31,12 @@ import (
func TestEIPDriver(t *testing.T) {
testutils.SetToTestingLogger(t, readWriteModel.Plc4xModelLog)
+ withCustomLogger := options.WithCustomLogger(testutils.ProduceTestingLogger(t))
testutils.RunDriverTestsuite(
t,
- eip.NewDriver(options.WithCustomLogger(testutils.ProduceTestingLogger(t))),
+ eip.NewDriver(withCustomLogger),
"assets/testing/protocols/eip/DriverTestsuite.xml",
eipIO.EipXmlParserHelper{},
+ withCustomLogger,
)
}
diff --git a/plc4go/tests/drivers/tests/eip_parser_serializer_test.go b/plc4go/tests/drivers/tests/eip_parser_serializer_test.go
index 7b87ef8fe9..e3a0e33f66 100644
--- a/plc4go/tests/drivers/tests/eip_parser_serializer_test.go
+++ b/plc4go/tests/drivers/tests/eip_parser_serializer_test.go
@@ -20,6 +20,7 @@
package tests
import (
+ "github.com/apache/plc4x/plc4go/spi/options"
"testing"
eipIO "github.com/apache/plc4x/plc4go/protocols/eip/readwrite"
@@ -33,6 +34,7 @@ func TestEipParserSerializerBigEndian(t *testing.T) {
t,
"assets/testing/protocols/eip/ParserSerializerTestsuiteBigEndian.xml",
eipIO.EipParserHelper{},
+ options.WithCustomLogger(testutils.ProduceTestingLogger(t)),
)
}
@@ -42,5 +44,6 @@ func TestEipParserSerializerLittleEndian(t *testing.T) {
t,
"assets/testing/protocols/eip/ParserSerializerTestsuiteLittleEndian.xml",
eipIO.EipParserHelper{},
+ options.WithCustomLogger(testutils.ProduceTestingLogger(t)),
)
}
diff --git a/plc4go/tests/drivers/tests/firmata_driver_test.go b/plc4go/tests/drivers/tests/firmata_driver_test.go
index cfbfb64c5a..112f28bbbb 100644
--- a/plc4go/tests/drivers/tests/firmata_driver_test.go
+++ b/plc4go/tests/drivers/tests/firmata_driver_test.go
@@ -20,6 +20,7 @@
package tests
import (
+ "github.com/apache/plc4x/plc4go/spi/options"
"testing"
"github.com/apache/plc4x/plc4go/internal/knxnetip"
@@ -31,10 +32,12 @@ import (
func TestFirmataDriver(t *testing.T) {
t.Skip("no testsuite yet")
testutils.SetToTestingLogger(t, readWriteModel.Plc4xModelLog)
+ withCustomLogger := options.WithCustomLogger(testutils.ProduceTestingLogger(t))
testutils.RunDriverTestsuite(
t,
- knxnetip.NewDriver(),
+ knxnetip.NewDriver(withCustomLogger),
"assets/testing/protocols/firmata/DriverTestsuite.xml",
firmataIO.FirmataXmlParserHelper{},
+ withCustomLogger,
)
}
diff --git a/plc4go/tests/drivers/tests/firmata_parser_serializer_test.go b/plc4go/tests/drivers/tests/firmata_parser_serializer_test.go
index 682ef7fb51..10858686b8 100644
--- a/plc4go/tests/drivers/tests/firmata_parser_serializer_test.go
+++ b/plc4go/tests/drivers/tests/firmata_parser_serializer_test.go
@@ -20,6 +20,7 @@
package tests
import (
+ "github.com/apache/plc4x/plc4go/spi/options"
"testing"
firmataIO "github.com/apache/plc4x/plc4go/protocols/firmata/readwrite"
@@ -33,5 +34,6 @@ func TestFirmataParserSerializer(t *testing.T) {
t,
"assets/testing/protocols/firmata/ParserSerializerTestsuite.xml",
firmataIO.FirmataParserHelper{},
+ options.WithCustomLogger(testutils.ProduceTestingLogger(t)),
)
}
diff --git a/plc4go/tests/drivers/tests/knxnetip_driver_test.go b/plc4go/tests/drivers/tests/knxnetip_driver_test.go
index 443455f9a1..e953e877c6 100644
--- a/plc4go/tests/drivers/tests/knxnetip_driver_test.go
+++ b/plc4go/tests/drivers/tests/knxnetip_driver_test.go
@@ -37,11 +37,13 @@ func TestKNXNetIPDriver(t *testing.T) {
parser := func(readBufferByteBased utils.ReadBufferByteBased) (any, error) {
return readWriteModel.KnxNetIpMessageParseWithBuffer(context.Background(), readBufferByteBased)
}
+ withCustomLogger := options.WithCustomLogger(testutils.ProduceTestingLogger(t))
testutils.RunDriverTestsuite(
t,
- knxnetip.NewDriver(options.WithCustomLogger(testutils.ProduceTestingLogger(t))),
+ knxnetip.NewDriver(withCustomLogger),
"assets/testing/protocols/knxnetip/DriverTestsuite.xml",
knxIO.KnxnetipXmlParserHelper{},
testutils.WithRootTypeParser(parser),
+ withCustomLogger,
)
}
diff --git a/plc4go/tests/drivers/tests/knxnetip_parser_serializer_test.go b/plc4go/tests/drivers/tests/knxnetip_parser_serializer_test.go
index 9a15e03fd2..9e37012151 100644
--- a/plc4go/tests/drivers/tests/knxnetip_parser_serializer_test.go
+++ b/plc4go/tests/drivers/tests/knxnetip_parser_serializer_test.go
@@ -20,6 +20,7 @@
package tests
import (
+ "github.com/apache/plc4x/plc4go/spi/options"
"testing"
knxIO "github.com/apache/plc4x/plc4go/protocols/knxnetip/readwrite"
@@ -33,5 +34,6 @@ func TestKNXNetIPParserSerializer(t *testing.T) {
t,
"assets/testing/protocols/knxnetip/ParserSerializerTestsuite.xml",
knxIO.KnxnetipParserHelper{},
+ options.WithCustomLogger(testutils.ProduceTestingLogger(t)),
)
}
diff --git a/plc4go/tests/drivers/tests/modbus_driver_test.go b/plc4go/tests/drivers/tests/modbus_driver_test.go
index a52b91fb79..68ec24556f 100644
--- a/plc4go/tests/drivers/tests/modbus_driver_test.go
+++ b/plc4go/tests/drivers/tests/modbus_driver_test.go
@@ -36,11 +36,13 @@ func TestModbusDriver(t *testing.T) {
parser := func(readBufferByteBased utils.ReadBufferByteBased) (any, error) {
return readWriteModel.ModbusTcpADUParseWithBuffer(context.Background(), readBufferByteBased, readWriteModel.DriverType_MODBUS_TCP, false)
}
+ withCustomLogger := options.WithCustomLogger(testutils.ProduceTestingLogger(t))
testutils.RunDriverTestsuite(
t,
- modbus.NewModbusTcpDriver(options.WithCustomLogger(testutils.ProduceTestingLogger(t))),
+ modbus.NewModbusTcpDriver(withCustomLogger),
"assets/testing/protocols/modbus/tcp/DriverTestsuite.xml",
modbusIO.ModbusXmlParserHelper{},
testutils.WithRootTypeParser(parser),
+ withCustomLogger,
)
}
diff --git a/plc4go/tests/drivers/tests/modbus_parser_serializer_test.go b/plc4go/tests/drivers/tests/modbus_parser_serializer_test.go
index 47d9ba4dc4..06cabaed73 100644
--- a/plc4go/tests/drivers/tests/modbus_parser_serializer_test.go
+++ b/plc4go/tests/drivers/tests/modbus_parser_serializer_test.go
@@ -20,6 +20,7 @@
package tests
import (
+ "github.com/apache/plc4x/plc4go/spi/options"
"testing"
modbusIO "github.com/apache/plc4x/plc4go/protocols/modbus/readwrite"
@@ -35,5 +36,6 @@ func TestModbusParserSerializer(t *testing.T) {
t,
"assets/testing/protocols/modbus/tcp/ParserSerializerTestsuite.xml",
modbusIO.ModbusParserHelper{},
+ options.WithCustomLogger(testutils.ProduceTestingLogger(t)),
)
}
diff --git a/plc4go/tests/drivers/tests/s7_driver_test.go b/plc4go/tests/drivers/tests/s7_driver_test.go
index 763337957d..ef24c191c8 100644
--- a/plc4go/tests/drivers/tests/s7_driver_test.go
+++ b/plc4go/tests/drivers/tests/s7_driver_test.go
@@ -36,9 +36,10 @@ func TestS7Driver(t *testing.T) {
parser := func(readBufferByteBased utils.ReadBufferByteBased) (any, error) {
return readWriteModel.TPKTPacketParseWithBuffer(context.Background(), readBufferByteBased)
}
+ withCustomLogger := options.WithCustomLogger(testutils.ProduceTestingLogger(t))
testutils.RunDriverTestsuite(
t,
- s7.NewDriver(options.WithCustomLogger(testutils.ProduceTestingLogger(t))),
+ s7.NewDriver(withCustomLogger),
"assets/testing/protocols/s7/DriverTestsuite.xml",
s7IO.S7XmlParserHelper{},
testutils.WithRootTypeParser(parser),
@@ -47,5 +48,6 @@ func TestS7Driver(t *testing.T) {
"Single element read request",
"Single element read request with disabled PUT/GET",
),
+ withCustomLogger,
)
}
diff --git a/plc4go/tests/drivers/tests/s7_parser_serializer_test.go b/plc4go/tests/drivers/tests/s7_parser_serializer_test.go
index d11274379e..0d5b004e68 100644
--- a/plc4go/tests/drivers/tests/s7_parser_serializer_test.go
+++ b/plc4go/tests/drivers/tests/s7_parser_serializer_test.go
@@ -20,6 +20,7 @@
package tests
import (
+ "github.com/apache/plc4x/plc4go/spi/options"
"testing"
s7IO "github.com/apache/plc4x/plc4go/protocols/s7/readwrite"
@@ -43,5 +44,6 @@ func TestS7ParserSerializer(t *testing.T) {
"S7 Write Request",
"S7 Write Request",
),
+ options.WithCustomLogger(testutils.ProduceTestingLogger(t)),
)
}