]> 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:12 +0000 (14:52 +0000)
commitb33acc8f861119371619cd3d4ae7dab4a9ac889d
tree61f15b90ee9bef5c83d6934e709251f651ca3848
parent0b30f546bac549fae8cc0c7c3ea2fb433d29d3e5
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