Malformed output for Embedded Tests with googletest and ESP8266

Hello

When I use Embedded Test with googletest and a HUZZAH ESP8266 Board, I get malformed output, which leads to wrong test result.

I have a dummy test that is executed native and embedded. It is pass but in the end marked as SKIPPED.
(see the end of output)

I found out the reason for this behavior is the serial output of the device to the host. Which is malformed.
For example the lines 247 and 248 should be switched and on one line as can be seen in
gtest.cc around line 3432 and 3433.

I find this behavior very strange. Somehow it looks like the string outputs are switched around.
I’m not sure what causes this behavior (gtest, gcc, platformio, vscode, …)
Or am I getting something wrong.

The repository is here: https://github.com/erichstuder/TurnTable/tree/wifi/software/firmware
Branch: wifi

Do you have any idea what causes this behavior and what I could do against it?

platformio.ini

[platformio]
test_dir = unit_tests

[env]
test_framework = googletest

[env:native]
platform = native

[env:huzzah]
platform = espressif8266
board = huzzah
framework = arduino
test_speed = 38400
lib_deps =
	256dpi/MQTT@^2.5.1
	jwrw/ESP_EEPROM@^2.2.1

here the full output of “pio test -vv”

Collected 1 tests (*)

Processing * in native environment
--------------------------------------------------------------------------------
Building...
Verbose mode can be enabled via `-v, --verbose` option
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 1 compatible libraries
Scanning dependencies...
Dependency Graph
|-- googletest @ 1.12.1
Building in test mode
Compiling .pio/build/native/test/test_main.o
Compiling .pio/build/native/lib12c/googletest/googlemock/src/gmock-cardinalities.o
Compiling .pio/build/native/lib12c/googletest/googlemock/src/gmock-internal-utils.o
Compiling .pio/build/native/lib12c/googletest/googlemock/src/gmock-matchers.o
Compiling .pio/build/native/lib12c/googletest/googlemock/src/gmock-spec-builders.o
Compiling .pio/build/native/lib12c/googletest/googlemock/src/gmock.o
Compiling .pio/build/native/lib12c/googletest/googletest/src/gtest-assertion-result.o
Compiling .pio/build/native/lib12c/googletest/googletest/src/gtest-death-test.o
Compiling .pio/build/native/lib12c/googletest/googletest/src/gtest-filepath.o
Compiling .pio/build/native/lib12c/googletest/googletest/src/gtest-matchers.o
Compiling .pio/build/native/lib12c/googletest/googletest/src/gtest-port.o
Compiling .pio/build/native/lib12c/googletest/googletest/src/gtest-printers.o
Compiling .pio/build/native/lib12c/googletest/googletest/src/gtest-test-part.o
Compiling .pio/build/native/lib12c/googletest/googletest/src/gtest-typed-test.o
Compiling .pio/build/native/lib12c/googletest/googletest/src/gtest.o
Archiving .pio/build/native/lib12c/libgoogletest.a
Indexing .pio/build/native/lib12c/libgoogletest.a
Linking .pio/build/native/program


Testing...
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from DummyTest
[ RUN      ] DummyTest.ShouldPass
[       OK ] DummyTest.ShouldPass (0 ms)
[----------] 1 test from DummyTest (0 ms total)

[----------] Global test environment tear-down
[==========] 1 test from 1 test suite ran. (0 ms total)
[  PASSED  ] 1 test.

--------------------- native:* [PASSED] Took 7.41 seconds ---------------------

Processing * in huzzah environment
--------------------------------------------------------------------------------

Building & Uploading...
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif8266/huzzah.html
PLATFORM: Espressif 8266 (4.2.1) > Adafruit HUZZAH ESP8266
HARDWARE: ESP8266 80MHz, 80KB RAM, 4MB Flash
PACKAGES: 
 - framework-arduinoespressif8266 @ 3.30102.0 (3.1.2) 
 - tool-esptool @ 1.413.0 (4.13) 
 - tool-esptoolpy @ 1.30000.201119 (3.0.0) 
 - tool-mklittlefs @ 1.203.210628 (2.3) 
 - tool-mkspiffs @ 1.200.0 (2.0) 
 - toolchain-xtensa @ 2.100300.220621 (10.3.0)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 40 compatible libraries
