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