switch_core_session.c 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
  3. * Copyright (C) 2005-2020, Anthony Minessale II <anthm@freeswitch.org>
  4. *
  5. * Version: MPL 1.1
  6. *
  7. * The contents of this file are subject to the Mozilla Public License Version
  8. * 1.1 (the "License"); you may not use this file except in compliance with
  9. * the License. You may obtain a copy of the License at
  10. * http://www.mozilla.org/MPL/
  11. *
  12. * Software distributed under the License is distributed on an "AS IS" basis,
  13. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  14. * for the specific language governing rights and limitations under the
  15. * License.
  16. *
  17. * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
  18. *
  19. * The Initial Developer of the Original Code is
  20. * Anthony Minessale II <anthm@freeswitch.org>
  21. * Portions created by the Initial Developer are Copyright (C)
  22. * the Initial Developer. All Rights Reserved.
  23. *
  24. * Contributor(s):
  25. * Chris Rienzo <chris@signalwire.com>
  26. *
  27. *
  28. * switch_core_session.c -- tests sessions
  29. *
  30. */
  31. #include <switch.h>
  32. #include <test/switch_test.h>
  33. FST_CORE_BEGIN("./conf")
  34. {
  35. FST_SUITE_BEGIN(switch_core_session)
  36. {
  37. FST_SETUP_BEGIN()
  38. {
  39. }
  40. FST_SETUP_END()
  41. FST_TEARDOWN_BEGIN()
  42. {
  43. }
  44. FST_TEARDOWN_END()
  45. FST_SESSION_BEGIN(session_external_id)
  46. {
  47. switch_core_session_t *session;
  48. fst_check(switch_core_session_set_external_id(fst_session, switch_core_session_get_uuid(fst_session)) == SWITCH_STATUS_SUCCESS);
  49. fst_check_string_equals(switch_core_session_get_external_id(fst_session), switch_core_session_get_uuid(fst_session));
  50. fst_check(switch_core_session_set_external_id(fst_session, "foo") == SWITCH_STATUS_SUCCESS);
  51. session = switch_core_session_locate("foo");
  52. fst_requires(session);
  53. fst_check_string_equals(switch_core_session_get_uuid(session), switch_core_session_get_uuid(fst_session));
  54. fst_check_string_equals(switch_core_session_get_external_id(session), "foo");
  55. fst_check(switch_core_session_set_external_id(fst_session, "bar") == SWITCH_STATUS_SUCCESS);
  56. fst_check_string_equals(switch_core_session_get_external_id(session), "bar");
  57. fst_requires(switch_core_session_locate("foo") == NULL);
  58. switch_core_session_rwunlock(session);
  59. session = switch_core_session_locate("bar");
  60. fst_requires(session);
  61. switch_core_session_rwunlock(session);
  62. session = switch_core_session_locate(switch_core_session_get_uuid(fst_session));
  63. fst_requires(session);
  64. switch_core_session_rwunlock(session);
  65. switch_channel_hangup(fst_channel, SWITCH_CAUSE_NORMAL_CLEARING);
  66. session = switch_core_session_locate("bar");
  67. fst_check(session == NULL);
  68. }
  69. FST_SESSION_END()
  70. }
  71. FST_SUITE_END()
  72. }
  73. FST_CORE_END()