Replaced config/system {repo,preserve,virtualpkg}.d with a single directory.
See the NEWS file for more information.
This commit is contained in:
@@ -3,6 +3,6 @@ TOPDIR = ../../../..
|
||||
|
||||
TESTSSUBDIR = xbps/libxbps/config
|
||||
TEST = config_test
|
||||
EXTRA_FILES = Kyuafile xbps.conf xbps_nomatch.conf 1.include.conf 2.include.conf
|
||||
EXTRA_FILES = Kyuafile xbps.cf xbps_nomatch.cf 1.include.cf 2.include.cf
|
||||
|
||||
include $(TOPDIR)/mk/test.mk
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
*/
|
||||
#include <atf-c.h>
|
||||
#include <xbps.h>
|
||||
#include <stdlib.h>
|
||||
#include <limits.h>
|
||||
|
||||
ATF_TC(config_include_test);
|
||||
ATF_TC_HEAD(config_include_test, tc)
|
||||
@@ -36,19 +38,40 @@ ATF_TC_BODY(config_include_test, tc)
|
||||
{
|
||||
struct xbps_handle xh;
|
||||
const char *tcsdir;
|
||||
char *buf, *buf2, pwd[PATH_MAX];
|
||||
|
||||
/* get test source dir */
|
||||
tcsdir = atf_tc_get_config_var(tc, "srcdir");
|
||||
|
||||
/* change dir to make sure relative paths won't match */
|
||||
ATF_REQUIRE_EQ(chdir("/"), 0);
|
||||
memset(&xh, 0, sizeof(xh));
|
||||
strncpy(xh.rootdir, tcsdir, sizeof(xh.rootdir));
|
||||
strncpy(xh.metadir, tcsdir, sizeof(xh.metadir));
|
||||
snprintf(xh.conffile, sizeof(xh.conffile), "%s/xbps.conf", tcsdir);
|
||||
buf = getcwd(pwd, sizeof(pwd));
|
||||
|
||||
xbps_strlcpy(xh.rootdir, pwd, sizeof(xh.rootdir));
|
||||
xbps_strlcpy(xh.metadir, pwd, sizeof(xh.metadir));
|
||||
snprintf(xh.confdir, sizeof(xh.confdir), "%s/xbps.d", pwd);
|
||||
|
||||
ATF_REQUIRE_EQ(xbps_mkpath(xh.confdir, 0755), 0);
|
||||
|
||||
buf = xbps_xasprintf("%s/xbps.cf", tcsdir);
|
||||
buf2 = xbps_xasprintf("%s/xbps.d/xbps.conf", pwd);
|
||||
ATF_REQUIRE_EQ(symlink(buf, buf2), 0);
|
||||
free(buf);
|
||||
free(buf2);
|
||||
|
||||
buf = xbps_xasprintf("%s/1.include.cf", tcsdir);
|
||||
buf2 = xbps_xasprintf("%s/xbps.d/1.include.conf", pwd);
|
||||
ATF_REQUIRE_EQ(symlink(buf, buf2), 0);
|
||||
free(buf);
|
||||
free(buf2);
|
||||
|
||||
buf = xbps_xasprintf("%s/2.include.cf", tcsdir);
|
||||
buf2 = xbps_xasprintf("%s/xbps.d/2.include.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 both repositories defined in [12].include.conf */
|
||||
ATF_REQUIRE_EQ(xbps_array_count(xh.repositories), 2);
|
||||
}
|
||||
@@ -64,16 +87,26 @@ ATF_TC_BODY(config_include_nomatch_test, tc)
|
||||
{
|
||||
struct xbps_handle xh;
|
||||
const char *tcsdir;
|
||||
char *buf, *buf2, pwd[PATH_MAX];
|
||||
|
||||
/* get test source dir */
|
||||
tcsdir = atf_tc_get_config_var(tc, "srcdir");
|
||||
|
||||
/* change dir to make sure relative paths won't match */
|
||||
ATF_REQUIRE_EQ(chdir("/"), 0);
|
||||
memset(&xh, 0, sizeof(xh));
|
||||
strncpy(xh.rootdir, tcsdir, sizeof(xh.rootdir));
|
||||
strncpy(xh.metadir, tcsdir, sizeof(xh.metadir));
|
||||
strncpy(xh.conffile, "/xbps_nomatch.conf", sizeof(xh.conffile));
|
||||
buf = getcwd(pwd, sizeof(pwd));
|
||||
|
||||
xbps_strlcpy(xh.rootdir, tcsdir, sizeof(xh.rootdir));
|
||||
xbps_strlcpy(xh.metadir, tcsdir, sizeof(xh.metadir));
|
||||
snprintf(xh.confdir, sizeof(xh.confdir), "%s/xbps.d", pwd);
|
||||
|
||||
ATF_REQUIRE_EQ(xbps_mkpath(xh.confdir, 0755), 0);
|
||||
|
||||
buf = xbps_xasprintf("%s/xbps_nomatch.cf", tcsdir);
|
||||
buf2 = xbps_xasprintf("%s/xbps.d/nomatch.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);
|
||||
|
||||
|
||||
@@ -78,8 +78,7 @@ ATF_TC_BODY(find_pkg_obsoletes_test, tc)
|
||||
tcsdir = atf_tc_get_config_var(tc, "srcdir");
|
||||
|
||||
memset(&xh, 0, sizeof(xh));
|
||||
strncpy(xh.rootdir, tcsdir, sizeof(xh.rootdir));
|
||||
strncpy(xh.conffile, "/tmp/unexistent.conf", sizeof(xh.conffile));
|
||||
xbps_strlcpy(xh.rootdir, tcsdir, sizeof(xh.rootdir));
|
||||
ATF_REQUIRE_EQ(xbps_init(&xh), 0);
|
||||
|
||||
d1 = create_dict("files", "/etc/foo.conf");
|
||||
|
||||
@@ -62,8 +62,8 @@ ATF_TC_BODY(find_pkg_orphans_test, tc)
|
||||
tcsdir = atf_tc_get_config_var(tc, "srcdir");
|
||||
|
||||
memset(&xh, 0, sizeof(xh));
|
||||
strncpy(xh.rootdir, tcsdir, sizeof(xh.rootdir));
|
||||
strncpy(xh.metadir, tcsdir, sizeof(xh.metadir));
|
||||
xbps_strlcpy(xh.rootdir, tcsdir, sizeof(xh.rootdir));
|
||||
xbps_strlcpy(xh.metadir, tcsdir, sizeof(xh.metadir));
|
||||
ATF_REQUIRE_EQ(xbps_init(&xh), 0);
|
||||
|
||||
a = xbps_array_create();
|
||||
@@ -99,8 +99,8 @@ ATF_TC_BODY(find_all_orphans_test, tc)
|
||||
tcsdir = atf_tc_get_config_var(tc, "srcdir");
|
||||
|
||||
memset(&xh, 0, sizeof(xh));
|
||||
strncpy(xh.rootdir, tcsdir, sizeof(xh.rootdir));
|
||||
strncpy(xh.metadir, tcsdir, sizeof(xh.metadir));
|
||||
xbps_strlcpy(xh.rootdir, tcsdir, sizeof(xh.rootdir));
|
||||
xbps_strlcpy(xh.metadir, tcsdir, sizeof(xh.metadir));
|
||||
ATF_REQUIRE_EQ(xbps_init(&xh), 0);
|
||||
|
||||
pstr = xbps_string_create();
|
||||
|
||||
@@ -42,8 +42,8 @@ ATF_TC_BODY(pkgdb_get_pkg_test, tc)
|
||||
tcsdir = atf_tc_get_config_var(tc, "srcdir");
|
||||
|
||||
memset(&xh, 0, sizeof(xh));
|
||||
strncpy(xh.rootdir, tcsdir, sizeof(xh.rootdir));
|
||||
strncpy(xh.metadir, tcsdir, sizeof(xh.metadir));
|
||||
xbps_strlcpy(xh.rootdir, tcsdir, sizeof(xh.rootdir));
|
||||
xbps_strlcpy(xh.metadir, tcsdir, sizeof(xh.metadir));
|
||||
xh.flags = XBPS_FLAG_DEBUG;
|
||||
ATF_REQUIRE_EQ(xbps_init(&xh), 0);
|
||||
|
||||
@@ -84,8 +84,8 @@ ATF_TC_BODY(pkgdb_get_virtualpkg_test, tc)
|
||||
tcsdir = atf_tc_get_config_var(tc, "srcdir");
|
||||
|
||||
memset(&xh, 0, sizeof(xh));
|
||||
strncpy(xh.rootdir, tcsdir, sizeof(xh.rootdir));
|
||||
strncpy(xh.metadir, tcsdir, sizeof(xh.metadir));
|
||||
xbps_strlcpy(xh.rootdir, tcsdir, sizeof(xh.rootdir));
|
||||
xbps_strlcpy(xh.metadir, tcsdir, sizeof(xh.metadir));
|
||||
xh.flags = XBPS_FLAG_DEBUG;
|
||||
ATF_REQUIRE_EQ(xbps_init(&xh), 0);
|
||||
|
||||
@@ -129,8 +129,8 @@ ATF_TC_BODY(pkgdb_get_pkg_revdeps_test, tc)
|
||||
tcsdir = atf_tc_get_config_var(tc, "srcdir");
|
||||
|
||||
memset(&xh, 0, sizeof(xh));
|
||||
strncpy(xh.rootdir, tcsdir, sizeof(xh.rootdir));
|
||||
strncpy(xh.metadir, tcsdir, sizeof(xh.metadir));
|
||||
xbps_strlcpy(xh.rootdir, tcsdir, sizeof(xh.rootdir));
|
||||
xbps_strlcpy(xh.metadir, tcsdir, sizeof(xh.metadir));
|
||||
xh.flags = XBPS_FLAG_DEBUG;
|
||||
ATF_REQUIRE_EQ(xbps_init(&xh), 0);
|
||||
|
||||
@@ -162,8 +162,8 @@ ATF_TC_BODY(pkgdb_pkg_reverts_test, tc)
|
||||
tcsdir = atf_tc_get_config_var(tc, "srcdir");
|
||||
|
||||
memset(&xh, 0, sizeof(xh));
|
||||
strncpy(xh.rootdir, tcsdir, sizeof(xh.rootdir));
|
||||
strncpy(xh.metadir, tcsdir, sizeof(xh.metadir));
|
||||
xbps_strlcpy(xh.rootdir, tcsdir, sizeof(xh.rootdir));
|
||||
xbps_strlcpy(xh.metadir, tcsdir, sizeof(xh.metadir));
|
||||
xh.flags = XBPS_FLAG_DEBUG;
|
||||
ATF_REQUIRE_EQ(xbps_init(&xh), 0);
|
||||
|
||||
|
||||
@@ -19,12 +19,13 @@ tc1_body() {
|
||||
cd ..
|
||||
|
||||
mkdir -p root/usr/bin
|
||||
mkdir -p root/xbps.d
|
||||
echo "modified blahblah" > root/usr/bin/blah
|
||||
echo "modified foofoo" > root/usr/bin/foo
|
||||
|
||||
echo "preserve=/usr/bin/*" > foo.conf
|
||||
echo "preserve=/usr/bin/*" > root/xbps.d/foo.conf
|
||||
|
||||
xbps-install -C foo.conf -r root --repository=$PWD/some_repo -yd A
|
||||
xbps-install -C xbps.d -r root --repository=$PWD/some_repo -yd A
|
||||
atf_check_equal $? 0
|
||||
|
||||
rv=1
|
||||
@@ -53,15 +54,16 @@ tc2_body() {
|
||||
cd ..
|
||||
|
||||
mkdir -p root/usr/bin
|
||||
mkdir -p root/xbps.d
|
||||
echo "modified blahblah" > root/usr/bin/blah
|
||||
echo "modified foofoo" > root/usr/bin/foo
|
||||
|
||||
printf "preserve=/usr/bin/blah\npreserve=/usr/bin/foo\n" > foo.conf
|
||||
printf "preserve=/usr/bin/blah\npreserve=/usr/bin/foo\n" > root/xbps.d/foo.conf
|
||||
|
||||
echo "foo.conf" >&2
|
||||
cat foo.conf >&2
|
||||
|
||||
xbps-install -C foo.conf -r root --repository=$PWD/some_repo -yd A
|
||||
xbps-install -C xbps.d -r root --repository=$PWD/some_repo -yd A
|
||||
atf_check_equal $? 0
|
||||
|
||||
rv=1
|
||||
|
||||
@@ -41,7 +41,7 @@ script_nargs_body() {
|
||||
rval=0
|
||||
xbps-reconfigure -C empty.conf -r root -f A 2>out
|
||||
out="$(cat out)"
|
||||
expected="post A 1.0_1 no $(pwd)/empty.conf $(uname -m)"
|
||||
expected="post A 1.0_1 no no $(uname -m)"
|
||||
if [ "$out" != "$expected" ]; then
|
||||
echo "out: '$out'"
|
||||
echo "expected: '$expected'"
|
||||
@@ -75,7 +75,7 @@ script_arch_body() {
|
||||
rval=0
|
||||
XBPS_ARCH=foo xbps-reconfigure -C empty.conf -r root -f A 2>out
|
||||
out="$(cat out)"
|
||||
expected="post A 1.0_1 no $(pwd)/empty.conf foo"
|
||||
expected="post A 1.0_1 no no foo"
|
||||
if [ "$out" != "$expected" ]; then
|
||||
echo "out: '$out'"
|
||||
echo "expected: '$expected'"
|
||||
|
||||
Reference in New Issue
Block a user