2

nRF52 unit testing

joe.ker gravatar image

asked 2017-04-20 11:08:34 +0100

updated 2017-04-20 11:08:50 +0100

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

edit retag flag offensive close delete report spam

3 answers

Sort by ยป oldest newest most voted
2
gnfrnd gravatar image

answered 2017-05-19 15:16:52 +0100

updated 2017-05-19 15:20:59 +0100

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;
}
}
edit flag offensive delete publish link more
1
jacob gravatar image

answered 2017-04-20 11:42:13 +0100

I have two kind of tests:

  1. Linux host connected to nRF52 using UART, controlling the nRF52 and running Bluez locally to connect over BLE. Everything implemented in Python and the unittest framework.

  2. Mac host connected to nRF52 using UART, controlling the nRF52 and running CoreBluetooth locally to connect over BLE. Testrunner implemented in Python and the unittest framework, CoreBluetooth stuff implemented in objective-c (but controlled by the Python code).

The nRF52 in this case will be part of a bigger system, and in that system, it will be connected over UART. The protocol used for testing is the same as the one used in the real product. It is a custom simple messaging protocol.

edit flag offensive delete publish link more
1
MatthewLai gravatar image

answered 2017-04-20 15:29:43 +0100

Or you can try Segger RTT. If I understand RTT correctly one can use it for both reading user input and generating output. That also implies one needs to have a Jlink along the chain...

edit flag offensive delete publish link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer. Do not ask a new question or reply to an answer here.

[hide preview]

Question Tools

1 follower

Stats

Asked: 2017-04-20 11:08:34 +0100

Seen: 245 times

Last updated: mai 19