TinyEmbeddedTest.h not found

Sysprogs forums Forums VisualGDB TinyEmbeddedTest.h not found

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #26326
    Jose Cazarin
    Participant

    Hello!

    I’m following this tutorial to set up some unit tests in my embedded project. But when I create the project, it just can’t find the TinyEmbeddedTest.h header. And it is indeed not present inside the folder of the created project. Could I be missing some packages?

    I’m using VS 2019 with VisualGDB 5.4R12 (build 3309) on a Windows 10 Pro machine

    Thanks for your support!

     

    #26327
    support
    Keymaster

    Hi,

    No problem, we can help you get it to work. We have quickly retested the configuration shown in the tutorial and could not reproduce the problem.

    Please double-check the following:

    1. Check whether the problem affects both build and IntelliSense, or IntelliSense only (i.e. if build succeeds).
    2. If the problem affects the build, double-check that the stm32.props file should contain the $(TESTFW_BASE)/com.sysprogs.unittest.tinyembtest text in the AdditionalIncludeDirectories element.
    3. If the text is present, check if the %LOCALAPPDATA%\VisualGDB\TestFrameworks\com.sysprogs.unittest.tinyembtest directory contains the TinyEmbeddedTest.h file. If not, please try re-downloading the test framework via Tools->VisualGDB->Manage VisualGDB Packages.

    If nothing helps, please try archiving your project (ensure you remove the temporary files) and attaching it here and we can check what is going on.

    #26331
    Jose Cazarin
    Participant

    The problem was really affecting the build.

    Thanks for the answer. So, actually I’m using an NRF microcontroller. But I was able to find the headers, and I just included the path to them in the “Include Directories” field in the “VisualGDB Project Properties” and now they are found! But I think it should work out of the box.

    But looks like the project wasn’t finding the .c files. So, I added the whole
    <h5>”%LOCALAPPDATA%\VisualGDB\TestFrameworks\com.sysprogs.unittest.tinyembtest“</h5>
    folder to my project. And now the problem is:
    <h5>\Local\VisualGDB\TestFrameworks\com.sysprogs.unittest.tinyembtest\SysprogsTestHooks.cpp(87,5): error : ‘pthread_mutex_t’ does not name a type; did you mean ‘pthread_atfork’?
    1> pthread_mutex_t m_Mutex;</h5>
    Looks like it’s not finding the pthread-related files. I even added the <pthread.h> header to the SysprogsTestHooks.cpp file (and the it is being found), but still got the same problem.

    Can you help me with this? Maybe it is something related to Windows since pthread.h is Unix-related

     

    Thanks!

     

     

    #26332
    support
    Keymaster

    It still looks like the embedded framework parameters (namely the SYSPROGS_TEST_PLATFORM_EMBEDDED macro) did not get applied to the project. Unfortunately, it’s hard to say what is causing it without knowing either all the choices you make in the wizard, or seeing the project generated by it (specifically .vcxproj, .mak, .props, .xml and .vgdbsettings files).

    #26333
    Jose Cazarin
    Participant

    Ok, I attached the project for you to take a look

    Kind regards!

    Attachments:
    You must be logged in to view attached files.
    #26336
    support
    Keymaster

    Thanks, it looks like the project was indeed missing the test framework-specific directories and macros (specifically, the nrf5x.props file must contain the SYSPROGS_TEST_PLATFORM_EMBEDDED string).

    We have tried regenerating the test-related properties by opening VisualGDB Project Properties -> Unit Tests, unchecking and checking the “This project contains unit tests” checkbox and clicking “Apply” and VisualGDB successfully inserted them in the .props file (see attachment).

    If it doesn’t work on your side, most likely some global setting on your computer is preventing VisualGDB from saving the test framework settings to the .props file. If this is the case, please try opening View->Other Windows->VisualGDB Diagnostics Console and then create a new test project from scratch. If the problem persists, please share the entire diagnostic output produced by VisualGDB and we will help you get everything to work automatically.

    Attachments:
    You must be logged in to view attached files.
    #26338
    Jose Cazarin
    Participant

    I don’t have the submenu “Unit Tests” on my “VisualGDB Project Properties” windows. See SS attached. Should it be there?

    When I put the nrf5x.props file that you attached in my project it builds fine!

    But the Test Explorer is not finding any tests, it just outputs “No tests found to run.”

    At least the example tests in the $(ProjectName)Tests should have run right?

     

     

     

    Attachments:
    You must be logged in to view attached files.
    #26340
    support
    Keymaster

    Thanks, this makes sense. It looks like you are using a VisualGDB edition that doesn’t support unit tests (Unit Tests, Profiling and other advanced features are supported starting from the Custom edition per our feature matrix). Most likely, you have created the initial project during the trial (that included the features from all editions) and then once you purchased an edition that does not support unit tests,  the related functionality was disabled.

    You can always upgrade your key using the following page: https://sysprogs.com/splm/mykey. If you have purchased it recently, the upgrade price will be just the price difference between the editions.

    #26341
    Jose Cazarin
    Participant

    Right, now I realized that I got the Embedded version, thats why I was having problems. Thanks for you help

    #26365
    Jose Cazarin
    Participant

    I’ve upgraded to the custom edition of the  VisualGDB

    What’s the best approach to adding unit tests to an existing project?

    What I tried: opening the VisualGDB properties of my current project and checking the box “this project contains unit tests based on” and selecting TinyEmbedded on the “Unit Tests” tab

    But when I do this, my project doesn’t compile anymore, it throws an error saying that it can’t find the SysprogsProfilerInterface.h header being included by the SysprogsTestHooks.cpp file

    But this file is present in the C:\Users\user\AppData\Local\VisualGDB\EmbeddedEFPs\Profiler folder

    I’ve tried to add the path to it manually  in the Include Directories but after this the error is

    Error undefined reference to `SysprogsProfiler_WriteData’

    Looks like something is still missing in the configuration

    #26394
    support
    Keymaster

    Hi,

    Sorry, the embedded test frameworks also require the profiler/semihosting framework, that needs to be enabled separately via VisualGDB Project Properties -> Embedded Frameworks.

    Generally, we would advise creating a new test project from the wizard. Now that you have the Custom edition, it should work out-of-the-box, referencing the necessary libraries generating the necessary initialization code.

    Once you can confirm that testing a newly created project works, please try referencing both the profiler framework and the unit test framework from the existing project and then ensure its main() function looks similar to the main() function of the generated test project.

    #26395
    Jose Cazarin
    Participant

    Yes, I can create a test project that works out of the box.

    I fixed the compilation errors by adding all the folders inside the C:\Users\user\AppData\Local\VisualGDB\EmbeddedEFPs\Profiler folder, had to tweak them a bit, add some includes, and then it compiled

    Then, I saw your last post, rolled back all these changes and just enabled the profiler/semihosting and checked the box that says “this project contains unit tests” and it compiled!

    Then, I created a simple test file with some dummy test cases, and it worked!

    Just a quick question, is there any way to select which main function is running? Because I need to 2 mains, the one where my application really is and the one to run the tests.

    I’m commenting out the real main to be able to run the tests, it’s a band-aid fix but I’m wondering  if there’s a better way to do that

    Thank you so much for your help so far!

    #26404
    support
    Keymaster

    Sorry for the delay. We have done some experiments and added a target API that allows distinguishing between the regular debug sessions (launched via Debug->Start Debugging) and test run/debug sessions launched via Test Explorer.

    Please try the following build: VisualGDB-5.5.2.3357.msi

    Please also update the Semihosting/Profiler and TinyEmbeddedTest frameworks via Tools->VisualGDB->Manage VisualGDB Packages after installing the new build.

    Then try creating a new TinyEmbeddedTest project and see how RunAllTests() is now called conditionally:

    if (IsRunningUnitTests())
        RunAllTests();

    You can use the IsRunningUnitTests() call in your code to switch between running the main application logic and passing control to the test framework.

    If you would like to remove the tests from the final binary, please consider creating a separate configuration (e.g. Debug + Tests), defining a macro (e.g. INCLUDE_UNIT_TESTS) via VS Project Properties and checking for it in your code.

    Hope this helps. Let us know if you have any further questions or suggestions.

Viewing 13 posts - 1 through 13 (of 13 total)
  • You must be logged in to reply to this topic.