private_exe.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /* Copyright (c) 2015 the Civetweb developers
  2. *
  3. * Permission is hereby granted, free of charge, to any person obtaining a copy
  4. * of this software and associated documentation files (the "Software"), to deal
  5. * in the Software without restriction, including without limitation the rights
  6. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7. * copies of the Software, and to permit persons to whom the Software is
  8. * furnished to do so, subject to the following conditions:
  9. *
  10. * The above copyright notice and this permission notice shall be included in
  11. * all copies or substantial portions of the Software.
  12. *
  13. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  18. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  19. * THE SOFTWARE.
  20. */
  21. /**
  22. * We include the source file so that we have access to the internal private
  23. * static functions.
  24. */
  25. #ifdef _MSC_VER
  26. #define _CRT_SECURE_NO_WARNINGS
  27. #endif
  28. #include "private_exe.h"
  29. /* This is required for "realpath". According to
  30. * http://man7.org/linux/man-pages/man3/realpath.3.html
  31. * defining _XOPEN_SOURCE 600 should be enough, but in
  32. * practice this does not work. */
  33. #ifdef __clang__
  34. #pragma clang diagnostic ignored "-Wimplicit-function-declaration"
  35. #endif
  36. #ifdef GCC
  37. #pragma GCC diagnostic ignored "-Wimplicit-function-declaration"
  38. #endif
  39. #include "../src/main.c"
  40. #include <stdlib.h>
  41. /* This unit test file uses the excellent Check unit testing library.
  42. * The API documentation is available here:
  43. * http://check.sourceforge.net/doc/check_html/index.html
  44. */
  45. START_TEST(test_helper_funcs)
  46. {
  47. const char *psrc = "test str";
  48. char *pdst;
  49. /* test sdup */
  50. pdst = sdup(psrc);
  51. ck_assert(pdst != NULL);
  52. ck_assert_str_eq(pdst, psrc);
  53. ck_assert_ptr_ne(pdst, psrc);
  54. free(pdst);
  55. }
  56. END_TEST
  57. Suite *make_private_exe_suite(void)
  58. {
  59. Suite *const suite = suite_create("EXE");
  60. TCase *const helper_funcs = tcase_create("Helper funcs");
  61. tcase_add_test(helper_funcs, test_helper_funcs);
  62. tcase_set_timeout(helper_funcs, civetweb_min_test_timeout);
  63. suite_add_tcase(suite, helper_funcs);
  64. return suite;
  65. }