[asterisk-dev] [Code Review] Migrates hashtest/hashtest2 to be unit tests

Mark Michelson reviewboard at asterisk.org
Mon Nov 12 11:30:13 CST 2012


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


There are more places than I have pointed out that need tests for allocation failure. You can seek out the rest and get them fixed.


/branches/1.8/tests/test_astobj2_thrash.c
<https://reviewboard.asterisk.org/r/2189/#comment14164>

    check for allocation failure of keybuf here.



/branches/1.8/tests/test_astobj2_thrash.c
<https://reviewboard.asterisk.org/r/2189/#comment14165>

    Check for allocation failure here.



/branches/1.8/tests/test_astobj2_thrash.c
<https://reviewboard.asterisk.org/r/2189/#comment14166>

    Check for allocation failure.



/branches/1.8/tests/test_astobj2_thrash.c
<https://reviewboard.asterisk.org/r/2189/#comment14167>

    The ao2_unlink() should be unnecessary since OBJ_UNLINK was passed as an argument to ao2_find(). In addition, you should pass OBJ_POINTER as an argument to ao2_find since you are passing an object of the appropriate type as an argument.


- Mark


On Nov. 9, 2012, 9:59 a.m., David Lee wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviewboard.asterisk.org/r/2189/
> -----------------------------------------------------------
> 
> (Updated Nov. 9, 2012, 9:59 a.m.)
> 
> 
> Review request for Asterisk Developers.
> 
> 
> Summary
> -------
> 
> Both hashtest and hashtest2 are manual testing apps that thrash hash
> tables (hashtab and ao2 containers, respectively), by spinning up
> several threads that randomly insert, delete, lookup and iterate over
> the hash table. If the app doesn't crash, the hash table probably passes
> the test. Those utils are not a part of the typical Asterisk build, so
> they do not usually get compiled. This all makes them less that useful.
> 
> This patch removes those manual test programs and replaces them with
> Asterisk unit test modules (test_{hashtab,astobj2}_thrash.so). It also
> attempts to make the tests more deterministic.
> 
> * Rather than spinning up some number of threads that operate on the
> hash table randomly, spin up four threads that concurrenly add,
> remove, lookup and iterate over the hash table.
> * Each thread checks the state of the hash table both during and after
> execution, and indicates a test failure if things are not as expected.
> * Each thread times out after 60 seconds to prevent deadlocking the unit
> test run.
> 
> 
> This addresses bug ASTERISK-20505.
>     https://issues.asterisk.org/jira/browse/ASTERISK-20505
> 
> 
> Diffs
> -----
> 
>   /branches/1.8/include/asterisk/hashtab.h 376119 
>   /branches/1.8/tests/test_astobj2_thrash.c PRE-CREATION 
>   /branches/1.8/tests/test_hashtab_thrash.c PRE-CREATION 
>   /branches/1.8/utils/Makefile 376119 
>   /branches/1.8/utils/hashtest.c 376119 
>   /branches/1.8/utils/hashtest2.c 376119 
>   /branches/1.8/utils/utils.xml 376119 
> 
> Diff: https://reviewboard.asterisk.org/r/2189/diff
> 
> 
> Testing
> -------
> 
> Tests run and pass on OS X and 64-bit Ubuntu 12.10.
> 
> If I disable 'do_locking' on the hashtab and rerun the test, the test fails (surprisingly, it does not segfault).
> 
> If I turn down the test timeout to 1 second, the tests all time out.
> 
> 
> Thanks,
> 
> David
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20121112/0958a08e/attachment-0001.htm>


More information about the asterisk-dev mailing list