PlatformIO Community

Pio test compile issues

Hi ,
I’m trying to run a simple pio test script and it gives the following error ,

Capture

my .ini is ;

[env:nucleo_f767zi]
platform = ststm32
board = nucleo_f767zi
framework = arduino
upload_protocol = serial
test_transport = custom

the test script :

#ifndef UNITTEST_TRANSPORT_H
#define UNITTEST_TRANSPORT_H
#include <Arduino.h>
#define TESTING_SERIAL Serial1

HardwareSerial Serial1(USART3);

void unittest_uart_begin() {
     /* default test_speed value */
    TESTING_SERIAL.begin(115200);
}

void unittest_uart_putchar(char c) {
       TESTING_SERIAL.print(c);
        }

void unittest_uart_flush() {
        TESTING_SERIAL.flush();
    }

void unittest_uart_end() {
}
   #endif

This script is under test path saved as unittest_transport.h

Appreciate if someone can help me find the issue .

Thanks,
Samson.

PlatformIO core 6.0 has major changes to unit testing. It looks like it did not find setup() and loop() for your test unit becuase you did not name the folder inside test/ which holds the code with setup() and loop() correct – it must begin with test_ to be recognized as a test unit.

There may also be changes needed for your custom test transport.

See Error platformio - #9 by maxgerhardt and official documentation.

1 Like

This option is deprecated. Please remove it. You need Custom unity_config.h. See example platformio-examples/unit-testing/stm32cube/test at develop · platformio/platformio-examples · GitHub

Thank you so much @ maxgerhard,@ ivankravets for your support.

Hi @maxgerhardt ,

The tester ran successfully, but didn’t output any results .According to @ivankravets about migrating to unity_config.h is there an example for Arduino platform ?

Currently my test folder path is :
image

Which unittest_transport.h has the serial configuration to display the output as below ;

#ifndef UNITTEST_TRANSPORT_H
#define UNITTEST_TRANSPORT_H
#include <Arduino.h>
#define TESTING_SERIAL Serial1

HardwareSerial Serial1(UART4);

void unittest_uart_begin() {
     /* default test_speed value */

   TESTING_SERIAL.setRx(PC11);
   TESTING_SERIAL.setTx(PC10);
   TESTING_SERIAL.begin(115200);
}

void unittest_uart_putchar(char c) {
       TESTING_SERIAL.print(c);
        }

void unittest_uart_flush() {
        TESTING_SERIAL.flush();
    }

void unittest_uart_end() {
}
   #endif

Do i have to rename unittest_transport.h. to unity_config.h ? I’m confused how how to create a custom unity_config.h based on unittest_transport.h.
Appreciate for your help.

Thanks,
Samson.

Remove unittest_transport.h and create unity_config.h as described in the docs.

@ivankravets thank you ,I will give it a try ,cheers .

Please confirm that it works for you now.

Hi @ivankravets ,

I renamed the same header file which we used before that is unittest_transport.h to unity_config.h as per the document do I have to replace the following functions as well ?

void unittest_uart_begin(); → void unityOutputStart();
void unittest_uart_putchar(char c); → void unityOutputChar(c);
void unittest_uart_flush(); → void unityOutputFlush();
void unittest_uart_end(); → void unityOutputComplete();

Anyhow it still gives the following error ,
image

Any thoughts?

Thank you ,
Samson.

Hardware Serial1 is already declared in the Arduino framework. Just use it.

@ivankravets ,@maxgerhardt I was using the unit test to test ATECC crypto chip and to display the public key .I work fine until core updated to 6.0 .As per your advice I re-named the my folder to start with test_ since it game an error about not finding setup() ,main() .The tester works fine ,but not printing the public key via serial now .
As per @ivankravets i renamed the older header (unittest_transport.h) to unity_config.h
and did the changes as below ,

#ifndef UNITY_CONFIG_H
#define UNITY_CONFIG_H
#include <Arduino.h>

void unityOutputStart()
{
  Serial.begin(115200);
}

void unityOutputChar(char c)
{
  Serial.print(c);
}

void unityOutputFlush()
{
  Serial.flush();
}

void unityOutputComplete()
{
}
#endif /* UNITY_CONFIG_H */

and it still gives the following error,
image

Not sure what else to do in order to get the values printed .

My .cpp file is

#include <Arduino.h>
#include <unity.h>
#include <ArduinoECCX08.h>
#include <utility/ECCX08JWS.h>
#include <utility/ECCX08DefaultTLSConfig.h>

ECCX08Class ECCX08(Wire2, 0x60);

void test_provision()
{

  TEST_ASSERT_MESSAGE(ECCX08.begin(), "ATECC608 not present");

  bool wasLocked = ECCX08.locked();

  if (!wasLocked) {

    TEST_ASSERT_MESSAGE(ECCX08.writeConfiguration(ECCX08_DEFAULT_TLS_CONFIG), "Failed to write config");
    TEST_ASSERT_MESSAGE(ECCX08.lock(), "Failed to lock ATECC608");
  }

  String publicKeyPem = ECCX08JWS.publicKey(0, !wasLocked);
TEST_MESSAGE(publicKeyPem.c_str());
}

void setup()
{
  delay(2000);
  UNITY_BEGIN();
  RUN_TEST(test_provision);
  UNITY_END();
}

void loop()
{
}
 

Appreciate your help .

Thanks,
Samson.

Implementation should be done in unity_config.cpp. See project example platformio-examples/unit-testing/stm32cube at develop · platformio/platformio-examples · GitHub