summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/Makefile.am2
-rw-r--r--test/fonts.conf.in2
-rwxr-xr-xtest/run-test-map.sh107
-rw-r--r--test/run-test.sh2
4 files changed, 111 insertions, 2 deletions
diff --git a/test/Makefile.am b/test/Makefile.am
index ff693e4..81aace0 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -1,4 +1,4 @@
-check_SCRIPTS=run-test.sh
+check_SCRIPTS=run-test.sh run-test-map.sh
TEST_EXTENSIONS = \
.sh \
$(NULL)
diff --git a/test/fonts.conf.in b/test/fonts.conf.in
index 95def72..24bd58b 100644
--- a/test/fonts.conf.in
+++ b/test/fonts.conf.in
@@ -1,4 +1,4 @@
<fontconfig>
-<dir>@FONTDIR@</dir>
+<dir @MAP@>@FONTDIR@</dir>
<cachedir>@CACHEDIR@</cachedir>
</fontconfig>
diff --git a/test/run-test-map.sh b/test/run-test-map.sh
new file mode 100755
index 0000000..869d7b2
--- /dev/null
+++ b/test/run-test-map.sh
@@ -0,0 +1,107 @@
+#!/bin/bash
+# fontconfig/test/run-test-cache-map.sh
+#
+# Copyright © 2018 Keith Packard
+#
+# Permission to use, copy, modify, distribute, and sell this software and its
+# documentation for any purpose is hereby granted without fee, provided that
+# the above copyright notice appear in all copies and that both that copyright
+# notice and this permission notice appear in supporting documentation, and
+# that the name of the copyright holders not be used in advertising or
+# publicity pertaining to distribution of the software without specific,
+# written prior permission. The copyright holders make no representations
+# about the suitability of this software for any purpose. It is provided "as
+# is" without express or implied warranty.
+#
+# THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+# EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+# DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+# OF THIS SOFTWARE.
+#
+
+case "$OSTYPE" in
+ msys ) MyPWD=`pwd -W` ;; # On Msys/MinGW, returns a MS Windows style path.
+ * ) MyPWD=`pwd` ;; # On any other platforms, returns a Unix style path.
+esac
+
+TESTDIR=${srcdir-"$MyPWD"}
+BUILDTESTDIR=${builddir-"$MyPWD"}
+
+FONTDIRA="$MyPWD"/fontsa
+FONTDIRB="$MyPWD"/fontsb
+CACHEDIR="$MyPWD"/cache.dir
+EXPECTEDIN=${EXPECTEDIN-"out-map.expected.in"}
+EXPECTEDA="out-map-a.expected"
+EXPECTEDB="out-map-b.expected"
+EXPECTED="out-map.expected"
+
+FCLIST=../fc-list/fc-list$EXEEXT
+FCCACHE=../fc-cache/fc-cache$EXEEXT
+
+which bwrap > /dev/null 2>&1
+if [ $? -eq 0 ]; then
+ BWRAP=`which bwrap`
+fi
+
+FONT1=$TESTDIR/4x6.pcf
+FONT2=$TESTDIR/8x16.pcf
+
+check () {
+ $FCLIST - file family pixelsize | sort > out
+ echo "=" >> out
+ $FCLIST - file family pixelsize | sort >> out
+ echo "=" >> out
+ $FCLIST - file family pixelsize | sort >> out
+ tr -d '\015' <out >out.tmp; mv out.tmp out
+ if cmp out $BUILDTESTDIR/$EXPECTED > /dev/null ; then : ; else
+ echo "*** Test failed: $TEST"
+ echo "*** output is in 'out', expected output in '$EXPECTED'"
+ exit 1
+ fi
+ rm -f out
+}
+
+prep() {
+ rm -rf $CACHEDIR
+ rm -rf $FONTDIRA $FONTDIRB
+ mkdir $FONTDIRA
+ mkdir $CACHEDIR
+}
+
+dotest () {
+ TEST=$1
+ test x$VERBOSE = x || echo Running: $TEST
+}
+
+sed "s!@FONTDIR@!$FONTDIRA!
+s!@MAP@!!
+s!@CACHEDIR@!$CACHEDIR!" < $TESTDIR/fonts.conf.in > fonts-a.conf
+
+sed "s!@FONTDIR@!$FONTDIRB!
+s!@MAP@!map="'"'"$FONTDIRA"'"'"!
+s!@CACHEDIR@!$CACHEDIR!" < $TESTDIR/fonts.conf.in > fonts-b.conf
+
+sed "s!@FONTDIR@!$FONTDIRA!" < $EXPECTEDIN > $EXPECTEDA
+sed "s!@FONTDIR@!$FONTDIRB!" < $EXPECTEDIN > $EXPECTEDB
+
+FONTCONFIG_FILE="$MyPWD"/fonts-a.conf
+export FONTCONFIG_FILE
+
+dotest "Basic check"
+prep
+cp $FONT1 $FONT2 $FONTDIRA
+cp $EXPECTEDA $EXPECTED
+$FCCACHE $FONTDIRA
+check
+
+dotest "mapped check"
+prep
+cp $FONT1 $FONT2 $FONTDIRA
+cp $EXPECTEDB $EXPECTED
+$FCCACHE $FONTDIRA
+mv $FONTDIRA $FONTDIRB
+export FONTCONFIG_FILE="$MyPWD"/fonts-b.conf
+check
diff --git a/test/run-test.sh b/test/run-test.sh
index a05dadb..b9a07b8 100644
--- a/test/run-test.sh
+++ b/test/run-test.sh
@@ -73,6 +73,7 @@ dotest () {
}
sed "s!@FONTDIR@!$FONTDIR!
+s!@MAP@!!
s!@CACHEDIR@!$CACHEDIR!" < $TESTDIR/fonts.conf.in > fonts.conf
FONTCONFIG_FILE="$MyPWD"/fonts.conf
@@ -145,6 +146,7 @@ sleep 1
ls -l $CACHEDIR > out1
TESTTMPDIR=`mktemp -d /tmp/fontconfig.XXXXXXXX`
sed "s!@FONTDIR@!$TESTTMPDIR/fonts!
+s!@MAP@!map="'"'"$FONTDIR"'"'"!
s!@CACHEDIR@!$TESTTMPDIR/cache.dir!" < $TESTDIR/fonts.conf.in > bind-fonts.conf
$BWRAP --bind / / --bind $CACHEDIR $TESTTMPDIR/cache.dir --bind $FONTDIR $TESTTMPDIR/fonts --bind .. $TESTTMPDIR/build --dev-bind /dev /dev --setenv FONTCONFIG_FILE $TESTTMPDIR/build/test/bind-fonts.conf $TESTTMPDIR/build/fc-match/fc-match$EXEEXT -f "%{file}\n" ":foundry=Misc" > xxx
$BWRAP --bind / / --bind $CACHEDIR $TESTTMPDIR/cache.dir --bind $FONTDIR $TESTTMPDIR/fonts --bind .. $TESTTMPDIR/build --dev-bind /dev /dev --setenv FONTCONFIG_FILE $TESTTMPDIR/build/test/bind-fonts.conf $TESTTMPDIR/build/test/test-bz106618$EXEEXT | sort > flist1