test_skel.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. * \file
  20. * \brief Skeleton Test
  21. *
  22. * \author\verbatim <Your Name Here> <<Your Email Here>> \endverbatim
  23. *
  24. * This is a skeleton for development of an Asterisk test module
  25. * \ingroup tests
  26. */
  27. /*** MODULEINFO
  28. <depend>TEST_FRAMEWORK</depend>
  29. <support_level>core</support_level>
  30. ***/
  31. #include "asterisk.h"
  32. ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
  33. #include "asterisk/utils.h"
  34. #include "asterisk/module.h"
  35. #include "asterisk/test.h"
  36. AST_TEST_DEFINE(sample_test)
  37. {
  38. void *ptr;
  39. switch (cmd) {
  40. case TEST_INIT:
  41. info->name = "sample_test";
  42. info->category = "/main/sample/";
  43. info->summary = "sample unit test";
  44. info->description =
  45. "This demonstrates what is required to implement "
  46. "a unit test.";
  47. return AST_TEST_NOT_RUN;
  48. case TEST_EXECUTE:
  49. break;
  50. }
  51. ast_test_status_update(test, "Executing sample test...\n");
  52. if (!(ptr = ast_malloc(8))) {
  53. ast_test_status_update(test, "ast_malloc() failed\n");
  54. return AST_TEST_FAIL;
  55. }
  56. ast_free(ptr);
  57. return AST_TEST_PASS;
  58. }
  59. static int unload_module(void)
  60. {
  61. AST_TEST_UNREGISTER(sample_test);
  62. return 0;
  63. }
  64. static int load_module(void)
  65. {
  66. AST_TEST_REGISTER(sample_test);
  67. return AST_MODULE_LOAD_SUCCESS;
  68. }
  69. AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Skeleton (sample) Test");