1 #ifndef __DYLD_TEST_SUPPORT_H__
2 #define __DYLD_TEST_SUPPORT_H__ 1
6 #endif /* __cplusplus */
10 #include <mach/machine.h>
11 #include <dispatch/dispatch.h>
16 // Only allow this interface for Objective-C++ due to typename and ARC issues in the default constructor
18 typedef void (^_dyld_test_reader_t
)(int fd
);
19 typedef void (^_dyld_test_exit_handler_t
)(pid_t pid
);
20 typedef void (^_dyld_test_crash_handler_t
)(task_t task
);
25 void set_executable_path(const char* EP
);
26 void set_args(const char** A
);
27 void set_env(const char** E
);
28 void set_stdout_handler(_dyld_test_reader_t SOH
);
29 void set_stderr_handler(_dyld_test_reader_t SEH
);
30 void set_exit_handler(_dyld_test_exit_handler_t EH
);
31 void set_crash_handler(_dyld_test_crash_handler_t CH
);
32 void set_launch_suspended(bool S
);
33 void set_launch_async(bool S
);
34 void set_launch_arch(cpu_type_t A
);
36 void *operator new(size_t size
);
37 void operator delete(void *ptr
);
39 const char* executablePath
;
42 _dyld_test_reader_t stdoutHandler
;
43 _dyld_test_reader_t stderrHandler
;
44 _dyld_test_crash_handler_t crashHandler
;
45 _dyld_test_exit_handler_t exitHandler
;
52 #define STDERR_WRITER ^(int fd) { \
56 size = read(fd, &buffer[0], 16384); \
58 fprintf(stderr, "%s", &buffer[0]); \
62 #define STDOUT_WRITER ^(int fd) { \
66 size = read(fd, &buffer[0], 16384); \
68 fprintf(stdout, "%s", &buffer[0]); \
72 #endif /* __cplusplus */
74 #define PASS(...) _PASS(__FILE__,__LINE__,__VA_ARGS__)
75 #define FAIL(...) _FAIL(__FILE__,__LINE__,__VA_ARGS__)
76 #define LOG(...) _LOG(__FILE__,__LINE__,__VA_ARGS__)
77 #define TIMEOUT(seconds) _TIMEOUT(__FILE__,__LINE__,seconds)
79 // MARK: Private implementation details
83 #endif /* __cplusplus */
84 __attribute__((format(printf
, 3, 4)))
85 __attribute__ ((noreturn
))
86 extern void _PASS(const char* file
, unsigned line
, const char* format
, ...);
88 __attribute__((format(printf
, 3, 4)))
89 __attribute__ ((noreturn
))
90 extern void _FAIL(const char* file
, unsigned line
, const char* format
, ...);
92 __attribute__((format(printf
, 3, 4)))
93 extern void _LOG(const char* file
, unsigned line
, const char* format
, ...);
95 extern void _TIMEOUT(const char* file
, unsigned line
, uint64_t seconds
);
98 #endif /* __cplusplus */
100 #endif /* __DYLD_TEST_SUPPORT_H__ */