switch_core.c 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
  3. * Copyright (C) 2005-2018, 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. * Seven Du <dujinfang@gmail.com>
  27. *
  28. *
  29. * switch_core.c -- tests core functions
  30. *
  31. */
  32. #include <switch.h>
  33. #include <stdlib.h>
  34. #include <test/switch_test.h>
  35. FST_CORE_BEGIN("./conf")
  36. {
  37. FST_SUITE_BEGIN(switch_ivr_originate)
  38. {
  39. FST_SETUP_BEGIN()
  40. {
  41. }
  42. FST_SETUP_END()
  43. FST_TEARDOWN_BEGIN()
  44. {
  45. }
  46. FST_TEARDOWN_END()
  47. #ifndef WIN32
  48. FST_TEST_BEGIN(test_fork)
  49. {
  50. switch_stream_handle_t exec_result = { 0 };
  51. SWITCH_STANDARD_STREAM(exec_result);
  52. fst_requires(switch_stream_system_fork("ip ad sh", &exec_result) == 0);
  53. fst_requires(!zstr(exec_result.data));
  54. switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "%s\n", (char *)exec_result.data);
  55. fst_requires(switch_stream_system_fork("ip ad sh | grep link", &exec_result) == 0);
  56. fst_requires(!zstr(exec_result.data));
  57. switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "%s\n", (char *)exec_result.data);
  58. switch_safe_free(exec_result.data);
  59. }
  60. FST_TEST_END()
  61. #endif
  62. FST_TEST_BEGIN(test_non_fork_exec_set)
  63. {
  64. char *var_test = switch_core_get_variable_dup("test");
  65. char *var_default_password = switch_core_get_variable_dup("default_password");
  66. switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "global_getvar test: %s\n", switch_str_nil(var_test));
  67. switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "global_getvar default_password: %s\n", switch_str_nil(var_default_password));
  68. fst_check_string_not_equals(var_test, "");
  69. fst_check_string_not_equals(var_default_password, "");
  70. fst_check_string_equals(var_test, var_default_password);
  71. switch_safe_free(var_test);
  72. switch_safe_free(var_default_password);
  73. }
  74. FST_TEST_END()
  75. }
  76. FST_SUITE_END()
  77. }
  78. FST_CORE_END()