1 #include <stdint.h> 2 #include <unistd.h> 3 4 #ifdef __cplusplus 5 extern "C" { 6 #endif 7 8 /* TODO: not thread-safe nor fork-safe */ 9 extern volatile int t_status; 10 11 #define T_LOC2(l) __FILE__ ":" #l 12 #define T_LOC1(l) T_LOC2(l) 13 #define t_error(...) t_printf(T_LOC1(__LINE__) ": " __VA_ARGS__) 14 15 int t_printf(const char *s, ...); 16 17 int t_vmfill(void **, size_t *, int); 18 int t_memfill(void); 19 20 void t_fdfill(void); 21 22 void t_randseed(uint64_t s); 23 uint64_t t_randn(uint64_t n); 24 uint64_t t_randint(uint64_t a, uint64_t b); 25 void t_shuffle(uint64_t *p, size_t n); 26 void t_randrange(uint64_t *p, size_t n); 27 int t_choose(uint64_t n, size_t k, uint64_t *p); 28 29 char *t_pathrel(char *buf, size_t n, char *argv0, char *p); 30 31 int t_setrlim(int r, long lim); 32 33 int t_setutf8(void); 34 35 void check_log(const char *file, const char *pattern); 36 void clear_log(const char *log_dir, const char *file_tag); 37 // Use the file_tag to match all the files in log_dir, and then check if the file contain pattern. 38 void find_and_check_file(const char *log_dir, const char *file_tag, const char *pattern); 39 40 #ifndef __arm__ 41 #define __clock_gettime64 clock_gettime 42 #define __pthread_cond_timedwait_time64 pthread_cond_timedwait 43 #define __nanosleep_time64 nanosleep 44 #define __fstat_time64 fstat 45 #define __lstat_time64 lstat 46 #define __stat_time64 stat 47 #define __utimensat_time64 utimensat 48 #define __adjtimex_time64 adjtimex 49 #define __clock_adjtime64 clock_adjtime 50 #define __clock_getres_time64 clock_getres 51 #define __clock_nanosleep_time64 clock_nanosleep 52 #define __clock_settime64 clock_settime 53 #define __cnd_timedwait_time64 cnd_timedwait 54 #define __ctime64 ctime 55 #define __ctime64_r ctime_r 56 #define __difftime64 difftime 57 #define __dlsym_time64 dlsym 58 #define __fstatat_time64 fstatat 59 #define __futimens_time64 futimens 60 #define __futimes_time64 futimes 61 #define __futimesat_time64 futimesat 62 #define __getitimer_time64 getitimer 63 #define __getrusage_time64 getrusage 64 #define __gettimeofday_time64 gettimeofday 65 #define __gmtime64 gmtime 66 #define __gmtime64_r gmtime_r 67 #define __localtime64 localtime 68 #define __localtime64_r localtime_r 69 #define __lutimes_time64 lutimes 70 #define __mktime64 mktime 71 #define __mtx_timedlock_time64 mtx_timedlock 72 #define __ppoll_time64 ppoll 73 #define __pselect_time64 pselect 74 #define __pthread_mutex_timedlock_time64 pthread_mutex_timedlock 75 #define __pthread_rwlock_timedrdlock_time64 pthread_rwlock_timedrdlock 76 #define __pthread_rwlock_timedwrlock_time64 pthread_rwlock_timedwrlock 77 #define __recvmmsg_time64 recvmmsg 78 #define __sched_rr_get_interval_time64 sched_rr_get_interval 79 #define __select_time64 select 80 #define __sem_timedwait_time64 sem_timedwait 81 #define __semtimedop_time64 semtimedop 82 #define __setitimer_time64 setitimer 83 #define __settimeofday_time64 settimeofday 84 #define __sigtimedwait_time64 sigtimedwait 85 #define __thrd_sleep_time64 thrd_sleep 86 #define __time64 time 87 #define __timegm_time64 timegm 88 #define __timer_gettime64 timer_gettime 89 #define __timer_settime64 timer_settime 90 #define __timerfd_gettime64 timerfd_gettime 91 #define __timerfd_settime64 timerfd_settime 92 #define __timespec_get_time64 timespec_get 93 #define __utime64 utime 94 #define __utimes_time64 utimes 95 #define __wait4_time64 wait4 96 #endif 97 98 #define TEST_MODE 0666 99 100 #ifdef __cplusplus 101 } 102 #endif 103