31ATF_TC(config_include_test);
32ATF_TC_HEAD(config_include_test, tc)
34 atf_tc_set_md_var(tc,
"descr",
"Test including files by file globbing");
37ATF_TC_BODY(config_include_test, tc)
41 char *buf, *buf2, pwd[PATH_MAX];
45 tcsdir = atf_tc_get_config_var(tc,
"srcdir");
47 memset(&xh, 0,
sizeof(xh));
48 buf = getcwd(pwd,
sizeof(pwd));
52 ret = snprintf(xh.confdir,
sizeof(xh.confdir),
"%s/xbps.d", pwd);
53 ATF_REQUIRE_EQ((ret >= 0), 1);
54 ATF_REQUIRE_EQ(((
size_t)ret <
sizeof(xh.confdir)), 1);
60 ATF_REQUIRE_EQ(symlink(buf, buf2), 0);
66 ATF_REQUIRE_EQ(symlink(buf, buf2), 0);
72 ATF_REQUIRE_EQ(symlink(buf, buf2), 0);
76 xh.flags = XBPS_FLAG_DEBUG;
79 ATF_REQUIRE_EQ(xbps_array_count(xh.repositories), 2);
83ATF_TC(config_include_nomatch_test);
84ATF_TC_HEAD(config_include_nomatch_test, tc)
86 atf_tc_set_md_var(tc,
"descr",
"Test finds no files to include");
89ATF_TC_BODY(config_include_nomatch_test, tc)
93 char *buf, *buf2, pwd[PATH_MAX];
97 tcsdir = atf_tc_get_config_var(tc,
"srcdir");
99 memset(&xh, 0,
sizeof(xh));
100 buf = getcwd(pwd,
sizeof(pwd));
104 ret = snprintf(xh.confdir,
sizeof(xh.confdir),
"%s/xbps.d", pwd);
105 ATF_REQUIRE_EQ((ret >= 0), 1);
106 ATF_REQUIRE_EQ(((
size_t)ret <
sizeof(xh.confdir)), 1);
112 ATF_REQUIRE_EQ(symlink(buf, buf2), 0);
116 xh.flags = XBPS_FLAG_DEBUG;
120 ATF_REQUIRE_EQ(xbps_array_count(xh.repositories), 0);
123ATF_TC(config_include_absolute);
124ATF_TC_HEAD(config_include_absolute, tc)
126 atf_tc_set_md_var(tc,
"descr",
"Test including files by absolute path");
129ATF_TC_BODY(config_include_absolute, tc)
133 char *cfg, *buf, *buf2, pwd[PATH_MAX];
137 tcsdir = atf_tc_get_config_var(tc,
"srcdir");
139 memset(&xh, 0,
sizeof(xh));
140 buf = getcwd(pwd,
sizeof(pwd));
144 ret = snprintf(xh.confdir,
sizeof(xh.confdir),
"%s/xbps.d", pwd);
145 ATF_REQUIRE_EQ((ret >= 0), 1);
146 ATF_REQUIRE_EQ(((
size_t)ret <
sizeof(xh.confdir)), 1);
155 ATF_REQUIRE_EQ(symlink(buf, buf2), 0);
161 ATF_REQUIRE_EQ(symlink(buf, buf2), 0);
165 xh.flags = XBPS_FLAG_DEBUG;
168 ATF_REQUIRE_EQ(xbps_array_count(xh.repositories), 1);
171ATF_TC(config_include_absolute_glob);
172ATF_TC_HEAD(config_include_absolute_glob, tc)
174 atf_tc_set_md_var(tc,
"descr",
"Test including files by absolute path with globbing");
177ATF_TC_BODY(config_include_absolute_glob, tc)
181 char *cfg, *buf, *buf2, pwd[PATH_MAX];
185 tcsdir = atf_tc_get_config_var(tc,
"srcdir");
187 memset(&xh, 0,
sizeof(xh));
188 buf = getcwd(pwd,
sizeof(pwd));
192 ret = snprintf(xh.confdir,
sizeof(xh.confdir),
"%s/xbps.d", pwd);
193 ATF_REQUIRE_EQ((ret >= 0), 1);
194 ATF_REQUIRE_EQ(((
size_t)ret <
sizeof(xh.confdir)), 1);
203 ATF_REQUIRE_EQ(symlink(buf, buf2), 0);
209 ATF_REQUIRE_EQ(symlink(buf, buf2), 0);
215 ATF_REQUIRE_EQ(symlink(buf, buf2), 0);
219 xh.flags = XBPS_FLAG_DEBUG;
222 ATF_REQUIRE_EQ(xbps_array_count(xh.repositories), 2);
225ATF_TC(config_masking);
226ATF_TC_HEAD(config_masking, tc)
228 atf_tc_set_md_var(tc,
"descr",
"Test file masking");
231ATF_TC_BODY(config_masking, tc)
234 const char *tcsdir, *repo;
235 char *buf, *buf2, pwd[PATH_MAX];
239 tcsdir = atf_tc_get_config_var(tc,
"srcdir");
241 memset(&xh, 0,
sizeof(xh));
242 buf = getcwd(pwd,
sizeof(pwd));
246 ret = snprintf(xh.confdir,
sizeof(xh.confdir),
"%s/xbps.d", pwd);
247 ATF_REQUIRE_EQ((ret >= 0), 1);
248 ATF_REQUIRE_EQ(((
size_t)ret <
sizeof(xh.confdir)), 1);
249 ret = snprintf(xh.sysconfdir,
sizeof(xh.sysconfdir),
"%s/sys-xbps.d", pwd);
250 ATF_REQUIRE_EQ((ret >= 0), 1);
251 ATF_REQUIRE_EQ(((
size_t)ret <
sizeof(xh.sysconfdir)), 1);
254 ATF_REQUIRE_EQ(
xbps_mkpath(xh.sysconfdir, 0755), 0);
258 ATF_REQUIRE_EQ(symlink(buf, buf2), 0);
264 ATF_REQUIRE_EQ(symlink(buf, buf2), 0);
268 xh.flags = XBPS_FLAG_DEBUG;
272 ATF_REQUIRE_EQ(xbps_array_count(xh.repositories), 1);
275 ATF_REQUIRE_EQ(xbps_array_get_cstring_nocopy(xh.repositories, 0, &repo),
true);
276 ATF_REQUIRE_STREQ(repo,
"1");
279ATF_TC(config_trim_values);
280ATF_TC_HEAD(config_trim_values, tc)
282 atf_tc_set_md_var(tc,
"descr",
"Test trimming of values");
285ATF_TC_BODY(config_trim_values, tc)
288 const char *tcsdir, *repo;
289 char *buf, *buf2, pwd[PATH_MAX];
293 tcsdir = atf_tc_get_config_var(tc,
"srcdir");
295 memset(&xh, 0,
sizeof(xh));
296 buf = getcwd(pwd,
sizeof(pwd));
300 ret = snprintf(xh.confdir,
sizeof(xh.confdir),
"%s/xbps.d", pwd);
301 ATF_REQUIRE_EQ((ret >= 0), 1);
302 ATF_REQUIRE_EQ(((
size_t)ret <
sizeof(xh.confdir)), 1);
303 ret = snprintf(xh.sysconfdir,
sizeof(xh.sysconfdir),
"%s/sys-xbps.d", pwd);
304 ATF_REQUIRE_EQ((ret >= 0), 1);
305 ATF_REQUIRE_EQ(((
size_t)ret <
sizeof(xh.sysconfdir)), 1);
308 ATF_REQUIRE_EQ(
xbps_mkpath(xh.sysconfdir, 0755), 0);
312 ATF_REQUIRE_EQ(symlink(buf, buf2), 0);
316 xh.flags = XBPS_FLAG_DEBUG;
320 ATF_REQUIRE_EQ(xbps_array_count(xh.repositories), 2);
323 ATF_REQUIRE_EQ(xbps_array_get_cstring_nocopy(xh.repositories, 0, &repo),
true);
324 ATF_REQUIRE_STREQ(repo,
"1");
326 ATF_REQUIRE_EQ(xbps_array_get_cstring_nocopy(xh.repositories, 1, &repo),
true);
327 ATF_REQUIRE_STREQ(repo,
"2");
330ATF_TC(config_no_trailing_newline);
331ATF_TC_HEAD(config_no_trailing_newline, tc)
333 atf_tc_set_md_var(tc,
"descr",
"Test configuration files without trailing newline");
336ATF_TC_BODY(config_no_trailing_newline, tc)
339 const char *tcsdir, *repo;
340 char *buf, *buf2, pwd[PATH_MAX];
344 tcsdir = atf_tc_get_config_var(tc,
"srcdir");
346 memset(&xh, 0,
sizeof(xh));
347 buf = getcwd(pwd,
sizeof(pwd));
351 ret = snprintf(xh.confdir,
sizeof(xh.confdir),
"%s/xbps.d", pwd);
352 ATF_REQUIRE_EQ((ret >= 0), 1);
353 ATF_REQUIRE_EQ(((
size_t)ret <
sizeof(xh.confdir)), 1);
354 ret = snprintf(xh.sysconfdir,
sizeof(xh.sysconfdir),
"%s/sys-xbps.d", pwd);
355 ATF_REQUIRE_EQ((ret >= 0), 1);
356 ATF_REQUIRE_EQ(((
size_t)ret <
sizeof(xh.sysconfdir)), 1);
359 ATF_REQUIRE_EQ(
xbps_mkpath(xh.sysconfdir, 0755), 0);
363 ATF_REQUIRE_EQ(symlink(buf, buf2), 0);
367 xh.flags = XBPS_FLAG_DEBUG;
371 ATF_REQUIRE_EQ(xbps_array_count(xh.repositories), 1);
374 ATF_REQUIRE_EQ(xbps_array_get_cstring_nocopy(xh.repositories, 0, &repo),
true);
375 ATF_REQUIRE_STREQ(repo,
"test");
380 ATF_TP_ADD_TC(tp, config_include_test);
381 ATF_TP_ADD_TC(tp, config_include_nomatch_test);
382 ATF_TP_ADD_TC(tp, config_include_absolute);
383 ATF_TP_ADD_TC(tp, config_include_absolute_glob);
384 ATF_TP_ADD_TC(tp, config_masking);
385 ATF_TP_ADD_TC(tp, config_trim_values);
386 ATF_TP_ADD_TC(tp, config_no_trailing_newline);
388 return atf_no_error();
Generic XBPS structure handler for initialization.
void void void void void int xbps_init(struct xbps_handle *xhp)
char * xbps_xasprintf(const char *fmt,...) __attribute__((format(printf
int xbps_mkpath(const char *path, mode_t mode)
size_t xbps_strlcpy(char *dst, const char *src, size_t dstsize)