Test SDK Integration with Self Test
To help with integration, the SDK has an optional Self Test component. The self test is a quick and easy way to test that various components of your integration with the Memfault SDK are functioning as expected.
The Self Test component contains the following tests:
- Device Info
- Component Boot
- Coredump Region
- Data Export
- Reboot Reason
- Time
- Coredump Storage Capacity
- Coredump Storage Operation
Component Dependencies
We recommend running the test via a CLI command. This can be integrated through
your device's existing shell/console or by using the
Demo CLI component of the SDK. If this is not available,
you can call the self test directly with memfault_self_test_run()
passing the
desired test flags. See
include/memfault/self_test.h
for more details.
Optional Platform Dependencies
To successfully run all of the tests within the Self Test, there are a few functions that need to be implemented for your platform. If these functions are not implemented, these tests will fail.
Time Test Requirements
memfault_self_test_platform_delay_ms()
: A function to delay the CPU by the specified number of milliseconds.
Coredump Storage Test Requirements
memfault_self_test_platform_disable_irqs()
: A function to disable any interrupts from peripherals or an RTOS.memfault_self_test_platform_enable_irqs()
: A function to enable interrupts from peripherals or an RTOS.
For more info on these functions, check out
include/memfault/self_test.h
Enabling The Self Test Component
First we'll need to enable the component so it is built with our application.
- Zephyr
- ESP-IDF
- Demo CLI
- Set
CONFIG_MEMFAULT_SHELL_SELF_TEST=y
in yourprj.conf
file. - Rebuild your application with
west build
- Set
CONFIG_MEMFAULT_CLI_SELF_TEST=y
in yoursdkconfig.default
file. - Clean your generated
sdkconfig
, and rebuild withidf.py build
- Add
#define MEMFAULT_DEMO_CLI_SELF_TEST 1
to yourmemfault_platform_config.h
file. - Rebuild your application.
Running The Self Test
The Self Test has 3 modes of operation controlled by the arguments passed to the command. These modes are:
- Default Mode: Running the command with no arguments
- Reboot Reason Mode: Running the command with
reboot
andreboot_verify
- Coredump Storage Mode: Running the command with
coredump_storage
Default Mode
The default mode is used when running the Self Test without any additional arguments. This mode will run the following tests:
- Device Info
- Component Boot
- Data Export
- Time
- Coredump Region
- Coredump Storage Capacity
- Zephyr
- ESP-IDF
- Demo CLI
- Run the command
mflt test self
.
- Run the command
memfault_self_test
.
- Run the command
self_test
.
Check the output from each of the tests for the results. For more info on each test, see their respective sections below.
Device Info Test
This test validates the info returned by your implementation of
memfault_platform_get_device_info()
. The test performs these checks:
- Build ID validation
- NULL field checks
- Field value validation
If there are any problems, the test will show a failure and where it occurred.