Commit Graph

687 Commits

Author SHA1 Message Date
David Vossel 6d9c531237 fixes some test description formatting inconsistencies so log file looks nice
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@246338 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-02-11 21:57:37 +00:00
David Vossel 9478670527 astobj2 unit test and bug fix
A bug was discovered during the creation of the astobj2 unit test.
When OBJ_MULTIPLE | OBJ_UNLINK is used, the objects being returned
had a ref count issue.  This patch resolves that.

Review: https://reviewboard.asterisk.org/r/496/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@246299 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-02-11 18:42:25 +00:00
Russell Bryant 1321748c19 Add a test module for the event API, test_event.c.
This module includes a single test so far that creates events using two
different methods and does some verification on the result to make sure
the correct data can be retrieved from the event that was created.

One bug was found in the event API while developing this test, which makes
me happy.  :-)

Review: https://reviewboard.asterisk.org/r/495/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@246260 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-02-10 23:19:16 +00:00
Russell Bryant bbed34f764 Various updates to the unit test API.
1) It occurred to me that the difference in usage between the error ast_str and
the ast_test_update_status() usage has turned out to be a bit ambiguous in
practice.  In a lot of cases, the same message was being sent to both.
In other cases, it was only sent to one or the other.  My opinion now is that
in every case, I think it makes sense to do both; we should output it to the
CLI as well as save it off for logging purposes.

This change results in most of the changes in this diff, since it required
changes to all existing unit tests.  It also allowed for some simplifications
of unit test API implementation code.

2) Update ast_test_status_update() to include the file, function, and line
number for the code providing the update.

3) There are some formatting tweaks here and there.  Hopefully they aren't too
distracting for code review purposes.  Reviewboard's diff viewer seems to do a
pretty good job of pointing out when something is a whitespace change.

4) I moved the md5_test and sha1_test into the test_utils module.  It seemed
like a better approach since these tests are so tiny.

5) I changed the number of nodes used in heap_test_2 from 1 million to
100 thousand.  The only reason for this was to reduce the time it took
for this test to run.

6) Remove an unused function prototype that was at the bottom of utils.h.

7) Simplify test_insert() using the LIST_INSERT_SORTALPHA() macro.  The one
minor difference in behavior is that it no longer checks for a test registered
with the same name.

8) Expand the code in test_alloc() to provide specific error messages for each
failure case, to clearly inform developers if they forget to set the name,
summary, description, etc.

9) Tweak the output of the "test show registered" CLI command.  I swapped the
name and category to have the category first.  It seemed more natural since
that is the sort key.

10) Don't output the status ast_str in the "test show results" CLI command.
This is going to tend to be pretty verbose, so just leave that for the
detailed test logs (test generate results).

Review: https://reviewboard.asterisk.org/r/493/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@245864 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-02-09 23:32:14 +00:00
Russell Bryant 38ed79a076 UNREGISTER instead of REGISTER in unload_module().
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@245623 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-02-08 23:34:01 +00:00
Russell Bryant fe19e1fbd3 Add a SHA1 test module.
Review: https://reviewboard.asterisk.org/r/492/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@245345 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-02-08 00:42:21 +00:00
Russell Bryant b0a0ee6bfe Remove unnecessary include, ast_md5_hash() comes from utils.h.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@245344 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-02-08 00:24:54 +00:00
Russell Bryant c54ab1ae21 Add an MD5 test module.
Review: https://reviewboard.asterisk.org/r/491/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@245307 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-02-07 21:56:04 +00:00
Russell Bryant 0ea944df9e Fix a couple of spelling errors, and add format module dependencies.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@245306 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-02-07 21:43:11 +00:00
Tilghman Lesher cf6592e58e Merge tests that verify the same thing. (Oops.)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@245046 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-02-05 19:07:18 +00:00
David Vossel d16b89be17 RFC compliant uri and display-name encode/decode
1.  URI Encoding
This patch changes ast_uri_encode()'s behavior when doreserved is enabled.
Previously when doreserved was enabled only a small set of reserved
characters were encoded.  This set was comprised primarily of the reserved
characters defined in RFC3261 section 25.1, but contained other characters as
well.  Rather than only escaping the reserved set, doreserved now escapes
all characters not within the unreserved set as defined by RFC 3261 and
RFC 2396.  Also, the 'doreserved' variable has been renamed to 'do_special_char'
in attempts to avoid confusion.

When doreserve is not enabled, the previous logic of only encoding the
characters <= 0X1F and > 0X7f remains, except for the '%' character, which
must always be encoded as it signifies a HEX escaped character during the decode
process.

