From 2fe2abfa5c54c4b8c90433473c66f58f477c1366 Mon Sep 17 00:00:00 2001 From: deadprogram Date: Thu, 25 Aug 2016 21:14:43 +0200 Subject: [PATCH] [intel-iot] Move test interfaces into test files Signed-off-by: deadprogram --- platforms/intel-iot/edison/edison_adaptor.go | 11 -- .../intel-iot/edison/edison_adaptor_test.go | 13 ++ platforms/intel-iot/joule/joule_adaptor.go | 182 +++++++++--------- .../intel-iot/joule/joule_adaptor_test.go | 11 ++ 4 files changed, 110 insertions(+), 107 deletions(-) diff --git a/platforms/intel-iot/edison/edison_adaptor.go b/platforms/intel-iot/edison/edison_adaptor.go index be12770b..494c8b87 100644 --- a/platforms/intel-iot/edison/edison_adaptor.go +++ b/platforms/intel-iot/edison/edison_adaptor.go @@ -6,20 +6,9 @@ import ( "strconv" "github.com/hybridgroup/gobot" - "github.com/hybridgroup/gobot/platforms/gpio" - "github.com/hybridgroup/gobot/platforms/i2c" "github.com/hybridgroup/gobot/sysfs" ) -var _ gobot.Adaptor = (*EdisonAdaptor)(nil) - -var _ gpio.DigitalReader = (*EdisonAdaptor)(nil) -var _ gpio.DigitalWriter = (*EdisonAdaptor)(nil) -var _ gpio.AnalogReader = (*EdisonAdaptor)(nil) -var _ gpio.PwmWriter = (*EdisonAdaptor)(nil) - -var _ i2c.I2c = (*EdisonAdaptor)(nil) - func writeFile(path string, data []byte) (i int, err error) { file, err := sysfs.OpenFile(path, os.O_WRONLY, 0644) defer file.Close() diff --git a/platforms/intel-iot/edison/edison_adaptor_test.go b/platforms/intel-iot/edison/edison_adaptor_test.go index 5fa78745..7f7585ae 100644 --- a/platforms/intel-iot/edison/edison_adaptor_test.go +++ b/platforms/intel-iot/edison/edison_adaptor_test.go @@ -4,10 +4,22 @@ import ( "errors" "testing" + "github.com/hybridgroup/gobot" "github.com/hybridgroup/gobot/gobottest" + "github.com/hybridgroup/gobot/platforms/gpio" + "github.com/hybridgroup/gobot/platforms/i2c" "github.com/hybridgroup/gobot/sysfs" ) +var _ gobot.Adaptor = (*EdisonAdaptor)(nil) + +var _ gpio.DigitalReader = (*EdisonAdaptor)(nil) +var _ gpio.DigitalWriter = (*EdisonAdaptor)(nil) +var _ gpio.AnalogReader = (*EdisonAdaptor)(nil) +var _ gpio.PwmWriter = (*EdisonAdaptor)(nil) + +var _ i2c.I2c = (*EdisonAdaptor)(nil) + type NullReadWriteCloser struct { contents []byte } @@ -115,6 +127,7 @@ func TestEdisonAdaptor(t *testing.T) { a, _ := initTestEdisonAdaptor() gobottest.Assert(t, a.Name(), "myAdaptor") } + func TestEdisonAdaptorConnect(t *testing.T) { a, _ := initTestEdisonAdaptor() gobottest.Assert(t, len(a.Connect()), 0) diff --git a/platforms/intel-iot/joule/joule_adaptor.go b/platforms/intel-iot/joule/joule_adaptor.go index 71fdf973..2aa01254 100644 --- a/platforms/intel-iot/joule/joule_adaptor.go +++ b/platforms/intel-iot/joule/joule_adaptor.go @@ -6,19 +6,9 @@ import ( "strconv" "github.com/hybridgroup/gobot" - "github.com/hybridgroup/gobot/platforms/gpio" - "github.com/hybridgroup/gobot/platforms/i2c" "github.com/hybridgroup/gobot/sysfs" ) -var _ gobot.Adaptor = (*JouleAdaptor)(nil) - -var _ gpio.DigitalReader = (*JouleAdaptor)(nil) -var _ gpio.DigitalWriter = (*JouleAdaptor)(nil) -var _ gpio.PwmWriter = (*JouleAdaptor)(nil) - -var _ i2c.I2c = (*JouleAdaptor)(nil) - func writeFile(path string, data []byte) (i int, err error) { file, err := sysfs.OpenFile(path, os.O_WRONLY, 0644) defer file.Close() @@ -46,8 +36,8 @@ func readFile(path string) ([]byte, error) { } type sysfsPin struct { - pin int - pwmPin int + pin int + pwmPin int } // JouleAdaptor represents an Intel Joule @@ -62,199 +52,199 @@ type JouleAdaptor struct { var sysfsPinMap = map[string]sysfsPin{ // disabled "0": sysfsPin{ - pin: -1, - pwmPin: -1, + pin: -1, + pwmPin: -1, }, "1": sysfsPin{ - pin: 446, - pwmPin: -1, + pin: 446, + pwmPin: -1, }, "2": sysfsPin{ - pin: 421, - pwmPin: -1, + pin: 421, + pwmPin: -1, }, // disabled "3": sysfsPin{ - pin: -1, - pwmPin: -1, + pin: -1, + pwmPin: -1, }, "4": sysfsPin{ - pin: 422, - pwmPin: -1, + pin: 422, + pwmPin: -1, }, "5": sysfsPin{ - pin: 356, - pwmPin: -1, + pin: 356, + pwmPin: -1, }, "6": sysfsPin{ - pin: 417, - pwmPin: -1, + pin: 417, + pwmPin: -1, }, // UART "7": sysfsPin{ - pin: -1, - pwmPin: -1, + pin: -1, + pwmPin: -1, }, "8": sysfsPin{ - pin: 419, - pwmPin: -1, + pin: 419, + pwmPin: -1, }, // disabled "9": sysfsPin{ - pin: -1, - pwmPin: -1, + pin: -1, + pwmPin: -1, }, "10": sysfsPin{ - pin: 416, - pwmPin: -1, + pin: 416, + pwmPin: -1, }, "11": sysfsPin{ - pin: 381, - pwmPin: -1, + pin: 381, + pwmPin: -1, }, "13": sysfsPin{ - pin: 382, - pwmPin: -1, + pin: 382, + pwmPin: -1, }, "15": sysfsPin{ - pin: 380, - pwmPin: -1, + pin: 380, + pwmPin: -1, }, "17": sysfsPin{ - pin: 379, - pwmPin: -1, + pin: 379, + pwmPin: -1, }, "19": sysfsPin{ - pin: 378, - pwmPin: -1, + pin: 378, + pwmPin: -1, }, // UART "21": sysfsPin{ - pin: -1, - pwmPin: -1, + pin: -1, + pwmPin: -1, }, // disabled "22": sysfsPin{ - pin: -1, - pwmPin: -1, + pin: -1, + pwmPin: -1, }, // UART "23": sysfsPin{ - pin: -1, - pwmPin: -1, + pin: -1, + pwmPin: -1, }, // disabled "24": sysfsPin{ - pin: -1, - pwmPin: -1, + pin: -1, + pwmPin: -1, }, "25": sysfsPin{ - pin: 463, - pwmPin: 0, + pin: 463, + pwmPin: 0, }, // low voltage should not use "26": sysfsPin{ - pin: -1, - pwmPin: -1, + pin: -1, + pwmPin: -1, }, "27": sysfsPin{ - pin: 464, - pwmPin: 1, + pin: 464, + pwmPin: 1, }, // disabled "28": sysfsPin{ - pin: -1, - pwmPin: -1, + pin: -1, + pwmPin: -1, }, "29": sysfsPin{ - pin: 465, - pwmPin: 2, + pin: 465, + pwmPin: 2, }, // disabled? "30": sysfsPin{ - pin: -1, - pwmPin: -1, + pin: -1, + pwmPin: -1, }, "31": sysfsPin{ - pin: 466, - pwmPin: 3, + pin: 466, + pwmPin: 3, }, // disabled? "32": sysfsPin{ - pin: -1, - pwmPin: -1, + pin: -1, + pwmPin: -1, }, // disabled "33": sysfsPin{ - pin: -1, - pwmPin: -1, + pin: -1, + pwmPin: -1, }, "34": sysfsPin{ - pin: 393, - pwmPin: -1, + pin: 393, + pwmPin: -1, }, // GND "35": sysfsPin{ - pin: -1, - pwmPin: -1, + pin: -1, + pwmPin: -1, }, // GND "36": sysfsPin{ - pin: -1, - pwmPin: -1, + pin: -1, + pwmPin: -1, }, // GND "37": sysfsPin{ - pin: -1, - pwmPin: -1, + pin: -1, + pwmPin: -1, }, // GND "38": sysfsPin{ - pin: -1, - pwmPin: -1, + pin: -1, + pwmPin: -1, }, // disabled "39": sysfsPin{ - pin: -1, - pwmPin: -1, + pin: -1, + pwmPin: -1, }, // GND "40": sysfsPin{ - pin: -1, - pwmPin: -1, + pin: -1, + pwmPin: -1, }, // TODO: Second header // LED100 "100": sysfsPin{ - pin: 337, - pwmPin: -1, + pin: 337, + pwmPin: -1, }, // LED101 "101": sysfsPin{ - pin: 338, - pwmPin: -1, + pin: 338, + pwmPin: -1, }, // LED102 "102": sysfsPin{ - pin: 339, - pwmPin: -1, + pin: 339, + pwmPin: -1, }, // LED103 "103": sysfsPin{ - pin: 340, - pwmPin: -1, + pin: 340, + pwmPin: -1, }, // LEDWIFI "104": sysfsPin{ - pin: 438, - pwmPin: -1, + pin: 438, + pwmPin: -1, }, // LEDBT "105": sysfsPin{ - pin: 439, - pwmPin: -1, + pin: 439, + pwmPin: -1, }, } diff --git a/platforms/intel-iot/joule/joule_adaptor_test.go b/platforms/intel-iot/joule/joule_adaptor_test.go index 8b518eed..3392680d 100644 --- a/platforms/intel-iot/joule/joule_adaptor_test.go +++ b/platforms/intel-iot/joule/joule_adaptor_test.go @@ -4,10 +4,21 @@ import ( "errors" "testing" + "github.com/hybridgroup/gobot" "github.com/hybridgroup/gobot/gobottest" + "github.com/hybridgroup/gobot/platforms/gpio" + "github.com/hybridgroup/gobot/platforms/i2c" "github.com/hybridgroup/gobot/sysfs" ) +var _ gobot.Adaptor = (*JouleAdaptor)(nil) + +var _ gpio.DigitalReader = (*JouleAdaptor)(nil) +var _ gpio.DigitalWriter = (*JouleAdaptor)(nil) +var _ gpio.PwmWriter = (*JouleAdaptor)(nil) + +var _ i2c.I2c = (*JouleAdaptor)(nil) + type NullReadWriteCloser struct { contents []byte }