Asterisk - The Open Source Telephony Project GIT-master-f36a736
test_skel.c
Go to the documentation of this file.
1/*
2 * Asterisk -- An open source telephony toolkit.
3 *
4 * Copyright (C) <Year>, <Your Name Here>
5 *
6 * <Your Name Here> <<Your Email Here>>
7 *
8 * See http://www.asterisk.org for more information about
9 * the Asterisk project. Please do not directly contact
10 * any of the maintainers of this project for assistance;
11 * the project provides a web site, mailing lists and IRC
12 * channels for your use.
13 *
14 * This program is free software, distributed under the terms of
15 * the GNU General Public License Version 2. See the LICENSE file
16 * at the top of the source tree.
17 */
18
19/*!
20 * \file
21 * \brief Skeleton Test
22 *
23 * \author\verbatim <Your Name Here> <<Your Email Here>> \endverbatim
24 *
25 * This is a skeleton for development of an Asterisk test module
26 * \ingroup tests
27 */
28
29/*** MODULEINFO
30 <depend>TEST_FRAMEWORK</depend>
31 <support_level>core</support_level>
32 ***/
33
34#include "asterisk.h"
35
36#include "asterisk/utils.h"
37#include "asterisk/module.h"
38#include "asterisk/test.h"
39
40AST_TEST_DEFINE(sample_test)
41{
42 void *ptr;
43
44 switch (cmd) {
45 case TEST_INIT:
46 info->name = "sample_test";
47 info->category = "/main/sample/";
48 info->summary = "sample unit test";
49 info->description =
50 "This demonstrates what is required to implement "
51 "a unit test.";
52 return AST_TEST_NOT_RUN;
53 case TEST_EXECUTE:
54 break;
55 }
56
57 ast_test_status_update(test, "Executing sample test...\n");
58
59 if (!(ptr = ast_malloc(8))) {
60 ast_test_status_update(test, "ast_malloc() failed\n");
61 return AST_TEST_FAIL;
62 }
63
64 ast_free(ptr);
65
66 return AST_TEST_PASS;
67}
68
69static int unload_module(void)
70{
71 AST_TEST_UNREGISTER(sample_test);
72 return 0;
73}
74
75static int load_module(void)
76{
77 AST_TEST_REGISTER(sample_test);
79}
80
81AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Skeleton (sample) Test");
Asterisk main include file. File version handling, generic pbx functions.
#define ast_free(a)
Definition: astmm.h:180
#define ast_malloc(len)
A wrapper for malloc()
Definition: astmm.h:191
Asterisk module definitions.
#define AST_MODULE_INFO_STANDARD(keystr, desc)
Definition: module.h:581
#define ASTERISK_GPL_KEY
The text the key() function should return.
Definition: module.h:46
@ AST_MODULE_LOAD_SUCCESS
Definition: module.h:70
def info(msg)
Test Framework API.
@ TEST_INIT
Definition: test.h:200
@ TEST_EXECUTE
Definition: test.h:201
#define AST_TEST_REGISTER(cb)
Definition: test.h:127
#define ast_test_status_update(a, b, c...)
Definition: test.h:129
#define AST_TEST_UNREGISTER(cb)
Definition: test.h:128
@ AST_TEST_PASS
Definition: test.h:195
@ AST_TEST_FAIL
Definition: test.h:196
@ AST_TEST_NOT_RUN
Definition: test.h:194
AST_TEST_DEFINE(sample_test)
Definition: test_skel.c:40
static int load_module(void)
Definition: test_skel.c:75
static int unload_module(void)
Definition: test_skel.c:69
Utility functions.