From c481e8019d7577daf5ae8e7d7e00dd80d29fae7c Mon Sep 17 00:00:00 2001 From: Tim Ruehsen Date: Sun, 13 Apr 2014 16:43:03 +0200 Subject: [PATCH] added ./configure --with-psl-testfile to set PSL test file path --- configure.ac | 9 +++++++++ tests/Makefile.am | 2 +- tests/test-registrable-domain.c | 6 ++---- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index d6d31f8..1daf685 100644 --- a/configure.ac +++ b/configure.ac @@ -97,6 +97,14 @@ AC_ARG_WITH(psl-file, PSL_FILE="\$(top_srcdir)/data/effective_tld_names.dat") AC_SUBST(PSL_FILE) +# Check for custom PSL test file +AC_ARG_WITH(psl-testfile, + AC_HELP_STRING([--with-psl-testfile=[PATH]], + [path to PSL test file]), + PSL_TESTFILE=$withval, + PSL_TESTFILE="\$(top_srcdir)/data/test_psl.txt") +AC_SUBST(PSL_TESTFILE) + # Override the template file name of the generated .pc file, so that there # is no need to rename the template file when the API version changes. AC_CONFIG_FILES([Makefile @@ -120,5 +128,6 @@ AC_MSG_NOTICE([Summary of build options: LDFlags: ${LDFLAGS} Builtin PSL: ${enable_builtin} PSL File: ${PSL_FILE} + PSL Test File: ${PSL_TESTFILE} Tests: ${TESTS_INFO} ]) diff --git a/tests/Makefile.am b/tests/Makefile.am index e867f17..637d995 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,4 +1,4 @@ -DEFS = @DEFS@ -DDATADIR=\"$(top_srcdir)/data\" -DSRCDIR=\"$(srcdir)\" -DPSL_FILE=\"$(PSL_FILE)\" +DEFS = @DEFS@ -DDATADIR=\"$(top_srcdir)/data\" -DSRCDIR=\"$(srcdir)\" -DPSL_FILE=\"$(PSL_FILE)\" -DPSL_TESTFILE=\"$(PSL_TESTFILE)\" AM_CPPFLAGS = -I$(top_srcdir)/include LDADD = ../src/libpsl-@LIBPSL_API_VERSION@.la diff --git a/tests/test-registrable-domain.c b/tests/test-registrable-domain.c index ebd1da6..57f1721 100644 --- a/tests/test-registrable-domain.c +++ b/tests/test-registrable-domain.c @@ -39,8 +39,6 @@ #include -#define TESTDATA DATADIR"/test_psl.txt" - static int ok, failed; @@ -110,7 +108,7 @@ static void test_psl(void) // Norwegian with lowercase oe test(psl, "www.\303\270yer.no", "www.\303\270yer.no"); - if ((fp = fopen(TESTDATA, "r"))) { + if ((fp = fopen(PSL_TESTFILE, "r"))) { while ((fgets(buf, sizeof(buf), fp))) { if (sscanf(buf, " checkPublicSuffix('%127[^']' , '%127[^']", domain, expected_regdom) != 2) { if (sscanf(buf, " checkPublicSuffix('%127[^']' , %127[nul]", domain, expected_regdom) != 2) @@ -130,7 +128,7 @@ static void test_psl(void) fclose(fp); } else { - printf("Failed to open %s\n", TESTDATA); + printf("Failed to open %s\n", PSL_TESTFILE); failed++; } }