C/C++ Unit Test runtime error (Keil, ARM, CMSIS)
Hello,
we used the QuickStart MDK-ARM unit test example and applied it to our project. We are using Keil uVision 5.26.2 with Parasoft C/C++ Test 10.4.1. The project builds in Keil and executes on the target without any issues. The Parasoft project (Keil uVision import using Batch File output) is setup for Static Analysis and this run without issues as well.
I have auto-generated unit test cases for various module (c-file). When I try to execute the test cases using the Keil uVision Tests - ULINKPRo or Simulator (ITM) configuration, I seem to get the follow error.
C/C++test analysis errors in 1. Test execution: error compiling file. "C:\\Keil_v5\\ARM\\PACK\\ARM\\CMSIS\\4.5.0\\CMSIS\\Include\core_cm3.h", line 128: Error: #35: #error directive: "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" ^ C:\Program Files\Parasoft\C++test\10.4\engine\runtime\src\transport\CppTestTransportITM.c: 0 warnings, 1 error
Our project uses the nRF52832 chipset and pretty sure __FPU_PRESENT
is set correctly. We get this error no matter what module is selected for execution.
Is there something I'm missing in the configuration in Keil uVision and/or Parasoft?
Thanks,
Comments
Hello,
FYI, I was able to do the following as a work around.
modified the CppTestTransportITM.c
line 38 from
#include "core_cm3.h"
to#include "core_cm4.h"
line 40
#if (__CM3_CMSIS_VERSION ...
to#if (__CM4_CMSIS_VERSION ...
Hello,
After the fix mentioned in my previous post, we tried to execute test cases on a module (single c-file, 5 units, 15 test cases total). It started Keil uVision and after a few seconds exited. Parasoft reports 0 (zero) cases executed.
We are also trying the file-scope approach - disabling the additional symbol sources option as below
1). Generate Unit Tests for the given module (c-file), works okay
2). Generate stubs (file-scope), work okay
3). Run Unit Tests - Keil uVision Tests - ULINKPRo or Simulator (ITM) (file-scope)
We get the following error
There are a lot of 3rd party libraries and SDK calls that we want to stub out, so the file-scope method would be ideal. Any suggestions?
Thanks,
sys_exit must be retargeted as does SystemInit (although I have never encountered that symbol before). Keil uVision will sometimes just decide to exit without invoking anything, it's very puzzling.
Hello,
Ah okay. So our guess is that since both SystemInit and _sys_exit are provided by the SDK (nrf52/Keil), and we are disabling additional symbols, there is no test harness getting associated for them. Wonder why no stubs?. As for re-targeting these, what's the best way without modifying the source under test, maybe some code we can add to the test bench itself? Or is there a way to disable additional symbols except these two symbols?
Thanks,
C++test provides the ability to generate a retargeting library. Check the manual. It will describe all the steps involved.
Hello,
Thanks for the information. We were able to generate the run-time re-target (cpp_rtget.c) and include a stubbed SystemInit (this looks like another custom SDK function). The re-target file already included a _sys_exit. The errors above went away but we are still not getting any test execution. Keil starts, it looks like it's trying to step through some disassembly then exits after a few seconds. 0 (zero) test cases executed.
Hello,
So, one thing we tried was to modify the memory area for since we don't need to reserve any memory for the MBR/Soft Device (nRF52832 specific) when we are Unit Testing. When running with this configuration, keil starts and gets stuck in the startup code at the __main symbol, not sure if something is causing a hard fault (also high-lighted with green marker). Have stop debugging to exit out. still no text execution. See attached screen shot of Keil.
Hi @sketkar ,
What is your current configuration for stack and heap?
Hello,
Both are set to 8192. __START_CONFIG, __STARTUP_CONFIG_STACK_SIZE __STACK_SIZE, __STARTUP_CONFIG_HEAP_SIZE and __HEAP_SIZE are **not** defined.
Here is the snippet from arm_startup_nrf52.s.
One question we have is do we need to rebuild the Parasoft runtime library specifically for the nRF52/Cortex M4 manually? We were unable to open the C++testRtLib_Keil.Uv2 in Keil uVision (5.26.2) and have made the assumption that the library would be built by C/C++ Test when we run the tests. See screenshot.
Thanks,
Hello,
stepping through the test execution in Keil uVision IDE, it looks like the test hits the HardFault interrupt (see snippet below)
in the
cpptest_testrunner.c
file, specific function isstatic void __CPTR_Do_Tests_TestSuite_main_c_a23b0b65(void)
and the specific macro called is CPPTEST_RUN_TEST_SUITE_BEGIN(TestSuite_main_c_a23b0b65, "/nrf52832_example/main.c", 4)unit under test is main.c - auto-generated unit tests with file-scope stubs and file-scope test execution (Run Keil uVision Test - Simulator). We have created custom runtime re-targeting library (cpptest_retgt.c) as mentioned in a previous post but we have not created any custom runtime initialization & finalization.
@sketkar - It will require a more thorough debugging session as this gets into low level details. I sense that those downstream errors could potentially be avoided given the proper setup upstream. I suggest opening a support case an CC your account manager for visibility.
@Andrey Madan - I have created a new support ticket in the customer portal. I appreciate your help.