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

David Lee reviewboard at asterisk.org
Fri Nov 9 09:59:25 CST 2012


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

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/20121109/1791c0e6/attachment.htm>


More information about the asterisk-dev mailing list