]> git.ipfire.org Git - thirdparty/asterisk.git/commit
Add ability to pass arguments to unit tests from the CLI
authorGeorge Joseph <gjoseph@sangoma.com>
Fri, 27 Dec 2024 15:19:08 +0000 (08:19 -0700)
committerAsterisk Development Team <asteriskteam@digium.com>
Thu, 23 Jan 2025 18:39:41 +0000 (18:39 +0000)
commit22108f46ee8bfe5d2fa3766b289089ecabc31077
treed5f028467c8c316f8b6995c000b7497173a7a7ec
parentcde6bcf66cd6d999b293c19fd08675f9fdf0f128
Add ability to pass arguments to unit tests from the CLI

Unit tests can now be passed custom arguments from the command
line.  For example, the following command would run the "mytest" test
in the "/main/mycat" category with the option "myoption=54"

`CLI> test execute category /main/mycat name mytest options myoption=54`

You can also pass options to an entire category...

`CLI> test execute category /main/mycat options myoption=54`

Basically, everything after the "options" keyword is passed verbatim to
the test which must decide what to do with it.

* A new API ast_test_get_cli_args() was created to give the tests access to
the cli_args->argc and cli_args->argv elements.

* Although not needed for the option processing, a new macro
ast_test_validate_cleanup_custom() was added to test.h that allows you
to specify a custom error message instead of just "Condition failed".

* The test_skel.c was updated to demonstrate parsing options and the use
of the ast_test_validate_cleanup_custom() macro.

(cherry picked from commit 6d63b628534178c929a3736ea316654cf6e60849)
include/asterisk/test.h
main/test.c
tests/test_skel.c