summaryrefslogtreecommitdiff
path: root/tests/test_skel.c
diff options
context:
space:
mode:
authorRussell Bryant <russell@russellbryant.com>2010-01-22 04:49:26 +0000
committerRussell Bryant <russell@russellbryant.com>2010-01-22 04:49:26 +0000
commit8f4383d1fa815b2977c0b319b3488ccaeaec95b7 (patch)
treec7c511698767e6284eb90c75be9f2f0d0b818211 /tests/test_skel.c
parentc8c4ea9bf4717a2a916722b902adceacf15eae6b (diff)
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
Diffstat (limited to 'tests/test_skel.c')
-rw-r--r--tests/test_skel.c43
1 files changed, 35 insertions, 8 deletions
diff --git a/tests/test_skel.c b/tests/test_skel.c
index 86a1758ac..a86e627ce 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
@@ -34,21 +34,48 @@
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/cli.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(&args->status_update, "Executing sample test.\n");
+
+ if (!(ptr = ast_malloc(8))) {
+ ast_str_set(&args->ast_test_error_str, 0, "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;
}