Files
vystem/docs/shelter/kernel/testutils.md
2026-03-31 22:15:00 +02:00

1.9 KiB

Tests utilities

Introduction

To support the test-and-benchmark framework, the Shelter kernel include a common base of utilities that provide to all tests a basic way to store and expose their results. This file only cover the basic utilities usable by all tests, not the detail and typical results of each test. These utilities are defined inside shelter/lib/include/kernel/tests/test_utils.h and implemented inside shelter/lib/src/kernel/tests/test_utils.c.

Overview

The test-and-benchmark (TAB) framework is responsible for testing differents subsystems to ensure their stability and performances over differents devices. But it also provides a common base for showing results and others little things.

Firsty, it define internally a buffer of 10000 sh_tsc_TSC_VALUE for storing cycles count and compute statistics. The pointer to this buffer is obtainable through the sh_tsc_TSC_VALUE* sh_test_get_tsc_values_buffer_ptr() function.

Then, the TAB framework also define the void sh_test_load_iterations_count(sh_uint64 iterations_num) function. This function load the iterations count defined by the bench_iterations boot configuration key. Some tests doesn't support this feature, so this function will only set iterations count for tests that support custom iterations count.

Finally, each test uses the SH_STATUS sh_test_compute_print_stats(char* benchname,sh_tsc_TSC_VALUE *tsc_value_array,sh_uint64 array_size) function. This function will compute various statistics and print them like this:

Result for benchmark "<benchmark name>" :
Min: <min time> | Med: <median time> | Avg: <average time> | Max: <max time> | Total : <total time> (TSC)
[P00-P90] <min time>-P90 : [##################--] 90%
[P90-P99] P90-P99 : [#-------------------] 9%
[P99-Max] P99-<max time> : [--------------------] 1%

Here, PXX where XX is a percentage mean a percentile.