Asterisk - The Open Source Telephony Project  18.5.0
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 
40 AST_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 
69 static int unload_module(void)
70 {
71  AST_TEST_UNREGISTER(sample_test);
72  return 0;
73 }
74 
75 static int load_module(void)
76 {
77  AST_TEST_REGISTER(sample_test);
79 }
80 
81 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Skeleton (sample) Test");
#define AST_MODULE_INFO_STANDARD(keystr, desc)
Definition: module.h:567
Asterisk main include file. File version handling, generic pbx functions.
static int unload_module(void)
Definition: test_skel.c:69
Test Framework API.
#define AST_TEST_REGISTER(cb)
Definition: test.h:127
AST_TEST_DEFINE(sample_test)
Definition: test_skel.c:40
Utility functions.
#define ast_test_status_update(a, b, c...)
Definition: test.h:129
#define ast_malloc(len)
A wrapper for malloc()
Definition: astmm.h:193
#define AST_TEST_UNREGISTER(cb)
Definition: test.h:128
def info(msg)
#define ast_free(a)
Definition: astmm.h:182
static int load_module(void)
Definition: test_skel.c:75
#define ASTERISK_GPL_KEY
The text the key() function should return.
Definition: module.h:46
Asterisk module definitions.