[asterisk-commits] russell: trunk r242184 - /trunk/tests/test_skel.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Jan 21 22:49:29 CST 2010


Author: russell
Date: Thu Jan 21 22:49:26 2010
New Revision: 242184

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=242184
Log:
Add test API usage example to test_skel.c.

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

Modified:
    trunk/tests/test_skel.c

Modified: trunk/tests/test_skel.c
URL: http://svnview.digium.com/svn/asterisk/trunk/tests/test_skel.c?view=diff&rev=242184&r1=242183&r2=242184
==============================================================================
--- trunk/tests/test_skel.c (original)
+++ trunk/tests/test_skel.c Thu Jan 21 22:49:26 2010
@@ -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;
 }
 




More information about the asterisk-commits mailing list