Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MBed tests do not print to serial #3342

Closed
1 task done
ivan1993br opened this issue Jan 15, 2020 · 3 comments
Closed
1 task done

MBed tests do not print to serial #3342

ivan1993br opened this issue Jan 15, 2020 · 3 comments

Comments

@ivan1993br
Copy link

What kind of issue is this?

  • PlatformIO Core.
    If you’ve found a bug, please provide an information below.

Configuration

Operating system:

PlatformIO, version 4.1.0

Description of problem

Tests does not output to serial port as expected on mbed os.

Steps to Reproduce

Create a embedded test with mbed os using the UNITY framework provided by platformio

Actual Results

The test compile and runs on the board but does not output anything on serial port

Expected Results

The test compile and runs on the board and output the results on the serial port

If problems with PlatformIO Build System:

The content of platformio.ini:

[env:disco_f407vg]
framework = mbed
platform = ststm32
board = disco_f407vg
build_flags = -DPIO_FRAMEWORK_MBED_RTOS_PRESENT -std=gnu++11
build_unflags = -std=gnu++98
test_transport = custom

Source file to reproduce issue:

#ifdef PIO_FRAMEWORK_MBED_RTOS_PRESENT
#include "mbed.h"
#endif

#include "unity.h"

void test_function_calculator_addition(void) {
  TEST_ASSERT_EQUAL(32, 32);
}

void test_function_calculator_subtraction(void) {
  TEST_ASSERT_EQUAL(20, 20);
}

void test_function_calculator_multiplication(void) {
  TEST_ASSERT_EQUAL(50, 50);
}

void test_function_calculator_division(void) {
  TEST_ASSERT_EQUAL(32, 32);
}

int main(int argc, char **argv) {
  #ifdef PIO_FRAMEWORK_MBED_RTOS_PRESENT
  wait(5);     // for ARM mbed framework
  #endif
  UNITY_BEGIN();
  RUN_TEST(test_function_calculator_addition);
  RUN_TEST(test_function_calculator_subtraction);
  RUN_TEST(test_function_calculator_multiplication);
  RUN_TEST(test_function_calculator_division);
  UNITY_END();
}

Additional info

I was able to fix this issue by creating a .mbedignore on the mbed folder for the unity framework (features/framework/unity).

When I include the unity.h file, the one that is included is from the mbed framework when I do not ignore it, so the modifications done by platformio to the macros variables that allow me to print to the serial port are not used.

@ivankravets ivankravets added this to the 4.1.1 milestone Jan 22, 2020
@ivankravets ivankravets removed this from the 4.1.1 milestone Jan 29, 2020
@ivan1993br
Copy link
Author

ivan1993br commented Feb 6, 2020

@ivankravets Do you have some idea on how you want to proceed to solve this issue? I mean, remove the unity from the mbed framework, or just remove when it is compiling the tests? - Do you think to add an option on the .json file?

@ivankravets
Copy link
Member

Duplicate of #3980

@pratiksurgeonslab98
Copy link

@ivan1993br
Referring to #3342

I was able to fix this issue by creating a .mbedignore on the mbed folder for the unity framework (features/framework/unity).
When I include the unity.h file, the one that is included is from the mbed framework when I do not ignore it, so the modifications done by platformio to the macros variables that allow me to print to the serial port are not used.

What was the content of your .mbedignore file and the directory in which it is kept?

for me the file content of .mbedignore is
unity/*

the .mbedignore is kept in both these directories
/home/roy/.platformio/packages/framework-mbed/features/.mbedignore
and
/home/roy/.platformio/packages/framework-mbed/features/frameworks/unity/.mbedignore

I am unable to print the test results after running pio test.
Please help.

Thanks in advance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants