1 #include "../test.h"
2 #include "../../src/alloc.h"
3 #include "../../src/action.h"
4 #include "../../src/asfd.h"
5 #include "../../src/async.h"
6 #include "../../src/conf.h"
7 #include "../../src/fsops.h"
8 #include "../../src/iobuf.h"
9 #include "../../src/sbuf.h"
10 #include "../../src/strlist.h"
11 #include "../../src/client/extra_comms.h"
12 #include "../builders/build.h"
13 #include "../builders/build_file.h"
14 #include "../builders/build_asfd_mock.h"
15 
16 #include <sys/utsname.h>
17 
18 static struct ioevent_list reads;
19 static struct ioevent_list writes;
20 
setup_conf(void)21 static struct conf **setup_conf(void)
22 {
23 	struct conf **confs=NULL;
24 	fail_unless((confs=confs_alloc())!=NULL);
25 	fail_unless(!confs_init(confs));
26 	return confs;
27 }
28 
setup_async(void)29 static struct async *setup_async(void)
30 {
31 	struct async *as;
32 	fail_unless((as=async_alloc())!=NULL);
33 	as->init(as, 0 /* estimate */);
34 	return as;
35 }
36 
setup(struct async ** as,struct conf *** confs)37 static void setup(struct async **as, struct conf ***confs)
38 {
39 	if(as) *as=setup_async();
40 	if(confs) *confs=setup_conf();
41 }
42 
tear_down(struct async ** as,struct asfd ** asfd,struct conf *** confs)43 static void tear_down(struct async **as, struct asfd **asfd,
44 	struct conf ***confs)
45 {
46 	async_free(as);
47 	asfd_free(asfd);
48 	asfd_mock_teardown(&reads, &writes);
49 	confs_free(confs);
50 	alloc_check();
51 }
52 
async_rw_simple(struct async * as)53 static int async_rw_simple(struct async *as)
54 {
55 	return as->asfd->read(as->asfd);
56 }
57 
run_test(int expected_ret,enum action action,void setup_callback (struct asfd * asfd,struct conf ** confs),void checks_callback (struct conf ** confs,enum action action,const char * incexc))58 static void run_test(int expected_ret,
59 	enum action action,
60 	void setup_callback(struct asfd *asfd, struct conf **confs),
61 	void checks_callback(struct conf **confs,
62 		enum action action, const char *incexc))
63 {
64         struct async *as;
65         struct asfd *asfd;
66         struct conf **confs;
67 	struct strlist *failover=NULL;
68 	char *incexc=NULL;
69 
70         setup(&as, &confs);
71         asfd=asfd_mock_setup(&reads, &writes);
72 	as->asfd_add(as, asfd);
73 	as->read_write=async_rw_simple;
74 	asfd->as=as;
75 
76 	setup_callback(asfd, confs);
77 
78 	fail_unless(extra_comms_client(
79 		as,
80 		confs,
81 		&action,
82 		failover,
83 		&incexc
84 	)==expected_ret);
85 
86 	if(checks_callback)
87 		checks_callback(confs, action, incexc);
88 
89 	free_w(&incexc);
90 	tear_down(&as, &asfd, &confs);
91 }
92 
setup_write_error(struct asfd * asfd,struct conf ** confs)93 static void setup_write_error(struct asfd *asfd, struct conf **confs)
94 {
95 	int w=0;
96 	asfd_assert_write(asfd, &w, -1, CMD_GEN, "extra_comms_begin");
97 }
98 
setup_read_error(struct asfd * asfd,struct conf ** confs)99 static void setup_read_error(struct asfd *asfd, struct conf **confs)
100 {
101 	int r=0; int w=0;
102 	asfd_assert_write(asfd, &w, 0, CMD_GEN, "extra_comms_begin");
103 	asfd_mock_read(asfd, &r, -1, CMD_GEN, "extra_comms_begin ok");
104 }
105 
setup_read_unexpected(struct asfd * asfd,struct conf ** confs)106 static void setup_read_unexpected(struct asfd *asfd, struct conf **confs)
107 {
108 	int r=0; int w=0;
109 	asfd_assert_write(asfd, &w, 0, CMD_GEN, "extra_comms_begin");
110 	asfd_mock_read(asfd, &r, 0, CMD_GEN, "extra_comms_begin blah");
111 }
112 
setup_extra_comms_begin(struct asfd * asfd,int * r,int * w,const char * feat)113 static void setup_extra_comms_begin(struct asfd *asfd,
114 	int *r, int *w, const char *feat)
115 {
116 	char msg[64];
117 	asfd_assert_write(asfd, w, 0, CMD_GEN, "extra_comms_begin");
118 	snprintf(msg, sizeof(msg), "extra_comms_begin ok:%s:", feat);
119 	asfd_mock_read(asfd, r, 0, CMD_GEN, msg);
120 }
121 
setup_extra_comms_end(struct asfd * asfd,int * r,int * w)122 static void setup_extra_comms_end(struct asfd *asfd, int *r, int *w)
123 {
124 	asfd_assert_write(asfd, w, 0, CMD_GEN, "extra_comms_end");
125 	asfd_mock_read(asfd, r, 0, CMD_GEN, "extra_comms_end ok");
126 }
127 
setup_end_unexpected(struct asfd * asfd,struct conf ** confs)128 static void setup_end_unexpected(struct asfd *asfd, struct conf **confs)
129 {
130 	int r=0; int w=0;
131 	setup_extra_comms_begin(asfd, &r, &w, "");
132 	asfd_assert_write(asfd, &w, 0, CMD_GEN, "extra_comms_end");
133 	asfd_mock_read(asfd, &r, 0, CMD_GEN, "extra_comms_end blah");
134 }
135 
setup_autoupgrade(struct asfd * asfd,struct conf ** confs)136 static void setup_autoupgrade(struct asfd *asfd, struct conf **confs)
137 {
138 	int r=0; int w=0;
139 	fail_unless(!set_string(confs[OPT_AUTOUPGRADE_DIR], "blah"));
140 	fail_unless(!set_string(confs[OPT_AUTOUPGRADE_OS], "os"));
141 	setup_extra_comms_begin(asfd, &r, &w, "autoupgrade");
142 	// Return an error from the autoupgrade code.
143 	asfd_assert_write(asfd, &w, -1, CMD_GEN, "autoupgrade:os");
144 }
145 
setup_happy_path_simple(struct asfd * asfd,struct conf ** confs)146 static void setup_happy_path_simple(struct asfd *asfd,
147 	struct conf **confs)
148 {
149 	int r=0; int w=0;
150 	setup_extra_comms_begin(asfd, &r, &w, "");
151 	setup_extra_comms_end(asfd, &r, &w);
152 }
153 
setup_srestore_action_monitor(struct asfd * asfd,struct conf ** confs)154 static void setup_srestore_action_monitor(struct asfd *asfd,
155 	struct conf **confs)
156 {
157 	int r=0; int w=0;
158 	setup_extra_comms_begin(asfd, &r, &w, "srestore");
159 	setup_extra_comms_end(asfd, &r, &w);
160 }
161 
setup_srestore_denied(struct asfd * asfd,struct conf ** confs)162 static void setup_srestore_denied(struct asfd *asfd, struct conf **confs)
163 {
164 	int r=0; int w=0;
165 	set_int(confs[OPT_SERVER_CAN_RESTORE], 0);
166 	setup_extra_comms_begin(asfd, &r, &w, "srestore");
167 	asfd_assert_write(asfd, &w, 0, CMD_GEN, "srestore not ok");
168 	setup_extra_comms_end(asfd, &r, &w);
169 }
170 
171 // Neither client or server provide a restoreprefix
setup_srestore_no_restoreprefix1(struct asfd * asfd,struct conf ** confs)172 static void setup_srestore_no_restoreprefix1(
173 	struct asfd *asfd, struct conf **confs)
174 {
175 	int r=0; int w=0;
176 	set_int(confs[OPT_SERVER_CAN_RESTORE], 1);
177 	setup_extra_comms_begin(asfd, &r, &w, "srestore");
178 	asfd_assert_write(asfd, &w, 0, CMD_GEN, "srestore ok");
179 
180 	asfd_mock_read(asfd, &r, 0, CMD_GEN, "backup = 20");
181 	asfd_mock_read(asfd, &r, 0, CMD_GEN, "srestore end");
182 	asfd_assert_write(asfd, &w, 0, CMD_GEN, "srestore end ok");
183 }
184 
185 // Server provides a restoreprefix, but the client does not.
setup_srestore_no_restoreprefix2(struct asfd * asfd,struct conf ** confs)186 static void setup_srestore_no_restoreprefix2(
187 	struct asfd *asfd, struct conf **confs)
188 {
189 	int r=0; int w=0;
190 	set_int(confs[OPT_SERVER_CAN_RESTORE], 1);
191 	setup_extra_comms_begin(asfd, &r, &w, "srestore");
192 	asfd_assert_write(asfd, &w, 0, CMD_GEN, "srestore ok");
193 
194 	asfd_mock_read(asfd, &r, 0, CMD_GEN, "backup = 20");
195 	asfd_mock_read(asfd, &r, 0, CMD_GEN, "restoreprefix = /tmp");
196 	asfd_mock_read(asfd, &r, 0, CMD_GEN, "srestore end");
197 	asfd_assert_write(asfd, &w, 0, CMD_GEN, "srestore end ok");
198 }
199 
setup_srestore(struct asfd * asfd,struct conf ** confs)200 static void setup_srestore(struct asfd *asfd, struct conf **confs)
201 {
202 	int r=0; int w=0;
203 	set_int(confs[OPT_SERVER_CAN_RESTORE], 1);
204 	set_string(confs[OPT_RESTOREPREFIX], "/tmp");
205 	setup_extra_comms_begin(asfd, &r, &w, "srestore");
206 	asfd_assert_write(asfd, &w, 0, CMD_GEN, "srestore ok");
207 
208 	asfd_mock_read(asfd, &r, 0, CMD_GEN, "backup = 20");
209 	asfd_mock_read(asfd, &r, 0, CMD_GEN, "include = /blah1");
210 	asfd_mock_read(asfd, &r, 0, CMD_GEN, "include = /blah2");
211 	asfd_mock_read(asfd, &r, 0, CMD_GEN, "srestore end");
212 	asfd_assert_write(asfd, &w, 0, CMD_GEN, "srestore end ok");
213 
214 	setup_extra_comms_end(asfd, &r, &w);
215 }
216 
check_srestore(struct conf ** confs,enum action action,const char * incexc)217 static void check_srestore(struct conf **confs,
218 	enum action action, const char *incexc)
219 {
220 	struct strlist *s;
221 	fail_unless(!strcmp(incexc,
222 		"backup = 20\ninclude = /blah1\ninclude = /blah2\n\n"));
223 	s=get_strlist(confs[OPT_INCLUDE]);
224 	fail_unless(!strcmp(s->path, "/blah1"));
225 	fail_unless(!strcmp(s->next->path, "/blah2"));
226 	fail_unless(s->next->next==NULL);
227 	fail_unless(!strcmp(get_string(confs[OPT_BACKUP]), "20"));
228 	fail_unless(action==ACTION_RESTORE);
229 	fail_unless(get_string(confs[OPT_ORIG_CLIENT])==NULL);
230 }
231 
setup_srestore_orig_client(struct asfd * asfd,struct conf ** confs)232 static void setup_srestore_orig_client(struct asfd *asfd, struct conf **confs)
233 {
234 	int r=0; int w=0;
235 	set_int(confs[OPT_SERVER_CAN_RESTORE], 1);
236 	set_string(confs[OPT_RESTOREPREFIX], "/tmp");
237 	setup_extra_comms_begin(asfd, &r, &w, "srestore:orig_client");
238 	asfd_assert_write(asfd, &w, 0, CMD_GEN, "srestore ok");
239 
240 	asfd_mock_read(asfd, &r, 0, CMD_GEN, "backup = 10");
241 	asfd_mock_read(asfd, &r, 0, CMD_GEN, "include = /blah1");
242 	asfd_mock_read(asfd, &r, 0, CMD_GEN, "orig_client = altclient");
243 	asfd_mock_read(asfd, &r, 0, CMD_GEN, "srestore end");
244 	asfd_assert_write(asfd, &w, 0, CMD_GEN, "srestore end ok");
245 	asfd_assert_write(asfd, &w, 0, CMD_GEN, "orig_client=altclient");
246 	asfd_mock_read(asfd, &r, 0, CMD_GEN, "orig_client ok");
247 
248 	setup_extra_comms_end(asfd, &r, &w);
249 }
250 
check_srestore_orig_client(struct conf ** confs,enum action action,const char * incexc)251 static void check_srestore_orig_client(struct conf **confs,
252 	enum action action, const char *incexc)
253 {
254 	fail_unless(!strcmp(incexc, "backup = 10\ninclude = /blah1\norig_client = altclient\n\n"));
255 	fail_unless(!strcmp(get_string(confs[OPT_BACKUP]), "10"));
256 	fail_unless(action==ACTION_RESTORE);
257 	fail_unless(!strcmp(get_string(confs[OPT_ORIG_CLIENT]), "altclient"));
258 }
259 
setup_switch_client_denied(struct asfd * asfd,struct conf ** confs)260 static void setup_switch_client_denied(struct asfd *asfd, struct conf **confs)
261 {
262 	int r=0; int w=0;
263 	fail_unless(!set_string(confs[OPT_CNAME], "testclient"));
264 	fail_unless(!set_string(confs[OPT_ORIG_CLIENT], "abc"));
265 	setup_extra_comms_begin(asfd, &r, &w, "");
266 }
267 
setup_switch_client(struct asfd * asfd,struct conf ** confs)268 static void setup_switch_client(struct asfd *asfd, struct conf **confs)
269 {
270 	int r=0; int w=0;
271 	fail_unless(!set_string(confs[OPT_CNAME], "testclient"));
272 	fail_unless(!set_string(confs[OPT_ORIG_CLIENT], "abc"));
273 	setup_extra_comms_begin(asfd, &r, &w, "orig_client");
274 	asfd_assert_write(asfd, &w, 0, CMD_GEN, "orig_client=abc");
275 	asfd_mock_read(asfd, &r, 0, CMD_GEN, "orig_client ok");
276 	setup_extra_comms_end(asfd, &r, &w);
277 }
278 
setup_switch_client_read_unexpected(struct asfd * asfd,struct conf ** confs)279 static void setup_switch_client_read_unexpected(struct asfd *asfd,
280 	struct conf **confs)
281 {
282 	int r=0; int w=0;
283 	fail_unless(!set_string(confs[OPT_CNAME], "testclient"));
284 	fail_unless(!set_string(confs[OPT_ORIG_CLIENT], "abc"));
285 	setup_extra_comms_begin(asfd, &r, &w, "orig_client");
286 	asfd_assert_write(asfd, &w, 0, CMD_GEN, "orig_client=abc");
287 	asfd_mock_read(asfd, &r, 0, CMD_GEN, "orig_client blah");
288 }
289 
setup_sincexc_denied(struct asfd * asfd,struct conf ** confs)290 static void setup_sincexc_denied(struct asfd *asfd, struct conf **confs)
291 {
292 	int r=0; int w=0;
293 	set_int(confs[OPT_SERVER_CAN_OVERRIDE_INCLUDES], 0);
294 	setup_extra_comms_begin(asfd, &r, &w, "sincexc");
295 	setup_extra_comms_end(asfd, &r, &w);
296 }
297 
check_sincexc(struct conf ** confs,enum action action,const char * incexc)298 static void check_sincexc(struct conf **confs,
299 	enum action action, const char *incexc)
300 {
301 	struct strlist *s;
302 	fail_unless(!strcmp(incexc,
303 		"include = /blah1\ninclude = /blah2\n\n"));
304 	s=get_strlist(confs[OPT_INCLUDE]);
305 	fail_unless(!strcmp(s->path, "/blah1"));
306 	fail_unless(!strcmp(s->next->path, "/blah2"));
307 	fail_unless(s->next->next==NULL);
308 	fail_unless(action==ACTION_BACKUP);
309 }
310 
setup_sincexc(struct asfd * asfd,struct conf ** confs)311 static void setup_sincexc(struct asfd *asfd, struct conf **confs)
312 {
313 	int r=0; int w=0;
314 	setup_extra_comms_begin(asfd, &r, &w, "sincexc");
315 	set_int(confs[OPT_SERVER_CAN_OVERRIDE_INCLUDES], 1);
316 	asfd_assert_write(asfd, &w, 0, CMD_GEN, "sincexc ok");
317 	asfd_mock_read(asfd, &r, 0, CMD_GEN, "include = /blah1");
318 	asfd_mock_read(asfd, &r, 0, CMD_GEN, "include = /blah2");
319 	asfd_mock_read(asfd, &r, 0, CMD_GEN, "sincexc end");
320 	asfd_assert_write(asfd, &w, 0, CMD_GEN, "sincexc end ok");
321 	setup_extra_comms_end(asfd, &r, &w);
322 }
323 
check_counters(struct conf ** confs,enum action action,const char * incexc)324 static void check_counters(struct conf **confs,
325 	enum action action, const char *incexc)
326 {
327 	fail_unless(get_int(confs[OPT_SEND_CLIENT_CNTR])==1);
328 }
329 
setup_counters(struct asfd * asfd,struct conf ** confs)330 static void setup_counters(struct asfd *asfd, struct conf **confs)
331 {
332 	int r=0; int w=0;
333 	setup_extra_comms_begin(asfd, &r, &w, "counters_json");
334 	asfd_assert_write(asfd, &w, 0, CMD_GEN, "counters_json ok");
335 	setup_extra_comms_end(asfd, &r, &w);
336 }
337 
setup_uname(struct asfd * asfd,struct conf ** confs)338 static void setup_uname(struct asfd *asfd, struct conf **confs)
339 {
340 	char msg[512]="";
341 	int r=0; int w=0;
342 	struct utsname utsname;
343 	fail_unless(!uname(&utsname));
344 	snprintf(msg, sizeof(msg), "uname=%s", utsname.sysname);
345 	setup_extra_comms_begin(asfd, &r, &w, "uname");
346 	asfd_assert_write(asfd, &w, 0, CMD_GEN, msg);
347 	setup_extra_comms_end(asfd, &r, &w);
348 }
349 
setup_csetproto(struct asfd * asfd,struct conf ** confs,enum protocol current_proto,enum protocol send_proto)350 static void setup_csetproto(struct asfd *asfd, struct conf **confs,
351 	enum protocol current_proto, enum protocol send_proto)
352 {
353 	char msg[64];
354 	int r=0; int w=0;
355 	set_protocol(confs, current_proto);
356 	snprintf(msg, sizeof(msg), "protocol=%d", (int)send_proto);
357 	setup_extra_comms_begin(asfd, &r, &w, "csetproto");
358 	asfd_assert_write(asfd, &w, 0, CMD_GEN, msg);
359 	setup_extra_comms_end(asfd, &r, &w);
360 }
361 
setup_csetproto_auto(struct asfd * asfd,struct conf ** confs)362 static void setup_csetproto_auto(struct asfd *asfd, struct conf **confs)
363 {
364 	setup_csetproto(asfd, confs, PROTO_AUTO, PROTO_1);
365 }
366 
setup_csetproto_proto1(struct asfd * asfd,struct conf ** confs)367 static void setup_csetproto_proto1(struct asfd *asfd, struct conf **confs)
368 {
369 	setup_csetproto(asfd, confs, PROTO_1, PROTO_1);
370 }
371 
setup_csetproto_proto2(struct asfd * asfd,struct conf ** confs)372 static void setup_csetproto_proto2(struct asfd *asfd, struct conf **confs)
373 {
374 	setup_csetproto(asfd, confs, PROTO_2, PROTO_2);
375 }
376 
check_proto1(struct conf ** confs,enum action action,const char * incexc)377 static void check_proto1(struct conf **confs,
378 	enum action action, const char *incexc)
379 {
380 	fail_unless(get_protocol(confs)==PROTO_1);
381 }
382 
check_proto2(struct conf ** confs,enum action action,const char * incexc)383 static void check_proto2(struct conf **confs,
384 	enum action action, const char *incexc)
385 {
386 	fail_unless(get_protocol(confs)==PROTO_2);
387 }
388 
setup_forceproto1(struct asfd * asfd,struct conf ** confs)389 static void setup_forceproto1(struct asfd *asfd, struct conf **confs)
390 {
391 	int r=0; int w=0;
392 	set_protocol(confs, PROTO_1);
393 	setup_extra_comms_begin(asfd, &r, &w, "forceproto=1");
394 	setup_extra_comms_end(asfd, &r, &w);
395 }
396 
setup_forceproto1_proto2(struct asfd * asfd,struct conf ** confs)397 static void setup_forceproto1_proto2(struct asfd *asfd, struct conf **confs)
398 {
399 	int r=0; int w=0;
400 	set_protocol(confs, PROTO_2);
401 	setup_extra_comms_begin(asfd, &r, &w, "forceproto=1");
402 }
403 
setup_forceproto2(struct asfd * asfd,struct conf ** confs)404 static void setup_forceproto2(struct asfd *asfd, struct conf **confs)
405 {
406 	int r=0; int w=0;
407 	set_protocol(confs, PROTO_2);
408 	setup_extra_comms_begin(asfd, &r, &w, "forceproto=2");
409 	setup_extra_comms_end(asfd, &r, &w);
410 }
411 
setup_forceproto2_proto1(struct asfd * asfd,struct conf ** confs)412 static void setup_forceproto2_proto1(struct asfd *asfd, struct conf **confs)
413 {
414 	int r=0; int w=0;
415 	set_protocol(confs, PROTO_1);
416 	setup_extra_comms_begin(asfd, &r, &w, "forceproto=2");
417 }
418 
check_msg(struct conf ** confs,enum action action,const char * incexc)419 static void check_msg(struct conf **confs,
420 	enum action action, const char *incexc)
421 {
422 	fail_unless(get_int(confs[OPT_MESSAGE])==1);
423 }
424 
setup_msg(struct asfd * asfd,struct conf ** confs)425 static void setup_msg(struct asfd *asfd, struct conf **confs)
426 {
427 	int r=0; int w=0;
428 	setup_extra_comms_begin(asfd, &r, &w, "msg");
429 	asfd_assert_write(asfd, &w, 0, CMD_GEN, "msg");
430 	setup_extra_comms_end(asfd, &r, &w);
431 }
432 
check_rshash(struct conf ** confs,enum action action,const char * incexc)433 static void check_rshash(struct conf **confs,
434 	enum action action, const char *incexc)
435 {
436 	fail_unless(get_e_rshash(confs[OPT_RSHASH])==
437 #ifdef HAVE_BLAKE2
438 		RSHASH_BLAKE2
439 #else
440 		RSHASH_MD4
441 #endif
442 	);
443 }
444 
setup_rshash(struct asfd * asfd,struct conf ** confs)445 static void setup_rshash(struct asfd *asfd, struct conf **confs)
446 {
447 	int r=0; int w=0;
448 	setup_extra_comms_begin(asfd, &r, &w, "rshash=blake2");
449 #ifdef HAVE_BLAKE2
450 	asfd_assert_write(asfd, &w, 0, CMD_GEN, "rshash=blake2");
451 #endif
452 	setup_extra_comms_end(asfd, &r, &w);
453 }
454 
START_TEST(test_client_extra_comms)455 START_TEST(test_client_extra_comms)
456 {
457 	run_test(-1, ACTION_BACKUP, setup_write_error, NULL);
458 	run_test(-1, ACTION_BACKUP, setup_read_error, NULL);
459 	run_test(-1, ACTION_BACKUP, setup_read_unexpected, NULL);
460 	run_test(-1, ACTION_BACKUP, setup_autoupgrade, NULL);
461 	run_test(0,  ACTION_BACKUP, setup_happy_path_simple, NULL);
462 	run_test(-1, ACTION_BACKUP, setup_end_unexpected, NULL);
463 	run_test(0,  ACTION_BACKUP, setup_srestore_denied, NULL);
464 	run_test(0,  ACTION_MONITOR,setup_srestore_action_monitor, NULL);
465 	run_test(0,  ACTION_BACKUP, setup_srestore, check_srestore);
466 	run_test(-1,  ACTION_BACKUP, setup_srestore_no_restoreprefix1, NULL);
467 	run_test(-1,  ACTION_BACKUP, setup_srestore_no_restoreprefix2, NULL);
468 	run_test(0,  ACTION_BACKUP,
469 		setup_srestore_orig_client, check_srestore_orig_client);
470 	run_test(-1, ACTION_BACKUP, setup_switch_client_denied, NULL);
471 	run_test(0,  ACTION_BACKUP, setup_switch_client, NULL);
472 	run_test(-1, ACTION_BACKUP, setup_switch_client_read_unexpected, NULL);
473 	run_test(0,  ACTION_BACKUP, setup_sincexc_denied, NULL);
474 	run_test(0,  ACTION_BACKUP, setup_sincexc, check_sincexc);
475 	run_test(0,  ACTION_BACKUP, setup_counters, check_counters);
476 	run_test(0,  ACTION_BACKUP, setup_uname, NULL);
477 	run_test(0,  ACTION_BACKUP, setup_csetproto_auto, check_proto1);
478 	run_test(0,  ACTION_BACKUP, setup_csetproto_proto1, check_proto1);
479 	run_test(0,  ACTION_BACKUP, setup_csetproto_proto2, check_proto2);
480 	run_test(0,  ACTION_BACKUP, setup_forceproto1, check_proto1);
481 	run_test(-1, ACTION_BACKUP, setup_forceproto1_proto2, NULL);
482 	run_test(0,  ACTION_BACKUP, setup_forceproto2, check_proto2);
483 	run_test(-1, ACTION_BACKUP, setup_forceproto2_proto1, NULL);
484 	run_test(0,  ACTION_BACKUP, setup_msg, check_msg);
485 	run_test(0,  ACTION_BACKUP, setup_rshash, check_rshash);
486 }
487 END_TEST
488 
suite_client_extra_comms(void)489 Suite *suite_client_extra_comms(void)
490 {
491 	Suite *s;
492 	TCase *tc_core;
493 
494 	s=suite_create("client_extra_comms");
495 
496 	tc_core=tcase_create("Core");
497 	tcase_set_timeout(tc_core, 60);
498 
499 	tcase_add_test(tc_core, test_client_extra_comms);
500 
501 	suite_add_tcase(s, tc_core);
502 
503 	return s;
504 }
505