suite_for_nua.c 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. /*
  2. * This file is part of the Sofia-SIP package
  3. *
  4. * Copyright (C) 2007 Nokia Corporation.
  5. *
  6. * Contact: Pekka Pessi <pekka.pessi@nokia.com>
  7. *
  8. * This library is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU Lesser General Public License
  10. * as published by the Free Software Foundation; either version 2.1 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This library is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * Lesser General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with this library; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  21. * 02110-1301 USA
  22. *
  23. */
  24. /**@CFILE suite_for_nua.c
  25. *
  26. * @brief Check-driven tester for Sofia SIP User Agent library
  27. *
  28. * @author Pekka Pessi <Pekka.Pessi@nokia.com>
  29. *
  30. * @copyright (C) 2007 Nokia Corporation.
  31. */
  32. #include "config.h"
  33. #include "test_nua.h"
  34. #include "check_sofia.h"
  35. int print_headings = 0;
  36. struct context ctx[1] = {{{ SU_HOME_INIT(ctx) }}};
  37. SOFIAPUBVAR su_log_t nua_log[];
  38. SOFIAPUBVAR su_log_t soa_log[];
  39. SOFIAPUBVAR su_log_t nea_log[];
  40. SOFIAPUBVAR su_log_t nta_log[];
  41. SOFIAPUBVAR su_log_t tport_log[];
  42. SOFIAPUBVAR su_log_t su_log_default[];
  43. static void init_context(void)
  44. {
  45. int level = 1;
  46. su_init();
  47. memset(ctx, 0, sizeof ctx);
  48. su_home_init(ctx->home);
  49. endpoint_init(ctx, &ctx->a, 'a');
  50. endpoint_init(ctx, &ctx->b, 'b');
  51. endpoint_init(ctx, &ctx->c, 'c');
  52. su_log_soft_set_level(nua_log, level);
  53. su_log_soft_set_level(soa_log, level);
  54. su_log_soft_set_level(su_log_default, level);
  55. su_log_soft_set_level(nea_log, level);
  56. su_log_soft_set_level(nta_log, level);
  57. su_log_soft_set_level(tport_log, level);
  58. }
  59. static void clean_context(void)
  60. {
  61. test_deinit(ctx);
  62. su_home_deinit(ctx->home);
  63. memset(ctx, 0, sizeof ctx);
  64. su_deinit();
  65. }
  66. /* Each testcase is run in different process */
  67. START_TEST(check_api) { fail_if(test_nua_api_errors(ctx)); } END_TEST
  68. START_TEST(check_tag_filter) { fail_if(test_tag_filter()); } END_TEST
  69. START_TEST(check_params) { fail_if(test_nua_params(ctx)); } END_TEST
  70. START_TEST(check_destroy) { fail_if(test_nua_destroy(ctx)); } END_TEST
  71. START_TEST(check_stack_errors) { fail_if(test_stack_errors(ctx)); } END_TEST
  72. START_TEST(without_proxy)
  73. {
  74. fail_if(test_nua_init(ctx, 0, NULL, 0, TAG_END()));
  75. fail_if(test_register(ctx));
  76. fail_if(test_connectivity(ctx));
  77. fail_if(test_basic_call(ctx));
  78. fail_if(test_rejects(ctx));
  79. fail_if(test_call_cancel(ctx));
  80. fail_if(test_call_destroy(ctx));
  81. fail_if(test_early_bye(ctx));
  82. fail_if(test_offer_answer(ctx));
  83. fail_if(test_reinvites(ctx));
  84. fail_if(test_session_timer(ctx));
  85. fail_if(test_refer(ctx));
  86. fail_if(test_100rel(ctx));
  87. fail_if(test_simple(ctx));
  88. fail_if(test_events(ctx));
  89. fail_if(test_extension(ctx));
  90. fail_if(test_unregister(ctx));
  91. fail_if(test_deinit(ctx));
  92. }
  93. END_TEST
  94. START_TEST(with_proxy)
  95. {
  96. fail_if(test_nua_init(ctx, 1, NULL, 0, TAG_END()));
  97. fail_if(test_register(ctx));
  98. fail_if(test_connectivity(ctx));
  99. fail_if(test_basic_call(ctx));
  100. fail_if(test_rejects(ctx));
  101. fail_if(test_call_cancel(ctx));
  102. fail_if(test_call_destroy(ctx));
  103. fail_if(test_early_bye(ctx));
  104. fail_if(test_offer_answer(ctx));
  105. fail_if(test_reinvites(ctx));
  106. fail_if(test_session_timer(ctx));
  107. fail_if(test_refer(ctx));
  108. fail_if(test_100rel(ctx));
  109. fail_if(test_simple(ctx));
  110. fail_if(test_events(ctx));
  111. fail_if(test_extension(ctx));
  112. fail_if(test_unregister(ctx));
  113. fail_if(test_deinit(ctx));
  114. }
  115. END_TEST
  116. START_TEST(with_proxy_and_nat)
  117. {
  118. fail_if(test_nua_init(ctx, 1, NULL, 1, TAG_END()));
  119. fail_if(test_register(ctx));
  120. fail_if(test_connectivity(ctx));
  121. fail_if(test_nat_timeout(ctx));
  122. fail_if(test_basic_call(ctx));
  123. fail_if(test_rejects(ctx));
  124. fail_if(test_call_cancel(ctx));
  125. fail_if(test_call_destroy(ctx));
  126. fail_if(test_early_bye(ctx));
  127. fail_if(test_offer_answer(ctx));
  128. fail_if(test_reinvites(ctx));
  129. fail_if(test_session_timer(ctx));
  130. fail_if(test_refer(ctx));
  131. fail_if(test_100rel(ctx));
  132. fail_if(test_simple(ctx));
  133. fail_if(test_events(ctx));
  134. fail_if(test_extension(ctx));
  135. fail_if(test_unregister(ctx));
  136. fail_if(test_deinit(ctx));
  137. }
  138. END_TEST
  139. Suite *suite_for_nua(void)
  140. {
  141. Suite *suite = suite_create("nua");
  142. TCase *tc;
  143. tc = tcase_create("api");
  144. tcase_add_unchecked_fixture(tc, init_context, clean_context);
  145. tcase_add_test(tc, check_api);
  146. tcase_add_test(tc, check_tag_filter);
  147. tcase_add_test(tc, check_params);
  148. tcase_add_test(tc, check_destroy);
  149. tcase_add_test(tc, check_stack_errors);
  150. tcase_set_timeout(tc, 5);
  151. suite_add_tcase(suite, tc);
  152. tc = tcase_create("without-proxy");
  153. tcase_add_unchecked_fixture(tc, init_context, clean_context);
  154. tcase_add_test(tc, without_proxy);
  155. tcase_set_timeout(tc, 60);
  156. suite_add_tcase(suite, tc);
  157. tc = tcase_create("with-proxy");
  158. tcase_add_unchecked_fixture(tc, init_context, clean_context);
  159. tcase_add_test(tc, with_proxy);
  160. tcase_set_timeout(tc, 120);
  161. suite_add_tcase(suite, tc);
  162. tc = tcase_create("with-proxy-and-nat");
  163. tcase_add_unchecked_fixture(tc, init_context, clean_context);
  164. tcase_add_test(tc, with_proxy_and_nat);
  165. tcase_set_timeout(tc, 120);
  166. suite_add_tcase(suite, tc);
  167. return suite;
  168. }