Hi,
I have setup Unity testing framework into Keil uvision 5 with code generated by STM32CubeMx, testing is working fine for one file at a time, but when I try to run more than one test file I am facing the following issue.
Error: L6200E: Symbol setUp multiply defined (by tim10_11_led1_2__unity_1\testmain.o and tim10_11_led1_2__unity_1\testgpio.o).
Error: L6200E: Symbol tearDown multiply defined (by tim10_11_led1_2__unity_1\testmain.o and tim10_11_led1_2__unity_1\testgpio.o)
As you can see, using setUp and tearDown methods in 2 test files invoke this error. Note: I am not defining them in header files, just using them in test sources.
My request is to find a compiler flag or linker flag I can add to the configuration so that Keil wont complain about these methods. They are needed in every test file. and I need to run multiple test files in one run.
Enviroment info:
IDE-Version: µVision V5.24.2.0 Copyright (C) 2017 ARM Ltd and ARM Germany GmbH. All rights reserved.
Tool Version Numbers: Toolchain: MDK-ARM Professional Version: 5.24.1 Toolchain Path: C:\Keil_v5\ARM\ARMCC\Bin C Compiler: Armcc.exe V5.06 update 5 (build 528) Assembler: Armasm.exe V5.06 update 5 (build 528) Linker/Locator: ArmLink.exe V5.06 update 5 (build 528) Library Manager: ArmAr.exe V5.06 update 5 (build 528) Hex Converter: FromElf.exe V5.06 update 5 (build 528) CPU DLL: SARMCM3.DLL V5.24.1 Dialog DLL: DCM.DLL V1.16.0.0
Dialog DLL: TCM.DLL V1.32.0.0
Test file example:
/** ****************************************************************************** * File Name : Testgpio.c * Description : GPIO module Tester ****************************************************************************** ** COPYRIGHT(c) 2017 Eslam El-Sherbieny * * Summary: Testing GPIO module methods * * * ****************************************************************************** */ #include "unity.h" #include "gpio.h" uint16_t LED_ORed; GPIO_InitTypeDef GPIO_InitStruct; /* Test Setup */ void setUp(void){ /* GPIO Ports Clock Enable */ __HAL_RCC_GPIOB_CLK_ENABLE(); /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(GPIOB, LED_1_Pin|LED3_Pin|LED2_Pin, GPIO_PIN_RESET); LED_ORed = LED_1_Pin|LED2_Pin|LED3_Pin; } /* Test Teardown */ void tearDown(void){ } /** * Test: test_MX_GPIO_Init * Target method: MX_GPIO_Init * Parent method: * * @brief GPIO Initialization * * @param GPIO_InitStruct GPIO structure * @param GPIO_InitStruct.Pin GPIO Pin variable * @param LED_ORed The value or ORing the 3 LEDs */ void test_MX_GPIO_Init(void){ TEST_ASSERT_EQUAL_UINT32(GPIO_InitStruct.Pin, LED_ORed); }
If you want a symbol local to a file "static" would be one route, perhaps you'd do better finding a way of not duplicating names within the namespace.
I tried adding static, Error is gone but since this is a predefined method used by Unity core, I got an error Undefined symbol SetUp and tearDown referred from Unity.o