2. URI Decoding: Break up URI before decode.
In chan_sip.c ast_uri_decode is called on the entire URI instead of it's
individual parts after it is parsed.  This is not good as ast_uri_decode
can introduce special characters back into the URI which can mess up parsing.
This patch resolves this by not decoding a URI until parsing is completely
done.  There are many instances where we check to see if pedantic checking
is enabled before we decode a URI.  In these cases a new macro,
SIP_PEDANTIC_DECODE, is used on the individual parsed segments of the URI
rather than constantly putting if (pedantic) { decode() } checks everywhere
in the code.  In the areas where ast_uri_decode is not dependent upon
pedantic checking this macro is not used, but decoding is still moved to
each individual part of the URI.  The only behavior that should change from
this patch is the time at which decoding occurs.

Since I had to look over every place URI parsing occurs to create this
patch, I found several places where we use duplicate code for parsing.
To consolidate the code, those areas have updated to use the parse_uri()
function where possible.

3. SIP display-name decoding according to RFC3261 section 25.
To properly decode the display-name portion of a FROM header, chan_sip's
get_calleridname() function required a complete re-write.  More information
about this change can be found in the comments at the beginning of this function.

4. Unit Tests.
Unit tests for ast_uri_encode, ast_uri_decode, and get_calleridname() have been
written.  This involved the addition of the test_utils.c file for testing the
utils api.

