[asterisk-dev] [Code Review] Unit Test Framework
Russell Bryant
russell at digium.com
Wed Dec 16 17:02:04 CST 2009
> On 2009-12-15 18:56:41, Russell Bryant wrote:
> > /trunk/include/asterisk/test.h, lines 140-173
> > <https://reviewboard.asterisk.org/r/447/diff/1/?file=7560#file7560line140>
> >
> > Do we expect these to be used anywhere else other than the CLI functions? If not, there is no reason to make them public API calls.
> >
> > We can always make them public API calls later if needed.
>
> David Vossel wrote:
> This was written with the assumption that the CLI may not be the only interface using this api in the future. I have no plans at the moment to use them anywhere else though. Does it hurt anything to keep them exposed?
The only potential downside to leaving it is that technically at that point, you have published an API and changing it is subject to the same scrutiny we would put on changing any other API call. If it's internal to the core part, you can change it all you want.
> On 2009-12-15 18:56:41, Russell Bryant wrote:
> > /trunk/main/test.c, lines 714-724
> > <https://reviewboard.asterisk.org/r/447/diff/1/?file=7562#file7562line714>
> >
> > Since ast_test_init() is outside of your ifdef block, Asterisk will fail to link if you disabled TEST_FRAMEWORK.
>
> David Vossel wrote:
> not at the moment. ast_test_init() is wrapped in a #ifdef TEST_FRAMEWORK block in asterisk.c.
Ah, fair enough.
> On 2009-12-15 18:56:41, Russell Bryant wrote:
> > /trunk/tests/test_heap.c, lines 77-79
> > <https://reviewboard.asterisk.org/r/447/diff/1/?file=7563#file7563line77>
> >
> > Do you think it would be useful to pass the CLI fd down to test functions to give them the ability to provide status output as tests execute?
>
> David Vossel wrote:
> I like this idea, but if this is done we are limiting the test framework to use the CLI. Is this something we want to do?
Good point. Here's another way to approach it. You could define a function called ast_test_status() that allows a test function to print status output to "somewhere".
To accomplish this, you could pass an opaque type as an argument to test handlers that would be passed up to ast_test_status(). Internally, that opaque type could include the data needed for printing out to the CLI, or whatever else you need in the future.
- Russell
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviewboard.asterisk.org/r/447/#review1301
-----------------------------------------------------------
On 2009-12-15 18:15:17, David Vossel wrote:
>
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviewboard.asterisk.org/r/447/
> -----------------------------------------------------------
>
> (Updated 2009-12-15 18:15:17)
>
>
> Review request for Asterisk Developers and Russell Bryant.
>
>
> Summary
> -------
>
> The Unit Test Framework is a new API that manages registration and execution of unit tests in Asterisk with the purpose of verifying the operation of C functions.
>
> The Framework consists of a single test manager accompanied by a list of registered test functions defined within the code. A test is defined, registered, and unregistered from the framework using a set of macros which allow the test code to only be compiled within asterisk when the TEST_FRAMEWORK flag is enabled in menuselect. This allows the test code to exist in the same file as the C functions it intends to verify. Registered tests may be viewed and executed via a set of new CLI commands. CLI commands are also present for generating and exporting test results into xml and txt formats.
>
> For more information and use cases please refer to the documentation provided at the beginning of the test.h file.
>
>
> Diffs
> -----
>
> /trunk/build_tools/cflags-devmode.xml 235225
> /trunk/include/asterisk/test.h PRE-CREATION
> /trunk/main/asterisk.c 235225
> /trunk/main/test.c PRE-CREATION
> /trunk/tests/test_heap.c 235225
>
> Diff: https://reviewboard.asterisk.org/r/447/diff
>
>
> Testing
> -------
>
> test_heap.c has been modified to take advantage of the Test Framework. I have executed and generated reports for these tests.
>
>
> Thanks,
>
> David
>
>
More information about the asterisk-dev
mailing list