@@ -22,6 +22,7 @@ import (
2222
2323 "github.com/arduino/arduino-cli/arduino/cores/packagemanager"
2424 "github.com/arduino/go-paths-helper"
25+ "github.com/arduino/go-properties-orderedmap"
2526 "github.com/stretchr/testify/require"
2627)
2728
@@ -43,3 +44,44 @@ func TestFindBoardWithFQBN(t *testing.T) {
4344 require .NotNil (t , board )
4445 require .Equal (t , board .Name (), "Arduino/Genuino Mega or Mega 2560" )
4546}
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