@@ -22,6 +22,7 @@ import (
22
22
23
23
"github.com/arduino/arduino-cli/arduino/cores/packagemanager"
24
24
"github.com/arduino/go-paths-helper"
25
+ "github.com/arduino/go-properties-orderedmap"
25
26
"github.com/stretchr/testify/require"
26
27
)
27
28
@@ -43,3 +44,44 @@ func TestFindBoardWithFQBN(t *testing.T) {
43
44
require .NotNil (t , board )
44
45
require .Equal (t , board .Name (), "Arduino/Genuino Mega or Mega 2560" )
45
46
}
47
+
48
+ func TestBoardOptionsFunctions (t * testing.T ) {
49
+ pm := packagemanager .NewPackageManager (
50
+ paths .New ("testdata" ),
51
+ paths .New ("testdata" ),
52
+ paths .New ("testdata" ),
53
+ paths .New ("testdata" ))
54
+ pm .LoadHardwareFromDirectory (paths .New ("testdata" ))
55
+
56
+ nano , err := pm .FindBoardWithFQBN ("arduino:avr:nano" )
57
+ require .Nil (t , err )
58
+ require .NotNil (t , nano )
59
+ require .Equal (t , nano .Name (), "Arduino Nano" )
60
+
61
+ nanoOptions := nano .GetConfigOptions ()
62
+ require .Equal (t , "Processor" , nanoOptions .Get ("cpu" ))
63
+ require .Equal (t , 1 , nanoOptions .Size ())
64
+ nanoCpuValues := nano .GetConfigOptionValues ("cpu" )
65
+
66
+ expectedNanoCpuValues := properties .NewMap ()
67
+ expectedNanoCpuValues .Set ("atmega328" , "ATmega328P" )
68
+ expectedNanoCpuValues .Set ("atmega328old" , "ATmega328P (Old Bootloader)" )
69
+ expectedNanoCpuValues .Set ("atmega168" , "ATmega168" )
70
+ require .EqualValues (t , expectedNanoCpuValues , nanoCpuValues )
71
+
72
+ esp8266 , err := pm .FindBoardWithFQBN ("esp8266:esp8266:generic" )
73
+ require .Nil (t , err )
74
+ require .NotNil (t , esp8266 )
75
+ require .Equal (t , esp8266 .Name (), "Generic ESP8266 Module" )
76
+
77
+ esp8266Options := esp8266 .GetConfigOptions ()
78
+ require .Equal (t , 13 , esp8266Options .Size ())
79
+ require .Equal (t , "Builtin Led" , esp8266Options .Get ("led" ))
80
+ require .Equal (t , "Upload Speed" , esp8266Options .Get ("UploadSpeed" ))
81
+
82
+ esp8266UploadSpeedValues := esp8266 .GetConfigOptionValues ("UploadSpeed" )
83
+ for k , v := range esp8266UploadSpeedValues .AsMap () {
84
+ // Some option values are missing for a particular OS: check that only the available options are listed
85
+ require .Equal (t , k , v )
86
+ }
87
+ }
0 commit comments