[asterisk-dev] [Code Review] 3734: media formats: Add a 'none' format to prevent NULL format derefences; update unit tests

Corey Farrell reviewboard at asterisk.org
Fri Jul 11 12:16:51 CDT 2014



> On July 11, 2014, 2:43 a.m., Corey Farrell wrote:
> > /team/group/media_formats-reviewed-trunk/tests/test_core_format.c, lines 61-66
> > <https://reviewboard.asterisk.org/r/3734/diff/4/?file=62711#file62711line61>
> >
> >     Do we really want doxygen tags on unit tests?
> 
> Matt Jordan wrote:
>     Yes!
>     
>     (1) It's generally harmless.
>     (2) Tests can be just as complex as 'regular' code. In this particular case, I'm implementing a format attribute module inside the test; that probably warrants some documentation
>     (3) When tests do fail, it can be incredibly challenging to understand why they failed without adequate documentation regarding what they do
>     
>     While I would never be as stringent about doxygen documentation for unit tests - they are unit tests, and are not an API to be consumed by other developers - I find that going back to a unit test written a year ago that has reasonable documentation is much nicer than not. Exhibit A: test_taskprocessor vs test_poll.

For the record I wasn't suggesting that the comments should be removed, just questioning if we want this to be part of the HTML API documentation that is generated.  I think comments in unit test source files are good, but if they translate to generated HTML documentation that is clutter.


> On July 11, 2014, 2:43 a.m., Corey Farrell wrote:
> > /team/group/media_formats-reviewed-trunk/tests/test_format_cap.c, line 478
> > <https://reviewboard.asterisk.org/r/3734/diff/4/?file=62713#file62713line478>
> >
> >     Should we also test that the counts from original dst_caps + src_caps == count?
> 
> Matt Jordan wrote:
>     Added:
>      	ast_test_validate(test, ast_format_cap_count(dst_caps) == ast_format_cap_count(src_caps));
>

Sorry I was unclear, what I meant:

/* line 466 */  total_count = ast_format_cap_count(dst_caps) + ast_format_cap_count(src_caps);
/* line 486 */  ast_test_validate(test, total_count == ast_format_cap_count(dst_caps));


This way total_count is the count of all audio + all video codecs.  After ast_format_cap_append_from_cap we want to verify dst_cap has the combined count.  I expect the test you added will fail (I haven't tried it so I could be wrong).


- Corey


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviewboard.asterisk.org/r/3734/#review12554
-----------------------------------------------------------


On July 11, 2014, 12:55 p.m., Matt Jordan wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviewboard.asterisk.org/r/3734/
> -----------------------------------------------------------
> 
> (Updated July 11, 2014, 12:55 p.m.)
> 
> 
> Review request for Asterisk Developers.
> 
> 
> Repository: Asterisk
> 
> 
> Description
> -------
> 
> This patch does two things:
> 
> * It updates a few of the unit tests for some of the API changes. In particular, it focuses on adding some tests for formats with attributes and their expected behaviour. A few other non-format related unit tests were updated as well to handle off nominals detected during testing.
> 
> * It adds an 'ast_format_none' format. This format is a dummy format that can be used instead of a NULL pointer to prevent having to put NULL dereference checks into every place in the codebase. Channels are no assigned this format immediately upon creation, and their default capabilities are set to have it. As this format's codec has no translation (nor a representation in the RTP engine), it _shouldn't_ cause harm.
> 
> * A few NULL checks were put in anyway into key areas in a few modules. These were ones that were hit hard by the unit tests and prone to crashing if presented a NULL format.
> 
> 
> Diffs
> -----
> 
>   /team/group/media_formats-reviewed-trunk/tests/test_format_cap.c 418370 
>   /team/group/media_formats-reviewed-trunk/tests/test_format_cache.c 418370 
>   /team/group/media_formats-reviewed-trunk/tests/test_core_format.c 418370 
>   /team/group/media_formats-reviewed-trunk/tests/test_cel.c 418370 
>   /team/group/media_formats-reviewed-trunk/main/format_cap.c 418370 
>   /team/group/media_formats-reviewed-trunk/main/format_cache.c 418370 
>   /team/group/media_formats-reviewed-trunk/main/codec_builtin.c 418370 
>   /team/group/media_formats-reviewed-trunk/main/codec.c 418370 
>   /team/group/media_formats-reviewed-trunk/main/channel.c 418370 
>   /team/group/media_formats-reviewed-trunk/main/bridge_channel.c 418370 
>   /team/group/media_formats-reviewed-trunk/include/asterisk/format_cache.h 418370 
>   /team/group/media_formats-reviewed-trunk/include/asterisk/codec.h 418370 
> 
> Diff: https://reviewboard.asterisk.org/r/3734/diff/
> 
> 
> Testing
> -------
> 
> Unit tests pass.
> 
> There is a FRACK on shutdown, but it doesn't appear to be caused by this patch (things didn't run long enough without this patch before)
> 
> 
> Thanks,
> 
> Matt Jordan
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20140711/f8ca59bc/attachment.html>


More information about the asterisk-dev mailing list