1 #include "../test.h"
2 #include "../../src/alloc.h"
3 #include "../../src/cstat.h"
4 #include "../../src/fsops.h"
5 
6 #include "build.h"
7 #include "build_file.h"
8 
get_clientconfdir_path(const char * file)9 char *get_clientconfdir_path(const char *file)
10 {
11 	static char path[256]="";
12 	snprintf(path, sizeof(path), "%s/%s", CLIENTCONFDIR, file);
13 	return path;
14 }
15 
build_clientconfdir_file(const char * file,const char * content)16 void build_clientconfdir_file(const char *file, const char *content)
17 {
18 	const char *path=get_clientconfdir_path(file);
19 	build_file(path, content);
20 }
21 
delete_clientconfdir_file(const char * file)22 void delete_clientconfdir_file(const char *file)
23 {
24 	const char *path=get_clientconfdir_path(file);
25 	fail_unless(!unlink(path));
26 }
27 
build_clientconfdir_files(const char * cnames[],const char * content)28 void build_clientconfdir_files(const char *cnames[], const char *content)
29 {
30 	int i=0;
31 	for(i=0; cnames[i]; i++)
32 		build_clientconfdir_file(cnames[i], content);
33 }
34 
assert_cstat_list(struct cstat * clist,const char * cnames[])35 void assert_cstat_list(struct cstat *clist, const char *cnames[])
36 {
37 	int i;
38 	struct cstat *c=NULL;
39 	struct cstat *l=NULL;
40 	for(i=0, c=clist; cnames && cnames[i]; c=c->next, i++)
41 	{
42 		ck_assert_str_eq(cnames[i], c->name);
43 		l=c;
44 	}
45 	fail_unless(c==NULL);
46 	for(i--, c=l; i>=0; c=c->prev, i--)
47 		ck_assert_str_eq(cnames[i], c->name);
48 }
49