Scanning dependencies...
Dependency Graph
|-- MQTT @ 2.5.1
|-- ESP_EEPROM @ 2.2.1
|-- googletest @ 1.12.1
Building in test mode
Compiling .pio/build/huzzah/test/test_main.cpp.o
Generating LD script .pio/build/huzzah/ld/local.eagle.app.v6.common.ld
Compiling .pio/build/huzzah/lib8d0/MQTT/MQTTClient.cpp.o
Compiling .pio/build/huzzah/lib8d0/MQTT/lwmqtt/client.c.o
Compiling .pio/build/huzzah/lib8d0/MQTT/lwmqtt/helpers.c.o
Compiling .pio/build/huzzah/lib8d0/MQTT/lwmqtt/packet.c.o
Compiling .pio/build/huzzah/lib8d0/MQTT/lwmqtt/string.c.o
Compiling .pio/build/huzzah/liba16/ESP_EEPROM/ESP_EEPROM.cpp.o
Compiling .pio/build/huzzah/lib932/googletest/googlemock/src/gmock-cardinalities.cc.o
Compiling .pio/build/huzzah/lib932/googletest/googlemock/src/gmock-internal-utils.cc.o
Compiling .pio/build/huzzah/lib932/googletest/googlemock/src/gmock-matchers.cc.o
Compiling .pio/build/huzzah/lib932/googletest/googlemock/src/gmock-spec-builders.cc.o
Compiling .pio/build/huzzah/lib932/googletest/googlemock/src/gmock.cc.o
Archiving .pio/build/huzzah/liba16/libESP_EEPROM.a
Indexing .pio/build/huzzah/liba16/libESP_EEPROM.a
Compiling .pio/build/huzzah/lib932/googletest/googletest/src/gtest-assertion-result.cc.o
Archiving .pio/build/huzzah/lib8d0/libMQTT.a
Indexing .pio/build/huzzah/lib8d0/libMQTT.a
Compiling .pio/build/huzzah/lib932/googletest/googletest/src/gtest-death-test.cc.o
Compiling .pio/build/huzzah/lib932/googletest/googletest/src/gtest-filepath.cc.o
Compiling .pio/build/huzzah/lib932/googletest/googletest/src/gtest-matchers.cc.o
Compiling .pio/build/huzzah/lib932/googletest/googletest/src/gtest-port.cc.o
Compiling .pio/build/huzzah/lib932/googletest/googletest/src/gtest-printers.cc.o
Compiling .pio/build/huzzah/lib932/googletest/googletest/src/gtest-test-part.cc.o
Compiling .pio/build/huzzah/lib932/googletest/googletest/src/gtest-typed-test.cc.o
Compiling .pio/build/huzzah/lib932/googletest/googletest/src/gtest.cc.o
Archiving .pio/build/huzzah/libFrameworkArduinoVariant.a
Indexing .pio/build/huzzah/libFrameworkArduinoVariant.a
Compiling .pio/build/huzzah/FrameworkArduino/Crypto.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/Esp-frag.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/Esp-version.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/Esp.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/FS.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/FSnoop.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/FunctionalInterrupt.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/HardwareSerial.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/IPAddress.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/LwipDhcpServer-NonOS.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/LwipDhcpServer.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/LwipIntf.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/LwipIntfCB.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/MD5Builder.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/Print.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/Schedule.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/StackThunk.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/Stream.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/StreamSend.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/Tone.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/TypeConversion.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/Updater.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/WMath.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/WString.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/abi.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/aes_unwrap.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/base64.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/cbuf.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/cont.S.o
Compiling .pio/build/huzzah/FrameworkArduino/cont_util.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/core_esp8266_app_entry_noextra4k.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/core_esp8266_eboot_command.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/core_esp8266_features.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/core_esp8266_flash_quirks.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/core_esp8266_flash_utils.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/core_esp8266_i2s.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/core_esp8266_main.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/core_esp8266_non32xfer.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/core_esp8266_noniso.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/core_esp8266_phy.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/core_esp8266_postmortem.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/core_esp8266_si2c.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/core_esp8266_sigma_delta.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/core_esp8266_spi_utils.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/core_esp8266_timer.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/core_esp8266_vm.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/core_esp8266_waveform_phase.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/core_esp8266_waveform_pwm.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/core_esp8266_wiring.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/core_esp8266_wiring_analog.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/core_esp8266_wiring_digital.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/core_esp8266_wiring_pulse.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/core_esp8266_wiring_pwm.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/core_esp8266_wiring_shift.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/crc32.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/debug.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/exc-c-wrapper-handler.S.o
Compiling .pio/build/huzzah/FrameworkArduino/exc-sethandler.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/flash_hal.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/gdb_hooks.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/heap.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/hwdt_app_entry.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/libb64/cdecode.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/libb64/cencode.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/libc_replacements.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/mmu_iram.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/reboot_uart_dwnld.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/spiffs/spiffs_cache.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/spiffs/spiffs_check.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/spiffs/spiffs_gc.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/spiffs/spiffs_hydrogen.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/spiffs/spiffs_nucleus.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/spiffs_api.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/sqrt32.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/stdlib_noniso.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/time.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/uart.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/umm_malloc/umm_info.c.o
Compiling .pio/build/huzzah/FrameworkArduino/umm_malloc/umm_integrity.c.o
Compiling .pio/build/huzzah/FrameworkArduino/umm_malloc/umm_local.c.o
Compiling .pio/build/huzzah/FrameworkArduino/umm_malloc/umm_malloc.cpp.o
Compiling .pio/build/huzzah/FrameworkArduino/umm_malloc/umm_poison.c.o
Compiling .pio/build/huzzah/FrameworkArduino/wpa2_eap_patch.cpp.o
Archiving .pio/build/huzzah/libFrameworkArduino.a
Indexing .pio/build/huzzah/libFrameworkArduino.a
Archiving .pio/build/huzzah/lib932/libgoogletest.a
Indexing .pio/build/huzzah/lib932/libgoogletest.a
Linking .pio/build/huzzah/firmware.elf
Retrieving maximum program size .pio/build/huzzah/firmware.elf
Checking size .pio/build/huzzah/firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [======    ]  60.7% (used 49704 bytes from 81920 bytes)
Flash: [=====     ]  48.3% (used 504875 bytes from 1044464 bytes)
Building .pio/build/huzzah/firmware.bin
Creating BIN file ".pio/build/huzzah/firmware.bin" using "/home/erich/.platformio/packages/framework-arduinoespressif8266/bootloaders/eboot/eboot.elf" and ".pio/build/huzzah/firmware.elf"
Configuring upload protocol...
AVAILABLE: espota, esptool
CURRENT: upload_protocol = esptool
Looking for upload port...
Auto-detected: /dev/ttyUSB0
Uploading .pio/build/huzzah/firmware.bin
esptool.py v3.0
Serial port /dev/ttyUSB0
Connecting....
Chip is ESP8266EX
Features: WiFi
Crystal is 26MHz
MAC: b4:e6:2d:6a:3b:b9
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Compressed 509024 bytes to 326490...
Writing at 0x00000000... (5 %)
Writing at 0x00004000... (10 %)
Writing at 0x00008000... (15 %)
Writing at 0x0000c000... (20 %)
Writing at 0x00010000... (25 %)
Writing at 0x00014000... (30 %)
Writing at 0x00018000... (35 %)
Writing at 0x0001c000... (40 %)
Writing at 0x00020000... (45 %)
Writing at 0x00024000... (50 %)
Writing at 0x00028000... (55 %)
Writing at 0x0002c000... (60 %)
Writing at 0x00030000... (65 %)
Writing at 0x00034000... (70 %)
Writing at 0x00038000... (75 %)
Writing at 0x0003c000... (80 %)
Writing at 0x00040000... (85 %)
Writing at 0x00044000... (90 %)
Writing at 0x00048000... (95 %)
Writing at 0x0004c000... (100 %)
Wrote 509024 bytes (326490 compressed) at 0x00000000 in 28.7 seconds (effective 142.0 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...

Testing...
If you don't see any output for the first 10 secs, please reset board (press reset button)

bd䄆ć䦦FC愄䤤Ĥ熤DƄbŧĄDÇĥņDĆD慆ĥbĄEbDĤ儤D䤆b
Above you can see output from bootloader => ignore.
It is probably shown as rubbish due to wrong baudrate (bootloader has 74880).

[==========] Running 1 test from 1 test suite.
Global test environment set-up.
[----------] 
[----------] 1 test from DummyTest
[ RUN      ] DummyTest.ShouldPass[       OK ] DummyTest.ShouldPass (0 ms)
[----------] 1 test from DummyTest (19 ms total)

Global test environment tear-down
[----------] 
[==========] 1 test from 1 test suite ran. (109 ms total)[  PASSED  ] 1 test.

--------------------- huzzah:* [PASSED] Took 51.17 seconds ---------------------

=================================== SUMMARY ===================================
Environment    Test    Status    Duration
-------------  ------  --------  ------------
native         *       PASSED    00:00:07.410
huzzah         *       SKIPPED   00:00:51.170
================== 1 test cases: 1 succeeded in 00:00:58.580 ==================

Regards
erichstuder