From e90373171884f806e541d6c5372042308c8eb623 Mon Sep 17 00:00:00 2001 From: Enno Boland Date: Thu, 29 May 2014 10:00:20 +0200 Subject: [PATCH] adding test for globbing nonexistent files. --- tests/xbps/libxbps/config/Makefile | 2 +- tests/xbps/libxbps/config/main.c | 32 +++++++++++++++++++++ tests/xbps/libxbps/config/xbps_nomatch.conf | 3 ++ 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 tests/xbps/libxbps/config/xbps_nomatch.conf diff --git a/tests/xbps/libxbps/config/Makefile b/tests/xbps/libxbps/config/Makefile index bae1f42b..0535c274 100644 --- a/tests/xbps/libxbps/config/Makefile +++ b/tests/xbps/libxbps/config/Makefile @@ -3,6 +3,6 @@ TOPDIR = ../../../.. TESTSSUBDIR = xbps/libxbps/config TEST = config_test -EXTRA_FILES = Kyuafile xbps.conf 1.include.conf 2.include.conf +EXTRA_FILES = Kyuafile xbps.conf xbps_nomatch.conf 1.include.conf 2.include.conf include $(TOPDIR)/mk/test.mk diff --git a/tests/xbps/libxbps/config/main.c b/tests/xbps/libxbps/config/main.c index e37667ff..57e52026 100644 --- a/tests/xbps/libxbps/config/main.c +++ b/tests/xbps/libxbps/config/main.c @@ -56,9 +56,41 @@ ATF_TC_BODY(config_include_test, tc) ATF_REQUIRE_EQ(xbps_array_count(xh.repositories), 2); } + +ATF_TC(config_include_nomatch_test); +ATF_TC_HEAD(config_include_nomatch_test, tc) +{ + atf_tc_set_md_var(tc, "descr", "Test finds no files to include"); +} + +ATF_TC_BODY(config_include_nomatch_test, tc) +{ + struct xbps_handle xh; + const char *tcsdir; + char conffile[XBPS_MAXPATH-1]; + + /* 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(conffile, tcsdir, sizeof(conffile)); + strncat(conffile, "/xbps_nomatch.conf", sizeof(conffile)-1); + xh.conffile = conffile; + xh.flags = XBPS_FLAG_DEBUG; + ATF_REQUIRE_EQ(xbps_init(&xh), 0); + + /* should contain no repositories */ + ATF_REQUIRE_EQ(xbps_array_count(xh.repositories), 0); +} + ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, config_include_test); + ATF_TP_ADD_TC(tp, config_include_nomatch_test); return atf_no_error(); } diff --git a/tests/xbps/libxbps/config/xbps_nomatch.conf b/tests/xbps/libxbps/config/xbps_nomatch.conf new file mode 100644 index 00000000..2637cf9d --- /dev/null +++ b/tests/xbps/libxbps/config/xbps_nomatch.conf @@ -0,0 +1,3 @@ +# relative path +include=*.this_file_does_not_exist.conf +include=nodir/*.this_file_does_not_exist.conf