@@ -16,6 +16,7 @@ package debug
1616
1717import (
1818 "fmt"
19+ "path/filepath"
1920 "runtime"
2021 "strings"
2122 "testing"
@@ -36,6 +37,12 @@ func TestGetCommandLine(t *testing.T) {
3637 pm .LoadHardwareFromDirectory (customHardware )
3738 pm .LoadHardwareFromDirectory (dataDir )
3839
40+ // Windows tools have .exe extension
41+ var toolExtension = ""
42+ if runtime .GOOS == "windows" {
43+ toolExtension = ".exe"
44+ }
45+
3946 // Arduino Zero has an integrated debugger port, anc it could be debugged directly using USB
4047 req := & dbg.DebugConfigReq {
4148 Instance : & dbg.Instance {Id : 1 },
@@ -44,25 +51,17 @@ func TestGetCommandLine(t *testing.T) {
4451 Port : "none" ,
4552 }
4653
47- goldCommand := fmt .Sprintf ("%s/arduino-test/tools/arm-none-eabi-gcc/7-2017q4/bin//arm-none-eabi-gdb" , dataDir ) +
54+ goldCommand := fmt .Sprintf ("%s/arduino-test/tools/arm-none-eabi-gcc/7-2017q4/bin//arm-none-eabi-gdb%s " , dataDir , toolExtension ) +
4855 " -ex target extended-remote |" +
49- fmt .Sprintf (" %s/arduino-test/tools/openocd/0.10.0-arduino7/bin/openocd" , dataDir ) +
56+ fmt .Sprintf (" %s/arduino-test/tools/openocd/0.10.0-arduino7/bin/openocd%s " , dataDir , toolExtension ) +
5057 fmt .Sprintf (" -s \" %s/arduino-test/tools/openocd/0.10.0-arduino7/share/openocd/scripts/\" " , dataDir ) +
5158 fmt .Sprintf (" --file \" %s/arduino-test/samd/variants/arduino_zero/openocd_scripts/arduino_zero.cfg\" " , customHardware ) +
5259 fmt .Sprintf (" -c \" gdb_port pipe\" -c \" telnet_port 0\" -c init -c halt %s/hello.arduino-test.samd.arduino_zero_edbg.elf" , sketchPath )
5360
54- if runtime .GOOS == "windows" {
55- goldCommand = fmt .Sprintf ("%s\\ arduino-test\\ tools\\ arm-none-eabi-gcc\\ 7-2017q4/bin//arm-none-eabi-gdb.exe" , dataDir ) +
56- " -ex target extended-remote |" +
57- fmt .Sprintf (" %s\\ arduino-test\\ tools\\ openocd\\ 0.10.0-arduino7/bin/openocd.exe" , dataDir ) +
58- fmt .Sprintf (" -s \" %s\\ arduino-test\\ tools\\ openocd\\ 0.10.0-arduino7/share/openocd/scripts/\" " , dataDir ) +
59- fmt .Sprintf (" --file \" %s\\ arduino-test\\ samd/variants/arduino_zero/openocd_scripts/arduino_zero.cfg\" " , customHardware ) +
60- fmt .Sprintf (" -c \" gdb_port pipe\" -c \" telnet_port 0\" -c init -c halt %s/hello.arduino-test.samd.arduino_zero_edbg.elf" , sketchPath )
61- }
62-
6361 command , err := getCommandLine (req , pm )
6462 assert .Nil (t , err )
65- assert .Equal (t , goldCommand , strings .Join (command [:], " " ))
63+ commandToTest := strings .Join (command [:], " " )
64+ assert .Equal (t , filepath .FromSlash (goldCommand ), filepath .FromSlash (commandToTest ))
6665
6766 // Other samd boards such as mkr1000 can be debugged using an external tool such as Atmel ICE connected to
6867 // the board debug port
@@ -73,23 +72,16 @@ func TestGetCommandLine(t *testing.T) {
7372 Port : "none" ,
7473 }
7574
76- goldCommand2 := fmt .Sprintf ("%s/arduino-test/tools/arm-none-eabi-gcc/7-2017q4/bin//arm-none-eabi-gdb" , dataDir ) +
75+ goldCommand2 := fmt .Sprintf ("%s/arduino-test/tools/arm-none-eabi-gcc/7-2017q4/bin//arm-none-eabi-gdb%s " , dataDir , toolExtension ) +
7776 " -ex target extended-remote |" +
78- fmt .Sprintf (" %s/arduino-test/tools/openocd/0.10.0-arduino7/bin/openocd" , dataDir ) +
77+ fmt .Sprintf (" %s/arduino-test/tools/openocd/0.10.0-arduino7/bin/openocd%s " , dataDir , toolExtension ) +
7978 fmt .Sprintf (" -s \" %s/arduino-test/tools/openocd/0.10.0-arduino7/share/openocd/scripts/\" " , dataDir ) +
8079 fmt .Sprintf (" --file \" %s/arduino-test/samd/variants/mkr1000/openocd_scripts/arduino_zero.cfg\" " , customHardware ) +
8180 fmt .Sprintf (" -c \" gdb_port pipe\" -c \" telnet_port 0\" -c init -c halt %s/hello.arduino-test.samd.mkr1000.elf" , sketchPath )
8281
83- if runtime .GOOS == "windows" {
84- goldCommand2 = fmt .Sprintf ("%s\\ arduino-test\\ tools\\ arm-none-eabi-gcc\\ 7-2017q4/bin//arm-none-eabi-gdb.exe" , dataDir ) +
85- " -ex target extended-remote |" +
86- fmt .Sprintf (" %s\\ arduino-test\\ tools\\ openocd\\ 0.10.0-arduino7/bin/openocd.exe" , dataDir ) +
87- fmt .Sprintf (" -s \" %s\\ arduino-test\\ tools\\ openocd\\ 0.10.0-arduino7/share/openocd/scripts/\" " , dataDir ) +
88- fmt .Sprintf (" --file \" %s\\ arduino-test\\ samd/variants/mkr1000/openocd_scripts/arduino_zero.cfg\" " , customHardware ) +
89- fmt .Sprintf (" -c \" gdb_port pipe\" -c \" telnet_port 0\" -c init -c halt %s/hello.arduino-test.samd.mkr1000.elf" , sketchPath )
90- }
91-
9282 command2 , err := getCommandLine (req2 , pm )
9383 assert .Nil (t , err )
94- assert .Equal (t , goldCommand2 , strings .Join (command2 [:], " " ))
84+ commandToTest2 := strings .Join (command2 [:], " " )
85+ assert .Equal (t , filepath .FromSlash (goldCommand2 ), filepath .FromSlash (commandToTest2 ))
86+
9587}
0 commit comments