This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nRF52 unit testing

Dear,

is anyone of the Nordic customers here using unit testing in their nRF52 project and would be willing to share an example project/their setup? Would be awesome.

Many thanks, Josef

Parents
  • I am using CppUTest for writing tests to my code. To do this I have to mock some functions, especially the Softdevice calls. There is a parameter for this: SVCALL_AS_NORMAL_FUNCTION.

    If defined, it allows me to write my own mocks for the code using these calls. Right now some of my mocks look like this:

    // Mocks:
    extern "C"
    {
    
      uint32_t sd_ble_gatts_hvx(uint16_t conn_handle, ble_gatts_hvx_params_t const * const p_hvx_params)
      {
         return NRF_SUCCESS;
      }
    
    
    uint32_t sd_flash_page_erase(uint32_t page_number)
    {
       return NRF_SUCCESS;
    }
      uint32_t sd_flash_write(uint32_t *p_dst, uint32_t const *p_src, uint32_t size)
    {
       return NRF_SUCCESS;
    }
      uint32_t sd_evt_get(uint32_t *p_evt_id)
    {
       return NRF_SUCCESS;
    }
    
     uint32_t sd_ble_evt_get(uint8_t * 	p_dest,
    		   uint16_t * 	p_len )
    {
       return NRF_SUCCESS;
    }
    }
    
Reply
  • I am using CppUTest for writing tests to my code. To do this I have to mock some functions, especially the Softdevice calls. There is a parameter for this: SVCALL_AS_NORMAL_FUNCTION.

    If defined, it allows me to write my own mocks for the code using these calls. Right now some of my mocks look like this:

    // Mocks:
    extern "C"
    {
    
      uint32_t sd_ble_gatts_hvx(uint16_t conn_handle, ble_gatts_hvx_params_t const * const p_hvx_params)
      {
         return NRF_SUCCESS;
      }
    
    
    uint32_t sd_flash_page_erase(uint32_t page_number)
    {
       return NRF_SUCCESS;
    }
      uint32_t sd_flash_write(uint32_t *p_dst, uint32_t const *p_src, uint32_t size)
    {
       return NRF_SUCCESS;
    }
      uint32_t sd_evt_get(uint32_t *p_evt_id)
    {
       return NRF_SUCCESS;
    }
    
     uint32_t sd_ble_evt_get(uint8_t * 	p_dest,
    		   uint16_t * 	p_len )
    {
       return NRF_SUCCESS;
    }
    }
    
Children
No Data
Related