tests: add test for configuration key/value formatting
Closes: #412 [via git-merge-pr]
This commit is contained in:
parent
248ca4b152
commit
72395cdf80
@ -276,6 +276,57 @@ ATF_TC_BODY(config_masking, tc)
|
||||
ATF_REQUIRE_STREQ(repo, "1");
|
||||
}
|
||||
|
||||
ATF_TC(config_trim_values);
|
||||
ATF_TC_HEAD(config_trim_values, tc)
|
||||
{
|
||||
atf_tc_set_md_var(tc, "descr", "Test trimming of values");
|
||||
}
|
||||
|
||||
ATF_TC_BODY(config_trim_values, tc)
|
||||
{
|
||||
struct xbps_handle xh;
|
||||
const char *tcsdir, *repo;
|
||||
char *buf, *buf2, pwd[PATH_MAX];
|
||||
int ret;
|
||||
|
||||
/* get test source dir */
|
||||
tcsdir = atf_tc_get_config_var(tc, "srcdir");
|
||||
|
||||
memset(&xh, 0, sizeof(xh));
|
||||
buf = getcwd(pwd, sizeof(pwd));
|
||||
|
||||
xbps_strlcpy(xh.rootdir, tcsdir, sizeof(xh.rootdir));
|
||||
xbps_strlcpy(xh.metadir, tcsdir, sizeof(xh.metadir));
|
||||
ret = snprintf(xh.confdir, sizeof(xh.confdir), "%s/xbps.d", pwd);
|
||||
ATF_REQUIRE_EQ((ret >= 0), 1);
|
||||
ATF_REQUIRE_EQ(((size_t)ret < sizeof(xh.confdir)), 1);
|
||||
ret = snprintf(xh.sysconfdir, sizeof(xh.sysconfdir), "%s/sys-xbps.d", pwd);
|
||||
ATF_REQUIRE_EQ((ret >= 0), 1);
|
||||
ATF_REQUIRE_EQ(((size_t)ret < sizeof(xh.sysconfdir)), 1);
|
||||
|
||||
ATF_REQUIRE_EQ(xbps_mkpath(xh.confdir, 0755), 0);
|
||||
ATF_REQUIRE_EQ(xbps_mkpath(xh.sysconfdir, 0755), 0);
|
||||
|
||||
buf = xbps_xasprintf("%s/trim.cf", tcsdir);
|
||||
buf2 = xbps_xasprintf("%s/xbps.d/1.conf", pwd);
|
||||
ATF_REQUIRE_EQ(symlink(buf, buf2), 0);
|
||||
free(buf);
|
||||
free(buf2);
|
||||
|
||||
xh.flags = XBPS_FLAG_DEBUG;
|
||||
ATF_REQUIRE_EQ(xbps_init(&xh), 0);
|
||||
|
||||
/* should contain one repository */
|
||||
ATF_REQUIRE_EQ(xbps_array_count(xh.repositories), 2);
|
||||
|
||||
/* should contain repository=1 */
|
||||
ATF_REQUIRE_EQ(xbps_array_get_cstring_nocopy(xh.repositories, 0, &repo), true);
|
||||
ATF_REQUIRE_STREQ(repo, "1");
|
||||
/* should contain repository=2 */
|
||||
ATF_REQUIRE_EQ(xbps_array_get_cstring_nocopy(xh.repositories, 1, &repo), true);
|
||||
ATF_REQUIRE_STREQ(repo, "2");
|
||||
}
|
||||
|
||||
ATF_TP_ADD_TCS(tp)
|
||||
{
|
||||
ATF_TP_ADD_TC(tp, config_include_test);
|
||||
@ -283,6 +334,7 @@ ATF_TP_ADD_TCS(tp)
|
||||
ATF_TP_ADD_TC(tp, config_include_absolute);
|
||||
ATF_TP_ADD_TC(tp, config_include_absolute_glob);
|
||||
ATF_TP_ADD_TC(tp, config_masking);
|
||||
ATF_TP_ADD_TC(tp, config_trim_values);
|
||||
|
||||
return atf_no_error();
|
||||
}
|
||||
|
2
tests/xbps/libxbps/config/trim.cf
Normal file
2
tests/xbps/libxbps/config/trim.cf
Normal file
@ -0,0 +1,2 @@
|
||||
repository= 1
|
||||
repository =2
|
Loading…
Reference in New Issue
Block a user