1 static const char *
fixture_path(const char * base,const char * fixture_name)2 fixture_path(const char *base, const char *fixture_name)
3 {
4 	static char _path[4096];
5 	size_t root_len;
6 
7 	root_len = strlen(base);
8 	strncpy(_path, base, sizeof(_path));
9 
10 	if (_path[root_len - 1] != '/')
11 		_path[root_len++] = '/';
12 
13 	if (fixture_name[0] == '/')
14 		fixture_name++;
15 
16 	strncpy(_path + root_len,
17 		fixture_name,
18 		sizeof(_path) - root_len);
19 
20 	return _path;
21 }
22 
23 #ifdef CLAR_FIXTURE_PATH
cl_fixture(const char * fixture_name)24 const char *cl_fixture(const char *fixture_name)
25 {
26 	return fixture_path(CLAR_FIXTURE_PATH, fixture_name);
27 }
28 
cl_fixture_sandbox(const char * fixture_name)29 void cl_fixture_sandbox(const char *fixture_name)
30 {
31 	fs_copy(cl_fixture(fixture_name), _clar_path);
32 }
33 
cl_fixture_cleanup(const char * fixture_name)34 void cl_fixture_cleanup(const char *fixture_name)
35 {
36 	fs_rm(fixture_path(_clar_path, fixture_name));
37 }
38 #endif
39