added ./configure --with-psl-testfile to set PSL test file path

This commit is contained in:
Tim Ruehsen 2014-04-13 16:43:03 +02:00
parent c93268ce25
commit c481e8019d
3 changed files with 12 additions and 5 deletions

View File

@ -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}
])

View File

@ -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

View File

@ -39,8 +39,6 @@
#include <libpsl.h>
#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++;
}
}