@@ -261,6 +261,21 @@ func TestTimerStopResetRace(t *testing.T) {
261261 runTest ("timer_stop_reset_race.go" , optionsFromTarget ("" , sema ), t , nil , nil )
262262}
263263
264+ func TestESP32QEMU (t * testing.T ) {
265+ t .Parallel ()
266+
267+ options := optionsFromTarget ("esp32-qemu" , sema )
268+ emuCheck (t , options )
269+ machines , err := exec .Command ("qemu-system-xtensa" , "-machine" , "help" ).Output ()
270+ if err != nil {
271+ t .Fatal ("failed to list qemu-system-xtensa machines:" , err )
272+ }
273+ if ! regexp .MustCompile (`(?m)^esp32\s` ).Match (machines ) {
274+ t .Skip ("qemu-system-xtensa does not support the ESP32 machine" )
275+ }
276+ runTest ("print.go" , options , t , nil , nil )
277+ }
278+
264279func runPlatTests (options compileopts.Options , tests []string , t * testing.T ) {
265280 emuCheck (t , options )
266281
@@ -539,6 +554,9 @@ func runTestWithConfig(name string, t *testing.T, options compileopts.Options, c
539554 if config .EmulatorName () == "simavr" {
540555 actual = cleanSimAVRTestOutput (actual )
541556 }
557+ if config .EmulatorName () == "qemu-system-xtensa" {
558+ actual = cleanESP32QEMUOutput (actual )
559+ }
542560 if name == "testing.go" {
543561 // Strip actual time.
544562 re := regexp .MustCompile (`\([0-9]\.[0-9][0-9]s\)` )
@@ -564,6 +582,18 @@ func runTestWithConfig(name string, t *testing.T, options compileopts.Options, c
564582 }
565583}
566584
585+ func cleanESP32QEMUOutput (output []byte ) []byte {
586+ entryLine := bytes .Index (output , []byte ("\n entry " ))
587+ if entryLine < 0 {
588+ return output
589+ }
590+ entryLineEnd := bytes .IndexByte (output [entryLine + 1 :], '\n' )
591+ if entryLineEnd < 0 {
592+ return output
593+ }
594+ return output [entryLine + 1 + entryLineEnd + 1 :]
595+ }
596+
567597func cleanSimAVRTestOutput (output []byte ) []byte {
568598 output = bytes .ReplaceAll (output , []byte {0x1b , '[' , '3' , '2' , 'm' }, nil )
569599 output = bytes .ReplaceAll (output , []byte {0x1b , '[' , '0' , 'm' }, nil )
0 commit comments