(closes issue #16299)
Reported by: wdoekes
Patches:
      astsvn-16299-get_calleridname.diff uploaded by wdoekes (license 717)
      get_calleridname_rewrite.diff uploaded by dvossel (license 671)
Tested by: wdoekes, dvossel, Nick_Lewis

Review: https://reviewboard.asterisk.org/r/469/



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@243200 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-01-26 16:30:08 +00:00
Russell Bryant 2ce1ffc664 Log the variable name being tested.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@243158 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-01-26 15:46:53 +00:00
Russell Bryant 3e0463107e Update test_substitution to show failures in the test log.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@243157 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-01-26 15:35:40 +00:00
Tilghman Lesher 847b171f6b Fixing last errors in the conversion, though it appears that the AES_* functions are still broken.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@243077 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-01-26 01:56:24 +00:00
Tilghman Lesher 8d58f5bf37 Using a dummy channel causes CDR() testing to fail.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@243076 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-01-26 01:41:47 +00:00
Tilghman Lesher 114d259192 Wish I had gotten to the review before this got submitted, because there's failures we need to address.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@243075 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-01-26 01:35:19 +00:00
Russell Bryant 6ab50cb0e8 Make unit test modules depend on TEST_FRAMEWORK instead of off by default.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@242965 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-01-25 21:32:38 +00:00
Russell Bryant 8e50021376 Convert test_substitution module to the unit test API.
Review: https://reviewboard.asterisk.org/r/474/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@242954 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-01-25 21:25:23 +00:00
Tilghman Lesher f9f4f6aa3d The irony of not compile-testing a test program before committing is killing me.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@242317 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-01-22 15:09:12 +00:00
Russell Bryant 2a6d62e94d Convert scheduler API entry order test to the test API.
Review: https://reviewboard.asterisk.org/r/470/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@242185 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-01-22 04:50:38 +00:00
Russell Bryant 8f4383d1fa Add test API usage example to test_skel.c.
Review: https://reviewboard.asterisk.org/r/471/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@242184 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-01-22 04:49:26 +00:00
Matthew Nicholson f92938ff67 Added a test for ast_format_reduce_str().
(related to issue #16560)


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@238716 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-01-08 21:04:51 +00:00
David Vossel 73cb2d507b Unit Test Framework API
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.

Review: https://reviewboard.asterisk.org/r/447/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@236027 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-12-22 16:09:11 +00:00
David Brooks dfa1fa560d ami_testhooks.c automatically registers hook
ami_testhooks.c was registering for AMI events upon module load. Moved the registration
to its own CLI command. Added CLI command for unregistering the hook. Changed some of
the wording, removed unnecessary arguments/parameters.

Reported by: rmudgett


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@228661 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-11-06 22:07:22 +00:00
David Brooks d87006ca1c AMI hook interface
This patch, originally submitted by jozza, enables custom modules to send actions to AMI
and receive messages from AMI via a hook interface. Included is a simple test module to
illustrate the interface.

(closes issue #14635)
Reported by: jozza

Review: https://reviewboard.asterisk.org/r/412/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@227448 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-11-03 21:26:28 +00:00
Russell Bryant 4cf8a968fd Add an API for reporting security events, and a security event logging module.
This commit introduces the security events API.  This API is to be used by
Asterisk components to report events that have security implications.
A simple example is when a connection is made but fails authentication.  These
events can be used by external tools manipulate firewall rules or something
similar after detecting unusual activity based on security events.

Inside of Asterisk, the events go through the ast_event API.  This means that
they have a binary encoding, and it is easy to write code to subscribe to these
events and do something with them.

One module is provided that is a subscriber to these events - res_security_log.
This module turns security events into a parseable text format and sends them
to the "security" logger level.  Using logger.conf, these log entries may be
sent to a file, or to syslog.

One service, AMI, has been fully updated for reporting security events.
AMI was chosen as it was a fairly straight forward service to convert.
The next target will be chan_sip.  That will be more complicated and will
be done as its own project as the next phase of security events work.

For more information on the security events framework, see the documentation
generated from doc/tex/.  "make asterisk.pdf"

Review: https://reviewboard.asterisk.org/r/273/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@206021 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-07-11 19:15:03 +00:00
Russell Bryant 0264eef115 Merge the new Channel Event Logging (CEL) subsystem.
CEL is the new system for logging channel events.  This was inspired after
facing many problems trying to represent what is possible to happen to a call
in Asterisk using CDR records.  For more information on CEL, see the built in
HTML or PDF documentation generated from the files in doc/tex/.

Many thanks to Steve Murphy (murf) and Brian Degenhardt (bmd) for their hard
work developing this code.  Also, thanks to Matt Nicholson (mnicholson) and
Sean Bright (seanbright) for their assistance in the final push to get this
code ready for Asterisk trunk.

Review: https://reviewboard.asterisk.org/r/239/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@203638 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-06-26 15:28:53 +00:00
Kevin P. Fleming d1e0b11343 Add ability for modules to dynamically register logger levels
This patch adds the ability for modules to dynamically create logger levels for their own use; these are named levels just like the built-in levels, and can be directed to any destination that the logger can send any level to, by including their names in logger.conf.

Review: https://reviewboard.asterisk.org/r/244/



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@194610 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-05-15 13:13:47 +00:00
Kevin P. Fleming 995d03a235 Minor changes in test modules
Correct command description in test_sched.c and include asterisk/cli.h in test_skel.c, since it's highly unlikely that a test module will *not* want to provide CLI commands to execute the tests



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@191997 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-05-04 12:52:44 +00:00
Tilghman Lesher a866a75900 Merge str_substitution branch.
This branch adds additional methods to dialplan functions, whereby the result
buffers are now dynamic buffers, which can be expanded to the size of any
result.  No longer are variable substitutions limited to 4095 bytes of data.
In addition, the common case of needing buffers much smaller than that will
enable substitution to only take up the amount of memory actually needed.
The existing variable substitution routines are still available, but users
of those API calls should transition to using the dynamic-buffer APIs.
Reviewboard: http://reviewboard.digium.com/r/174/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@191140 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-29 18:53:01 +00:00
Russell Bryant 32cd7d1d60 Disable test modules by default.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@187675 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-10 16:00:29 +00:00
Russell Bryant 989e617e1f Fix a regression in scheduler entry ordering, and add a regression test for it.
(closes issue #14522)
Reported by: pj
Tested by: russell


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@178022 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-02-23 17:29:16 +00:00
Mark Michelson 5d2a7dea85 Use constants from inttypes.h to clear up 32-bit compilation errors
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@176706 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-02-17 22:02:42 +00:00
Russell Bryant 044cf691fe Significantly improve scheduler performance under high load.
This patch changes the scheduler to use a max-heap to store pending scheduler
entries instead of a fully sorted doubly linked list.  When the number of
entries in the scheduler gets large, this will perform much better.  For much
more detailed information on this change, see the review request.

Review: http://reviewboard.digium.com/r/160/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@176639 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-02-17 21:04:08 +00:00
Russell Bryant 56b9180bd7 Add a test module for the heap implementation.
Review: http://reviewboard.digium.com/r/160/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@176635 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-02-17 20:56:26 +00:00
Steve Murphy 27891e6b4b Introducing doubly linked lists to trunk from branch team/murf/bug11210.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@114172 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-04-16 17:14:18 +00:00
Kevin P. Fleming d83f08d1b4 add some simple infrastructure for modules to be used for testing parts of Asterisk
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@96272 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-01-03 20:04:30 +00:00