main.c 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /*
  2. * Wslay - The WebSocket Library
  3. *
  4. * Copyright (c) 2011, 2012 Tatsuhiro Tsujikawa
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining
  7. * a copy of this software and associated documentation files (the
  8. * "Software"), to deal in the Software without restriction, including
  9. * without limitation the rights to use, copy, modify, merge, publish,
  10. * distribute, sublicense, and/or sell copies of the Software, and to
  11. * permit persons to whom the Software is furnished to do so, subject to
  12. * the following conditions:
  13. *
  14. * The above copyright notice and this permission notice shall be
  15. * included in all copies or substantial portions of the Software.
  16. *
  17. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  18. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  19. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  20. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  21. * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  22. * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  23. * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  24. */
  25. #include <stdio.h>
  26. #include <string.h>
  27. #include <CUnit/Basic.h>
  28. /* include test cases' include files here */
  29. #include "wslay_frame_test.h"
  30. #include "wslay_event_test.h"
  31. #include "wslay_queue_test.h"
  32. static int init_suite1(void)
  33. {
  34. return 0;
  35. }
  36. static int clean_suite1(void)
  37. {
  38. return 0;
  39. }
  40. int main(void)
  41. {
  42. CU_pSuite pSuite = NULL;
  43. /* initialize the CUnit test registry */
  44. if (CUE_SUCCESS != CU_initialize_registry())
  45. return CU_get_error();
  46. /* add a suite to the registry */
  47. pSuite = CU_add_suite("libwslay_TestSuite", init_suite1, clean_suite1);
  48. if (NULL == pSuite) {
  49. CU_cleanup_registry();
  50. return CU_get_error();
  51. }
  52. /* add the tests to the suite */
  53. if(!CU_add_test(pSuite, "wslay_frame_context_init",
  54. test_wslay_frame_context_init) ||
  55. !CU_add_test(pSuite, "wslay_frame_recv", test_wslay_frame_recv) ||
  56. !CU_add_test(pSuite, "wslay_frame_recv_1byte",
  57. test_wslay_frame_recv_1byte) ||
  58. !CU_add_test(pSuite, "wslay_frame_recv_fragmented",
  59. test_wslay_frame_recv_fragmented) ||
  60. !CU_add_test(pSuite, "wslay_frame_recv_interleaved_ctrl_frame",
  61. test_wslay_frame_recv_interleaved_ctrl_frame) ||
  62. !CU_add_test(pSuite, "wslay_frame_recv_zero_payloadlen",
  63. test_wslay_frame_recv_zero_payloadlen) ||
  64. !CU_add_test(pSuite, "wslay_frame_recv_too_large_payload",
  65. test_wslay_frame_recv_too_large_payload) ||
  66. !CU_add_test(pSuite, "wslay_frame_recv_ctrl_too_large_payload",
  67. test_wslay_frame_recv_ctrl_frame_too_large_payload) ||
  68. !CU_add_test(pSuite, "wslay_frame_recv_minimum_ext_payload16",
  69. test_wslay_frame_recv_minimum_ext_payload16) ||
  70. !CU_add_test(pSuite, "wslay_frame_recv_minimum_ext_payload64",
  71. test_wslay_frame_recv_minimum_ext_payload64) ||
  72. !CU_add_test(pSuite, "wslay_frame_send", test_wslay_frame_send) ||
  73. !CU_add_test(pSuite, "wslay_frame_send_fragmented",
  74. test_wslay_frame_send_fragmented) ||
  75. !CU_add_test(pSuite, "wslay_frame_send_interleaved_ctrl_frame",
  76. test_wslay_frame_send_interleaved_ctrl_frame) ||
  77. !CU_add_test(pSuite, "wslay_frame_send_1byte_masked",
  78. test_wslay_frame_send_1byte_masked) ||
  79. !CU_add_test(pSuite, "wslay_frame_send_zero_payloadlen",
  80. test_wslay_frame_send_zero_payloadlen) ||
  81. !CU_add_test(pSuite, "wslay_frame_send_too_large_payload",
  82. test_wslay_frame_send_too_large_payload) ||
  83. !CU_add_test(pSuite, "wslay_frame_send_ctrl_frame_too_large_payload",
  84. test_wslay_frame_send_ctrl_frame_too_large_payload) ||
  85. !CU_add_test(pSuite, "wslay_event_send_fragmented_msg",
  86. test_wslay_event_send_fragmented_msg) ||
  87. !CU_add_test(pSuite, "wslay_event_send_fragmented_msg_with_ctrl",
  88. test_wslay_event_send_fragmented_msg_with_ctrl) ||
  89. !CU_add_test(pSuite, "wslay_event_send_ctrl_msg_first",
  90. test_wslay_event_send_ctrl_msg_first) ||
  91. !CU_add_test(pSuite, "wslay_event_queue_close",
  92. test_wslay_event_queue_close) ||
  93. !CU_add_test(pSuite, "wslay_event_queue_close_without_code",
  94. test_wslay_event_queue_close_without_code) ||
  95. !CU_add_test(pSuite, "wslay_event_recv_close_without_code",
  96. test_wslay_event_recv_close_without_code) ||
  97. !CU_add_test(pSuite, "wslay_event_reply_close",
  98. test_wslay_event_reply_close) ||
  99. !CU_add_test(pSuite, "wslay_event_no_more_msg",
  100. test_wslay_event_no_more_msg) ||
  101. !CU_add_test(pSuite, "wslay_event_callback_failure",
  102. test_wslay_event_callback_failure) ||
  103. !CU_add_test(pSuite, "wslay_event_no_buffering",
  104. test_wslay_event_no_buffering) ||
  105. !CU_add_test(pSuite, "wslay_event_frame_too_big",
  106. test_wslay_event_frame_too_big) ||
  107. !CU_add_test(pSuite, "wslay_event_message_too_big",
  108. test_wslay_event_message_too_big) ||
  109. !CU_add_test(pSuite, "wslay_queue", test_wslay_queue)) {
  110. CU_cleanup_registry();
  111. return CU_get_error();
  112. }
  113. /* Run all tests using the CUnit Basic interface */
  114. CU_basic_set_mode(CU_BRM_VERBOSE);
  115. CU_basic_run_tests();
  116. CU_cleanup_registry();
  117. return CU_get_error();
  118. }