2 # fontconfig/test/run-test.sh
4 # Copyright © 2000 Keith Packard
6 # Permission to use, copy, modify, distribute, and sell this software and its
7 # documentation for any purpose is hereby granted without fee, provided that
8 # the above copyright notice appear in all copies and that both that
9 # copyright notice and this permission notice appear in supporting
10 # documentation, and that the name of the author(s) not be used in
11 # advertising or publicity pertaining to distribution of the software without
12 # specific, written prior permission. The authors make no
13 # representations about the suitability of this software for any purpose. It
14 # is provided "as is" without express or implied warranty.
16 # THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
17 # INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
18 # EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR
19 # CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
20 # DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
21 # TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
22 # PERFORMANCE OF THIS SOFTWARE.
24 msys ) MyPWD=`pwd -W` ;; # On Msys/MinGW, returns a MS Windows style path.
25 * ) MyPWD=`pwd` ;; # On any other platforms, returns a Unix style path.
28 TESTDIR=${srcdir-"$MyPWD"}
30 FONTDIR="$MyPWD"/fonts
31 CACHEDIR="$MyPWD"/cache.dir
32 EXPECTED=${EXPECTED-"out.expected"}
36 FCLIST=../fc-list/fc-list$EXEEXT
37 FCCACHE=../fc-cache/fc-cache$EXEEXT
39 which bwrap > /dev/null 2>&1
44 FONT1=$TESTDIR/4x6.pcf
45 FONT2=$TESTDIR/8x16.pcf
48 $FCLIST - family pixelsize | sort > out
50 $FCLIST - family pixelsize | sort >> out
52 $FCLIST - family pixelsize | sort >> out
53 tr -d '\015' <out >out.tmp; mv out.tmp out
54 if cmp out $TESTDIR/$EXPECTED > /dev/null ; then : ; else
55 echo "*** Test failed: $TEST"
56 echo "*** output is in 'out', expected output in '$EXPECTED'"
70 test x$VERBOSE = x || echo Running: $TEST
73 sed "s!@FONTDIR@!$FONTDIR!
74 s!@CACHEDIR@!$CACHEDIR!" < $TESTDIR/fonts.conf.in > fonts.conf
76 FONTCONFIG_FILE="$MyPWD"/fonts.conf
77 export FONTCONFIG_FILE
81 cp $FONT1 $FONT2 $FONTDIR
84 dotest "With a subdir"
86 cp $FONT1 $FONT2 $FONTDIR
90 dotest "Subdir with a cache file"
93 cp $FONT1 $FONT2 $FONTDIR/a
97 dotest "Complicated directory structure"
104 cp $FONT2 $FONTDIR/b/a
107 dotest "Subdir with an out-of-date cache file"
112 cp $FONT1 $FONT2 $FONTDIR/a
115 dotest "Dir with an out-of-date cache file"
124 dotest "Re-creating .uuid"
128 cat $FONTDIR/.uuid > out1
130 cat $FONTDIR/.uuid > out2
131 if cmp out1 out2 > /dev/null ; then : ; else
132 echo "*** Test failed: $TEST"
133 echo "*** .uuid was modified unexpectedly"
137 cat $FONTDIR/.uuid > out2
138 if cmp out1 out2 > /dev/null ; then
139 echo "*** Test failed: $TEST"
140 echo "*** .uuid wasn't modified"
145 dotest "Consistency between .uuid and cache name"
151 uuid=`cat $FONTDIR/.uuid`
154 echo "*** Test failed: $TEST"
155 echo "No cache for $uuid"
159 n=`ls -1 $CACHEDIR/*cache-* | wc -l`
161 echo "*** Test failed: $TEST"
162 echo "Unexpected cache was created"
167 dotest "Keep mtime of the font directory"
171 stat $FONTDIR | grep Modify > out1
173 stat $FONTDIR | grep Modify > out2
174 if cmp out1 out2 > /dev/null ; then : ; else
175 echo "*** Test failed: $TEST"
176 echo "mtime was modified"
180 if [ x"$BWRAP" != "x" ]; then
181 dotest "Basic functionality with the bind-mounted cache dir"
183 cp $FONT1 $FONT2 $FONTDIR
186 ls -l $CACHEDIR > out1
187 TESTTMPDIR=`mktemp -d /tmp/fontconfig.XXXXXXXX`
188 sed "s!@FONTDIR@!$TESTTMPDIR/fonts!
189 s!@CACHEDIR@!$TESTTMPDIR/cache.dir!" < $TESTDIR/fonts.conf.in > bind-fonts.conf
190 $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
191 ls -l $CACHEDIR > out2
192 if cmp out1 out2 > /dev/null ; then : ; else
193 echo "*** Test failed: $TEST"
194 echo "cache was updated."
197 if [ x`cat xxx` != "x$TESTTMPDIR/fonts/4x6.pcf" ]; then
198 echo "*** Test failed: $TEST"
199 echo "file property doesn't points to the new place: $TESTTMPDIR/fonts/4x6.pcf"
202 rm -rf $TESTTMPDIR out1 out2 xxx bind-fonts.conf
205 rm -rf $FONTDIR $CACHEFILE $CACHEDIR $FONTCONFIG_FILE out