aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_skel.c
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2010-06-25 18:58:37 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2010-06-25 18:58:37 +0000
commita3a4d3061dc9bbfae8f387fe9295a1cbe94db748 (patch)
treeaf460717bd24b7267eca56910c9dae1e9d8d1bc3 /tests/test_skel.c
parentaf204cb6e6ccd0702d6da0ab960f3222d9590091 (diff)
Backport unit test API from trunk.
Also, update existing test modules that were already in this branch but had been converted to the unit test API in trunk. Review: https://reviewboard.asterisk.org/r/748/ git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.2@272531 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'tests/test_skel.c')
-rw-r--r--tests/test_skel.c44
1 files changed, 36 insertions, 8 deletions
diff --git a/tests/test_skel.c b/tests/test_skel.c
index 9f8008658..c1ce5e844 100644
--- a/tests/test_skel.c
+++ b/tests/test_skel.c
@@ -16,8 +16,8 @@
* at the top of the source tree.
*/
-/*! \file
- *
+/*!
+ * \file
* \brief Skeleton Test
*
* \author\verbatim <Your Name Here> <<Your Email Here>> \endverbatim
@@ -27,27 +27,55 @@
*/
/*** MODULEINFO
- <defaultenabled>no</defaultenabled>
+ <depend>TEST_FRAMEWORK</depend>
***/
#include "asterisk.h"
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
-#include "asterisk/file.h"
-#include "asterisk/channel.h"
-#include "asterisk/pbx.h"
+#include "asterisk/utils.h"
#include "asterisk/module.h"
-#include "asterisk/lock.h"
-#include "asterisk/app.h"
+#include "asterisk/test.h"
+
+AST_TEST_DEFINE(sample_test)
+{
+ void *ptr;
+
+ switch (cmd) {
+ case TEST_INIT:
+ info->name = "sample_test";
+ info->category = "main/sample/";
+ info->summary = "sample unit test";
+ info->description =
+ "This demonstrates what is required to implement "
+ "a unit test.";
+ return AST_TEST_NOT_RUN;
+ case TEST_EXECUTE:
+ break;
+ }
+
+ ast_test_status_update(test, "Executing sample test...\n");
+
+ if (!(ptr = ast_malloc(8))) {
+ ast_test_status_update(test, "ast_malloc() failed\n");
+ return AST_TEST_FAIL;
+ }
+
+ ast_free(ptr);
+
+ return AST_TEST_PASS;
+}
static int unload_module(void)
{
+ AST_TEST_UNREGISTER(sample_test);
return 0;
}
static int load_module(void)
{
+ AST_TEST_REGISTER(sample_test);
return AST_MODULE_LOAD_SUCCESS;
}