1 #ifndef __UTEST_H
2 #define __UTEST_H
3 
4 #include "../src/burp.h"
5 #include "../src/conf.h"
6 #include <check.h>
7 
8 #define ARR_LEN(array) (sizeof((array))/sizeof((array)[0]))
9 #define FOREACH(array) for(unsigned int i=0; i<ARR_LEN(array); i++)
10 
11 #define MIN_SERVER_CONF_NO_LISTEN		\
12 	"mode=server\n"				\
13 	"lockfile=/lockfile/path\n"		\
14 	"ssl_cert=/ssl/cert/path\n"		\
15 	"ssl_cert_ca=/cert_ca/path\n"		\
16 	"directory=/a/directory\n"		\
17 	"dedup_group=a_group\n"			\
18 	"clientconfdir=clientconfdir\n"		\
19 	"ssl_dhfile=/a/dhfile\n"		\
20 	"keep=10\n"				\
21 
22 #define MIN_SERVER_CONF				\
23 	MIN_SERVER_CONF_NO_LISTEN		\
24 	"listen=0.0.0.0:1234\n"			\
25 	"listen_status=0.0.0.0:12345\n"		\
26 
27 #define MIN_CLIENT_CONF_NO_PORTS		\
28 	"mode=client\n"				\
29 	"server=4.5.6.7\n"			\
30 	"lockfile=/lockfile/path\n"		\
31 	"ssl_cert=/ssl/cert/path\n"		\
32 	"ssl_cert_ca=/cert_ca/path\n"		\
33 	"ssl_peer_cn=my_cn\n"			\
34 	"ca_csr_dir=/csr/dir\n"			\
35 	"ssl_key=/ssl/key/path\n"		\
36 
37 #define MIN_CLIENT_CONF				\
38 	MIN_CLIENT_CONF_NO_PORTS		\
39 	"port=1234\n"				\
40 	"status_port=12345\n"			\
41 
42 struct iobuf;
43 struct sbuf;
44 struct sd;
45 struct sdirs;
46 
47 extern int sub_ntests;
48 
49 extern void alloc_check_init(void);
50 extern void alloc_check(void);
51 
52 extern void assert_iobuf(struct iobuf *a, struct iobuf *b);
53 extern void assert_sbuf(struct sbuf *a, struct sbuf *b, enum protocol protocol);
54 extern struct manio *do_manio_open(const char *path, const char *mode,
55 	enum protocol protocol, int phase);
56 extern void assert_bu_list(struct sdirs *sdirs, struct sd *s, unsigned int len);
57 extern void assert_files_equal(const char *opath, const char *npath);
58 extern void assert_files_compressed_equal(const char *opath, const char *npath);
59 extern void assert_xattr(const char *expected,
60 	const char *retrieved, size_t rlen);
61 
62 
63 Suite *suite_alloc(void);
64 Suite *suite_asfd(void);
65 Suite *suite_attribs(void);
66 Suite *suite_base64(void);
67 Suite *suite_client_acl(void);
68 Suite *suite_client_auth(void);
69 Suite *suite_client_delete(void);
70 Suite *suite_client_extra_comms(void);
71 Suite *suite_client_extrameta(void);
72 Suite *suite_client_find(void);
73 Suite *suite_client_monitor(void);
74 Suite *suite_client_monitor_json_input(void);
75 Suite *suite_client_monitor_lline(void);
76 Suite *suite_client_monitor_status_client_ncurses(void);
77 Suite *suite_client_protocol1_backup_phase2(void);
78 Suite *suite_client_protocol2_backup_phase2(void);
79 Suite *suite_client_protocol2_rabin_read(void);
80 Suite *suite_client_restore(void);
81 Suite *suite_client_xattr(void);
82 Suite *suite_cmd(void);
83 Suite *suite_cntr(void);
84 Suite *suite_conf(void);
85 Suite *suite_conffile(void);
86 Suite *suite_fzp(void);
87 Suite *suite_hexmap(void);
88 Suite *suite_lock(void);
89 Suite *suite_pathcmp(void);
90 Suite *suite_protocol1_handy(void);
91 Suite *suite_protocol1_rs_buf(void);
92 Suite *suite_protocol2_blist(void);
93 Suite *suite_protocol2_blk(void);
94 Suite *suite_protocol2_rabin_rabin(void);
95 Suite *suite_protocol2_rabin_rconf(void);
96 Suite *suite_protocol2_rabin_win(void);
97 Suite *suite_protocol2_sbuf_protocol2(void);
98 Suite *suite_server_auth(void);
99 Suite *suite_server_autoupgrade(void);
100 Suite *suite_server_ca(void);
101 Suite *suite_server_backup_phase3(void);
102 Suite *suite_server_bu_get(void);
103 Suite *suite_server_delete(void);
104 Suite *suite_server_extra_comms(void);
105 Suite *suite_server_list(void);
106 Suite *suite_server_manio(void);
107 Suite *suite_server_monitor_browse(void);
108 Suite *suite_server_monitor_cache(void);
109 Suite *suite_server_monitor_cstat(void);
110 Suite *suite_server_monitor_json_output(void);
111 Suite *suite_server_monitor_status_server(void);
112 Suite *suite_server_resume(void);
113 Suite *suite_server_restore(void);
114 Suite *suite_server_run_action(void);
115 Suite *suite_server_sdirs(void);
116 Suite *suite_server_timer(void);
117 Suite *suite_server_protocol1_backup_phase2(void);
118 Suite *suite_server_protocol1_backup_phase4(void);
119 Suite *suite_server_protocol1_bedup(void);
120 Suite *suite_server_protocol1_blocklen(void);
121 Suite *suite_server_protocol1_dpth(void);
122 Suite *suite_server_protocol1_fdirs(void);
123 Suite *suite_server_protocol1_restore(void);
124 Suite *suite_server_protocol2_backup_phase2(void);
125 Suite *suite_server_protocol2_backup_phase4(void);
126 Suite *suite_server_protocol2_bsparse(void);
127 Suite *suite_server_protocol2_champ_chooser_champ_chooser(void);
128 Suite *suite_server_protocol2_champ_chooser_champ_server(void);
129 Suite *suite_server_protocol2_champ_chooser_dindex(void);
130 Suite *suite_server_protocol2_champ_chooser_hash(void);
131 Suite *suite_server_protocol2_champ_chooser_scores(void);
132 Suite *suite_server_protocol2_champ_chooser_sparse(void);
133 Suite *suite_server_protocol2_dpth(void);
134 Suite *suite_slist(void);
135 Suite *suite_times(void);
136 
137 #endif
138