Error platformio

Hello, i have need help…
Impossible to launch the tests on my platformio project (m5stackcore2)
c:/users/home/.platformio/packages/toolchain-xtensa-esp32/bin/…/lib/gcc/xtensa-esp32-elf/8.4.0/…/…/…/…/xtensa-esp32-elf/bin/ld.exe: .pio\build\m5stack-core2\libFrameworkArduino.a(main.cpp.o):(.literal._Z8loopTaskPv+0x8): undefined reference to setup()' c:/users/home/.platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: .pio\build\m5stack-core2\libFrameworkArduino.a(main.cpp.o):(.literal._Z8loopTaskPv+0xc): undefined reference to loop()’
c:/users/home/.platformio/packages/toolchain-xtensa-esp32/bin/…/lib/gcc/xtensa-esp32-elf/8.4.0/…/…/…/…/xtensa-esp32-elf/bin/ld.exe: .pio\build\m5stack-core2\libFrameworkArduino.a(main.cpp.o): in function loopTask(void*)': C:/Users/Home/.platformio/packages/framework-arduinoespressif32/cores/esp32/main.cpp:42: undefined reference to setup()’
c:/users/home/.platformio/packages/toolchain-xtensa-esp32/bin/…/lib/gcc/xtensa-esp32-elf/8.4.0/…/…/…/…/xtensa-esp32-elf/bin/ld.exe: C:/Users/Home/.platformio/packages/framework-arduinoespressif32/cores/esp32/main.cpp:48: undefined reference to loop()' collect2.exe: error: ld returned 1 exit status *** [.pio\build\m5stack-core2\firmware.elf] Error 1 Building stage has failed, see errors above. Use pio test --verbose` option to enable verbose output.

I have already deleted /penv and /cache without success…

In which file have you implemented the setup() and loop() functions? It must be in a .cpp file in the src/ folder of the project…

What loop and configuration are you talking about? Because for normal loop and configuration it is in source but I want to do unit tests with test file.

If you want to run unit tests on the embedded device, you still need to implement setup() and loop() in a file in test/. Please see

1 Like

here is the tree structure of my test files. In the .cpp, there is a setup and a loop in test_lora.cpp.
df

When you use the first example and adapt its platformio.ini to use an ESP32 instead of an Uno, does it work? Just to get a working baseline.

i tryed to use the test “calculator” for my board and it work, here is the content of my test_lora.cpp file, do you have an idea of what’s wrong?

#include <M5Core2.h> //this also include Arduino.h
#include <unity.h>
#include "fonction_send_lora.h"
#include "fonction_gener_value.h"

void setup() {
    M5.begin();
    Serial.begin(9600);

    UNITY_BEGIN();
    RUN_TEST([](){
        TEST_ASSERT_EQUAL(lora::is_init, false);
    });

    lora::init();

    RUN_TEST([](){
        TEST_ASSERT_EQUAL(lora::is_init, true);
    });
}

void loop() {
    static int N= 0;
    navi::data_navi data;
    lora::Send_Message_Lorawan(data);
    
    Serial.println("ok");
    delay(100);
    N++;

    if(N> 100){UNITY_END();}
}

I think if you structure it like that, it does not compile any sources in test/ at all. PlatformIO expects you, per documentation, to put each logical unit test as a folder that starts with test_.

PlatformIO looks for the tests in the project test_dir. The only folder with a name prefixed by test_ is nominated for unit testing and should be an independent test/application with its own main() function (setup() / loop() for Arduino […]

None of your folders in test start with test_. Can you rename LoRaWan to test_lorawan?

1 Like

thank you very much it worked, platformio did all of my unit test correctly but i think platformio is a bit drunk because it tells me that some were skipped even tho they were all passed
arrr

Skipped should mean skipped. Do test_gen_value and test_Navi have their own .cpp file with a setup() and loop() inside them? Is there a test_fitler active in the platformio.ini?

yes they do have their own .cpp file with setup and loop and everything, and no there is not any filter in the .ini file nor in the command line

CC @ivankravets what could be the cause of skipped tests although no source filter is set in the platformio.ini?

1 Like

Please provide us with the contents of the platformio.ini file. Also, a new screenshot with the folder structure will help as well.