]> 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)
committerGeorge Joseph <gjoseph@sangoma.com>
Thu, 2 Jan 2025 14:52:16 +0000 (14:52 +0000)
commit2fa9dcd51cb462da23daa753a9d9e373fa9fedcd
tree095c7306a172ac8139bd5b3ba427a165a20dbebe
parent21dba60ff2a0d29d1bef5da33b77c7c7392d7156
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.
include/asterisk/test.h
main/test.c
tests/test_skel.c