You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

287 lines
6.6 KiB

  1. /* /////////////////////////////////////////////////////////////////////////
  2. * File: test/unit/test.unit.be.WindowsSyslog/test.unit.be.WindowsSyslog.cpp
  3. *
  4. * Purpose: Implementation file for the test.unit.be.WindowsSyslog project.
  5. *
  6. * Created: 17th October 2008
  7. * Updated: 10th January 2011
  8. *
  9. * Status: Wizard-generated
  10. *
  11. * License: (Licensed under the Synesis Software Open License)
  12. *
  13. * Copyright (c) 2008-2011, Synesis Software Pty Ltd.
  14. * All rights reserved.
  15. *
  16. * www: http://www.synesis.com.au/software
  17. *
  18. * ////////////////////////////////////////////////////////////////////// */
  19. /* /////////////////////////////////////////////////////////////////////////
  20. * Includes
  21. */
  22. #include <pantheios/util/test/compiler_warnings_suppression.first_include.h>
  23. /* Pantheios Header Files */
  24. #include <pantheios/backends/bec.WindowsSyslog.h>
  25. /* xTests Header Files */
  26. #include <xtests/xtests.h>
  27. /* STLSoft Header Files */
  28. #include <stlsoft/smartptr/scoped_handle.hpp>
  29. /* Standard C Header Files */
  30. #include <stdio.h>
  31. #include <stdlib.h>
  32. #include <pantheios/util/test/compiler_warnings_suppression.last_include.h>
  33. /* /////////////////////////////////////////////////////////////////////////
  34. * Globals
  35. */
  36. extern "C" const PAN_CHAR_T PANTHEIOS_FE_PROCESS_IDENTITY[] = PANTHEIOS_LITERAL_STRING("test.unit.be.WindowsSyslog");
  37. /* /////////////////////////////////////////////////////////////////////////
  38. * Forward declarations
  39. */
  40. namespace
  41. {
  42. static void test_getDefaultAppInit(void);
  43. static void test_initialisation(void);
  44. static void test_1_2(void);
  45. static void test_1_3(void);
  46. static void test_1_4(void);
  47. static void test_1_5(void);
  48. static void test_1_6(void);
  49. static void test_1_7(void);
  50. static void test_1_8(void);
  51. static void test_1_9(void);
  52. static void test_1_10(void);
  53. static void test_1_11(void);
  54. static void test_1_12(void);
  55. static void test_1_13(void);
  56. static void test_1_14(void);
  57. static void test_1_15(void);
  58. static void test_1_16(void);
  59. static void test_1_17(void);
  60. static void test_1_18(void);
  61. static void test_1_19(void);
  62. } // anonymous namespace
  63. /* /////////////////////////////////////////////////////////////////////////
  64. * Main
  65. */
  66. int main(int argc, char **argv)
  67. {
  68. int retCode = EXIT_SUCCESS;
  69. int verbosity = 2;
  70. WSADATA wsadata;
  71. WORD version = MAKEWORD(2, 2);
  72. int r = ::WSAStartup(version, &wsadata);
  73. if(0 != r)
  74. {
  75. fprintf(stderr, "failed to initialise the WinSock2 library: %d\n", r);
  76. retCode = EXIT_FAILURE;
  77. }
  78. else
  79. {
  80. stlsoft::scoped_handle<void> scoper(::WSACleanup);
  81. XTESTS_COMMANDLINE_PARSEVERBOSITY(argc, argv, &verbosity);
  82. if(XTESTS_START_RUNNER("test.unit.be.WindowsSyslog", verbosity))
  83. {
  84. XTESTS_RUN_CASE(test_getDefaultAppInit);
  85. XTESTS_RUN_CASE(test_initialisation);
  86. XTESTS_RUN_CASE(test_1_2);
  87. XTESTS_RUN_CASE(test_1_3);
  88. XTESTS_RUN_CASE(test_1_4);
  89. XTESTS_RUN_CASE(test_1_5);
  90. XTESTS_RUN_CASE(test_1_6);
  91. XTESTS_RUN_CASE(test_1_7);
  92. XTESTS_RUN_CASE(test_1_8);
  93. XTESTS_RUN_CASE(test_1_9);
  94. XTESTS_RUN_CASE(test_1_10);
  95. XTESTS_RUN_CASE(test_1_11);
  96. XTESTS_RUN_CASE(test_1_12);
  97. XTESTS_RUN_CASE(test_1_13);
  98. XTESTS_RUN_CASE(test_1_14);
  99. XTESTS_RUN_CASE(test_1_15);
  100. XTESTS_RUN_CASE(test_1_16);
  101. XTESTS_RUN_CASE(test_1_17);
  102. XTESTS_RUN_CASE(test_1_18);
  103. XTESTS_RUN_CASE(test_1_19);
  104. }
  105. XTESTS_PRINT_RESULTS();
  106. XTESTS_END_RUNNER_UPDATE_EXITCODE(&retCode);
  107. }
  108. return retCode;
  109. }
  110. /* /////////////////////////////////////////////////////////////////////////
  111. * Test function implementations
  112. */
  113. namespace
  114. {
  115. static void test_getDefaultAppInit()
  116. {
  117. pan_be_WindowsSyslog_init_t init;
  118. pantheios_be_WindowsSyslog_getDefaultAppInit(&init);
  119. XTESTS_TEST_INTEGER_EQUAL(0u, unsigned(init.flags));
  120. XTESTS_TEST_INTEGER_EQUAL(4u, init.addrSize);
  121. XTESTS_TEST_INTEGER_EQUAL(255u, init.bytes[0]);
  122. XTESTS_TEST_INTEGER_EQUAL(255u, init.bytes[1]);
  123. XTESTS_TEST_INTEGER_EQUAL(255u, init.bytes[2]);
  124. XTESTS_TEST_INTEGER_EQUAL(255u, init.bytes[3]);
  125. XTESTS_TEST_POINTER_EQUAL(static_cast<char const*>(NULL), init.hostName);
  126. XTESTS_TEST_INTEGER_EQUAL(514u, init.port);
  127. XTESTS_TEST_INTEGER_EQUAL(PANTHEIOS_SYSLOG_FAC_USER, init.facility);
  128. }
  129. static void test_initialisation()
  130. {
  131. pan_be_WindowsSyslog_init_t init;
  132. pantheios_be_WindowsSyslog_getDefaultAppInit(&init);
  133. init.flags |= PANTHEIOS_BE_WINDOWSSYSLOG_F_NDELAY;
  134. init.addrSize = 0;
  135. init.hostName = "localhost";
  136. init.port = 50505;
  137. void* token;
  138. int r = pantheios_be_WindowsSyslog_init(PANTHEIOS_FE_PROCESS_IDENTITY, 1, &init, NULL, &token);
  139. if(r < 0)
  140. {
  141. XTESTS_TEST_FAIL_WITH_QUALIFIER("could not initialise be.WindowsSyslog", pantheios::getStockSeverityString(r));
  142. }
  143. else
  144. {
  145. stlsoft::scoped_handle<void*> scoper(token, pantheios_be_WindowsSyslog_uninit);
  146. XTESTS_TEST_PASSED();
  147. }
  148. }
  149. static void test_1_2()
  150. {
  151. pan_be_WindowsSyslog_init_t init;
  152. pantheios_be_WindowsSyslog_getDefaultAppInit(&init);
  153. init.flags |= PANTHEIOS_BE_WINDOWSSYSLOG_F_NDELAY;
  154. init.addrSize = 0;
  155. init.hostName = "localhost";
  156. init.port = 50505;
  157. void* token;
  158. int r = pantheios_be_WindowsSyslog_init(PANTHEIOS_FE_PROCESS_IDENTITY, 1, &init, NULL, &token);
  159. if(r < 0)
  160. {
  161. XTESTS_TEST_FAIL_WITH_QUALIFIER("could not initialise be.WindowsSyslog", pantheios::getStockSeverityString(r));
  162. }
  163. else
  164. {
  165. stlsoft::scoped_handle<void*> scoper(token, pantheios_be_WindowsSyslog_uninit);
  166. // TODO: create a listening thread, do the statements, stop the thread, verify the elements;
  167. XTESTS_TEST_PASSED();
  168. }
  169. }
  170. static void test_1_3()
  171. {
  172. }
  173. static void test_1_4()
  174. {
  175. }
  176. static void test_1_5()
  177. {
  178. }
  179. static void test_1_6()
  180. {
  181. }
  182. static void test_1_7()
  183. {
  184. }
  185. static void test_1_8()
  186. {
  187. }
  188. static void test_1_9()
  189. {
  190. }
  191. static void test_1_10()
  192. {
  193. }
  194. static void test_1_11()
  195. {
  196. }
  197. static void test_1_12()
  198. {
  199. }
  200. static void test_1_13()
  201. {
  202. }
  203. static void test_1_14()
  204. {
  205. }
  206. static void test_1_15()
  207. {
  208. }
  209. static void test_1_16()
  210. {
  211. }
  212. static void test_1_17()
  213. {
  214. }
  215. static void test_1_18()
  216. {
  217. }
  218. static void test_1_19()
  219. {
  220. }
  221. } // anonymous namespace
  222. /* ///////////////////////////// end of file //////////////////////////// */