dispatch_test.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * Copyright (c) 2008-2011 Apple Inc. All rights reserved.
  3. *
  4. * @APPLE_APACHE_LICENSE_HEADER_START@
  5. *
  6. * Licensed under the Apache License, Version 2.0 (the "License");
  7. * you may not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. *
  18. * @APPLE_APACHE_LICENSE_HEADER_END@
  19. */
  20. #include <stdbool.h>
  21. #include <dispatch/dispatch.h>
  22. #if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__)
  23. #include <generic_unix_port.h>
  24. #elif defined(_WIN32)
  25. #include <generic_win_port.h>
  26. #endif
  27. #define test_group_wait(g) do { \
  28. if (dispatch_group_wait(g, dispatch_time(DISPATCH_TIME_NOW, \
  29. 25ull * NSEC_PER_SEC))) { \
  30. test_long("group wait timed out", 1, 0); \
  31. test_stop(); \
  32. } } while (0)
  33. #if defined(__cplusplus)
  34. extern "C" {
  35. #endif
  36. void dispatch_test_start(const char* desc);
  37. bool dispatch_test_check_evfilt_read_for_fd(dispatch_fd_t fd);
  38. char *dispatch_test_get_large_file(void);
  39. void dispatch_test_release_large_file(const char *path);
  40. void _dispatch_test_current(const char* file, long line, const char* desc, dispatch_queue_t expected);
  41. #define dispatch_test_current(a,b) _dispatch_test_current(__SOURCE_FILE__, __LINE__, a, b)
  42. #if __APPLE__
  43. int sysctlbyname(const char *name, void *oldp, size_t *oldlenp, void *newp,
  44. size_t *newpl);
  45. #endif
  46. dispatch_fd_t dispatch_test_fd_open(const char *path, int flags);
  47. int dispatch_test_fd_close(dispatch_fd_t fd);
  48. off_t dispatch_test_fd_lseek(dispatch_fd_t fd, off_t offset, int whence);
  49. ssize_t dispatch_test_fd_pread(dispatch_fd_t fd, void *buf, size_t count, off_t offset);
  50. ssize_t dispatch_test_fd_read(dispatch_fd_t fd, void *buf, size_t count);
  51. ssize_t dispatch_test_fd_write(dispatch_fd_t fd, const void *buf, size_t count);
  52. #if defined(__cplusplus)
  53. } /* extern "C" */
  54. #endif