Getting an error when using Ztest+Twister on nrf5340dk

Hello, 

I am trying to use twister + ztest to run some basic tests on my device custom project and nrf5340

Here are the contents. 
Current Directory Structure

sensor app
|
|----   tests/
|       |------ src/
|               | --- main.c
|       | ----- CMakeLists.txt
|       | ----- prj.conf
|       | ----- testcase.yaml
|       | ----- map.yml


Contents of map.yml

- connected: true
  id: 000051000169 #this is the Serial Number of the JLINK debugger unit. 
  platform: nrf5340dk/nrf5340/cpuapp
  product: J-Link
  runner: nrfjprog
  serial: COM11


Contents of testcase.yaml

tests:
  sensor_app.sensor_app_tests:
    tags: sensor app unit test
    platform_allow: 
      - nrf5340dk/nrf5340/cpuapp
    integration_platforms:
      - nrf5340dk/nrf5340/cpuapp
    harness: console
    harness_config:
      type: multi_line
      regex:
        - "Running test_basic_assertions"
        - "[00:00:00.001,159] <err> Flash_Task: Successfully configured"
    timeout: 600
    # tags: rtt
    extra_configs:
      - CONFIG_RTT_CONSOLE=y
      - CONFIG_USE_SEGGER_RTT=y


Contents of prj.conf

CONFIG_ZTEST=y

Contents of tests/src/main.c

/*
 * Simple Zephyr Test Framework Example
 */

#include "zephyr/ztest.h"
#include <zephyr/kernel.h>
#include <zephyr/logging/log.h>
/* Define the test suite */
ZTEST_SUITE(sensor_app_tests, NULL, NULL, NULL, NULL, NULL);

LOG_MODULE_REGISTER(main, LOG_LEVEL_DBG);
/* Test case 1: Basic assertions */
ZTEST(sensor_app_tests, test_basic_assertions)
{
    LOG_DBG("Running test_basic_assertions\n");
    
    zassert_true(1, "1 should be true");
    zassert_false(0, "0 should be false");
    zassert_equal(1, 1, "1 should equal 1");
    zassert_not_equal(1, 2, "1 should not equal 2");
    
    LOG_DBG("test_basic_assertions PASSED\n");
}


 
Used the configurator tool to modify the JLINK such that the VCOM is enabled and able to see JLINK enumerated in the Device Manager with COM11

twister commands used:

west twister --device-testing --hardware-map=map.yml -p nrf5340dk/nrf5340/cpuapp --west-flash="--recover" -T .\sensor_app\tests\ -vv


Error:
DEBUG - sensor_app.sensor_app_tests.basic_assertions: No status
DEBUG - sensor_app.sensor_app_tests.basic_assertions: No status

From the twister-out directory:

the twister_suite_report: shows untested, no results captured testsuite misconfiguration?

Objective is to run the ztests using twister runner on my customized project - sensor_app
Current connection:
Nrf5340dev kit board connected to laptop via J LINK Debugger. 

Able to do west build and flash + view the logs on the RTT viewer. 
But it fails when i use west twister command
Misc: Using Windows 11, with powershell to run all the above commands. 

Parents
  • Hi I will look into your case. 
    What SDK are you using? I did a quick test without using uart to to verify the rest and it worked without any issue. nrfjprog is deprecated and should not be used for newer SDKs
    I suspect there might be an issue with it not selecting the correct core when trying to sett up RTT. 

    Regards

    Runar 


Reply
  • Hi I will look into your case. 
    What SDK are you using? I did a quick test without using uart to to verify the rest and it worked without any issue. nrfjprog is deprecated and should not be used for newer SDKs
    I suspect there might be an issue with it not selecting the correct core when trying to sett up RTT. 

    Regards

    Runar 


Children
  • Hello

    Thanks for the response. 

    Currently using an older sdk 

    NCS SDK = 2.7.0

    Cant use the newer versions/latest version of SDK due to project related constraints. 

    I tried to remove the runner: nrfjprog but it throws an error : Device Flash Error when I try to run the twister command
     

    1) sensor_app.basic on nrf5340dk/nrf5340/cpuapp error (Device issue (Flash error?))


    west twister -p nrf5340dk/nrf5340/cpuapp --device-testing --hardware-map map.yaml -T  .\sensor_app\tests\ -vv



    Twister Output Snippet with runner=nrfjprog enabled:
    INFO    - The following issues were found (showing the top 10 items):
    INFO    - 1) sensor_app.basic on nrf5340dk/nrf5340/cpuapp failed (Timeout)
    INFO    -
    



    Additional inputs: Currently cannot use uart0 on the device as I am already using SPIM for another part. 
    I believe we can use only one peripheral at a time. 

    Only one of the following peripherals can be enabled: SPI0, SPIM0, SPIS0, TWI0, TWIM0, TWIS0,
    UARTE0

Related