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"}
29 BUILDTESTDIR=${builddir-"$MyPWD"}
31 FONTDIR="$MyPWD"/fonts
32 CACHEDIR="$MyPWD"/cache.dir
33 EXPECTED=${EXPECTED-"out.expected"}
37 FCLIST=../fc-list/fc-list$EXEEXT
38 FCCACHE=../fc-cache/fc-cache$EXEEXT
40 which bwrap > /dev/null 2>&1
45 FONT1=$TESTDIR/4x6.pcf
46 FONT2=$TESTDIR/8x16.pcf
49 $FCLIST - family pixelsize | sort > out
51 $FCLIST - family pixelsize | sort >> out
53 $FCLIST - family pixelsize | sort >> out
54 tr -d '\015' <out >out.tmp; mv out.tmp out
55 if cmp out $BUILDTESTDIR/$EXPECTED > /dev/null ; then : ; else
56 echo "*** Test failed: $TEST"
57 echo "*** output is in 'out', expected output in '$EXPECTED'"
71 test x$VERBOSE = x || echo Running: $TEST
74 sed "s!@FONTDIR@!$FONTDIR!
75 s!@CACHEDIR@!$CACHEDIR!" < $TESTDIR/fonts.conf.in > fonts.conf
77 FONTCONFIG_FILE="$MyPWD"/fonts.conf
78 export FONTCONFIG_FILE
82 cp $FONT1 $FONT2 $FONTDIR
85 dotest "With a subdir"
87 cp $FONT1 $FONT2 $FONTDIR
91 dotest "Subdir with a cache file"
94 cp $FONT1 $FONT2 $FONTDIR/a
98 dotest "Complicated directory structure"
105 cp $FONT2 $FONTDIR/b/a
108 dotest "Subdir with an out-of-date cache file"
113 cp $FONT1 $FONT2 $FONTDIR/a
116 dotest "Dir with an out-of-date cache file"
125 dotest "Re-creating .uuid"
129 cat $FONTDIR/.uuid > out1
131 cat $FONTDIR/.uuid > out2
132 if cmp out1 out2 > /dev/null ; then : ; else
133 echo "*** Test failed: $TEST"
134 echo "*** .uuid was modified unexpectedly"
138 cat $FONTDIR/.uuid > out2
139 if cmp out1 out2 > /dev/null ; then
140 echo "*** Test failed: $TEST"
141 echo "*** .uuid wasn't modified"
146 dotest "Consistency between .uuid and cache name"
152 uuid=`cat $FONTDIR/.uuid`
155 echo "*** Test failed: $TEST"
156 echo "No cache for $uuid"
160 n=`ls -1 $CACHEDIR/*cache-* | wc -l`
162 echo "*** Test failed: $TEST"
163 echo "Unexpected cache was created"
168 dotest "Keep mtime of the font directory"
172 stat $FONTDIR | grep Modify > out1
174 stat $FONTDIR | grep Modify > out2
175 if cmp out1 out2 > /dev/null ; then : ; else
176 echo "*** Test failed: $TEST"
177 echo "mtime was modified"
181 if [ x"$BWRAP" != "x" ]; then
182 dotest "Basic functionality with the bind-mounted cache dir"
184 cp $FONT1 $FONT2 $FONTDIR
187 ls -l $CACHEDIR > out1
188 TESTTMPDIR=`mktemp -d /tmp/fontconfig.XXXXXXXX`
189 sed "s!@FONTDIR@!$TESTTMPDIR/fonts!
190 s!@CACHEDIR@!$TESTTMPDIR/cache.dir!" < $TESTDIR/fonts.conf.in > bind-fonts.conf
191 $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
192 $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
193 $BWRAP --bind / / --bind $CACHEDIR $TESTTMPDIR/cache.dir --bind $FONTDIR $TESTTMPDIR/fonts --bind .. $TESTTMPDIR/build --dev-bind /dev /dev find $TESTTMPDIR/fonts/ -type f -name '*.pcf' | sort > flist2
194 ls -l $CACHEDIR > out2
195 if cmp out1 out2 > /dev/null ; then : ; else
196 echo "*** Test failed: $TEST"
197 echo "cache was updated."
200 if [ x`cat xxx` != "x$TESTTMPDIR/fonts/4x6.pcf" ]; then
201 echo "*** Test failed: $TEST"
202 echo "file property doesn't point to the new place: $TESTTMPDIR/fonts/4x6.pcf"
205 if cmp flist1 flist2 > /dev/null ; then : ; else
206 echo "*** Test failed: $TEST"
207 echo "file properties doesn't point to the new places"
208 echo "Expected result:"
210 echo "Actual result:"
214 rm -rf $TESTTMPDIR out1 out2 xxx flist1 flist2 bind-fonts.conf
217 dotest "sysroot option"
219 mkdir -p $MyPWD/sysroot/$FONTDIR
220 mkdir -p $MyPWD/sysroot/$CACHEDIR
221 cp $FONT1 $MyPWD/sysroot/$FONTDIR
222 cp $MyPWD/fonts.conf $MyPWD/sysroot/$MyPWD/fonts.conf
223 $FCCACHE -y $MyPWD/sysroot
224 stat $MyPWD/sysroot/$FONTDIR/.uuid
225 if test $? != 0; then
226 echo "*** Test failed: $TEST"
230 dotest "creating uuid-based cache file on sysroot"
231 uuid=`cat $MyPWD/sysroot/$FONTDIR/.uuid`
232 ls $MyPWD/sysroot/$CACHEDIR/$uuid*
234 echo "*** Test failed: $TEST"
235 echo "No cache for $uuid"
236 ls $MyPWD/sysroot/$CACHEDIR
240 rm -rf $MyPWD/sysroot
242 dotest "deleting .uuid file on empty dir"
244 cp $FONT1 $FONT2 $FONTDIR
249 rmdir $FONTDIR > /dev/null 2>&1
251 echo "*** Test failed: $TEST"
252 echo "$FONTDIR isn't empty"
257 rm -rf $FONTDIR $CACHEFILE $CACHEDIR $FONTCONFIG_FILE out