PlatformIO Community

Pio test broke with esp32doit-devkit-v1 in pio core 6.1

Hi everyone !

I updated the pio core to 6.0.1, so when I started writing a new unit test the pio test stop work :frowning_face:

this is my env:

image

this is the problem:

/home/robson/.platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: .pio/build/esp32doit-devkit-v1/libFrameworkArduino.a(main.cpp.o):(.literal._Z8loopTaskPv+0x8): undefined reference to `setup()'
/home/robson/.platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: .pio/build/esp32doit-devkit-v1/libFrameworkArduino.a(main.cpp.o):(.literal._Z8loopTaskPv+0xc): undefined reference to `loop()'
/home/robson/.platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: .pio/build/esp32doit-devkit-v1/libFrameworkArduino.a(main.cpp.o): in function `loopTask(void*)':
/home/robson/.platformio/packages/framework-arduinoespressif32/cores/esp32/main.cpp:42: undefined reference to `setup()'
/home/robson/.platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: /home/robson/.platformio/packages/framework-arduinoespressif32/cores/esp32/main.cpp:48: undefined reference to `loop()'
collect2: error: ld returned 1 exit status
*** [.pio/build/esp32doit-devkit-v1/firmware.elf] Error 1
Building stage has failed, see errors above. Use `pio test --verbose` option to enable verbose output.

someone can help me ? :worried:

Thanks

Did you use GoogleTest before? Please read updated docs GoogleTest — PlatformIO latest documentation

@ivankravets thanks for the answer !

No! I followed this documentation in the first unit tests that It is worked well

when I upgraded de pio core, the tests broke, this is the main reason that I opened this topic.

I hope you re-read that guide to the end implemented setup/loop as described in the guide?

yes, I implemented !

this is my code:

void test_number_to_hex_left_pad_with_zeros_bytes(void){
    TEST_ASSERT_EQUAL_STRING("000000000f97", numberToHex(3991, 6).c_str());
    TEST_ASSERT_EQUAL_STRING("0053d1ac1000", numberToHex(360000000000, 6).c_str());
    TEST_ASSERT_EQUAL_STRING("20bde7364000", numberToHex(36000000000000, 6).c_str());
}


void test_hex_to_int_array(void){
    int expected_1[6] = {0, 0, 0, 0, 15, 151};
    int expected_2[6] = {0, 83, 209, 172, 16, 0};
    int expected_3[6] = {32, 189, 231, 54, 64, 0};
    TEST_ASSERT_EQUAL_INT_ARRAY(expected_1, hexToIntArray("000000000f97"), 6);
    TEST_ASSERT_EQUAL_INT_ARRAY(expected_2, hexToIntArray("0053d1ac1000"), 6);
    TEST_ASSERT_EQUAL_INT_ARRAY(expected_3, hexToIntArray("20bde7364000"), 6);
}

void test_crc16(void){
    //TEST_ASSERT_EQUAL_STRING("D550", crc16("AA0501")); FIXME: pio test broke after update update pio core to 6.1
}


void setup(){
    UNITY_BEGIN();
}

void loop(){
    RUN_TEST(test_number_to_hex_left_pad_with_zeros_bytes);
    RUN_TEST(test_hex_to_int_array);
    RUN_TEST(test_crc16);
    UNITY_END();
}

but, the problem is not in my test, you can seen in the message error that is not about my test.

https://docs.platformio.org/en/latest/advanced/unit-testing/structure.html#shared-code

Could you share your platformio.ini?

of course !

[env:esp32doit-devkit-v1]
platform = espressif32
board = esp32doit-devkit-v1
framework = arduino
lib_deps =
	thomasfredericks/Bounce2@^2.55.0
	pfeerick/elapsedMillis@^1.0.6
	robtillaart/CRC@^0.3.0

Guys, crazy hard to help you if you don’t want to read the docs. Please provide a simple project to reproduce this issue and share it somewhere (Github, Google Drive, etc.).

If you follow by documentation, everything should work, there are a ton of tests: integration + unit tests. See also examples platformio-examples/unit-testing at develop · platformio/platformio-examples · GitHub

Where this file is located? What is the full path? How do you run tests? Do you use the pio test command?

this is the structure of my project:
image

yes, run the pio test

with pio core 5.2.X the tests runned ok

ok ! thanks for your attention !

https://docs.platformio.org/en/latest/advanced/unit-testing/structure.html#test-hierarchy

Screen Shot 2022-05-20 at 20.23.20

That was the historical bug in PIO Core 5 which handled grouped tests as a single test. We refactored Unit Testing in PlatformIO Core 6.0 andit is possible to use grouped test suites.

Sorry for the issue. We updated the migration guide. Hope it is clear now. See my comment

this is my case… thank you !

1 Like

Sorry, again. Does it work now?