Blame test/run-test.sh

Packit 352660
#!/bin/sh
Packit 352660
# fontconfig/test/run-test.sh
Packit 352660
#
Packit 352660
# Copyright © 2000 Keith Packard
Packit 352660
#
Packit 352660
# Permission to use, copy, modify, distribute, and sell this software and its
Packit 352660
# documentation for any purpose is hereby granted without fee, provided that
Packit 352660
# the above copyright notice appear in all copies and that both that
Packit 352660
# copyright notice and this permission notice appear in supporting
Packit 352660
# documentation, and that the name of the author(s) not be used in
Packit 352660
# advertising or publicity pertaining to distribution of the software without
Packit 352660
# specific, written prior permission.  The authors make no
Packit 352660
# representations about the suitability of this software for any purpose.  It
Packit 352660
# is provided "as is" without express or implied warranty.
Packit 352660
#
Packit 352660
# THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
Packit 352660
# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
Packit 352660
# EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR
Packit 352660
# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
Packit 352660
# DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
Packit 352660
# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
Packit 352660
# PERFORMANCE OF THIS SOFTWARE.
Packit 352660
case "$OSTYPE" in
Packit 352660
    msys ) MyPWD=`pwd -W` ;;  # On Msys/MinGW, returns a MS Windows style path.
Packit 352660
    *    ) MyPWD=`pwd`    ;;  # On any other platforms, returns a Unix style path.
Packit 352660
esac
Packit 352660
Packit 352660
TESTDIR=${srcdir-"$MyPWD"}
Packit 352660
BUILDTESTDIR=${builddir-"$MyPWD"}
Packit 352660
Packit 352660
FONTDIR="$MyPWD"/fonts
Packit 352660
CACHEDIR="$MyPWD"/cache.dir
Packit 352660
EXPECTED=${EXPECTED-"out.expected"}
Packit 352660
Packit 352660
ECHO=true
Packit 352660
Packit 352660
FCLIST=../fc-list/fc-list$EXEEXT
Packit 352660
FCCACHE=../fc-cache/fc-cache$EXEEXT
Packit 352660
Packit 352660
which bwrap > /dev/null 2>&1
Packit 352660
if [ $? -eq 0 ]; then
Packit 352660
    BWRAP=`which bwrap`
Packit 352660
fi
Packit 352660
Packit 352660
FONT1=$TESTDIR/4x6.pcf
Packit 352660
FONT2=$TESTDIR/8x16.pcf
Packit 352660
Packit 352660
check () {
Packit 352660
  $FCLIST - family pixelsize | sort > out
Packit 352660
  echo "=" >> out
Packit 352660
  $FCLIST - family pixelsize | sort >> out
Packit 352660
  echo "=" >> out
Packit 352660
  $FCLIST - family pixelsize | sort >> out
Packit 352660
  tr -d '\015' <out >out.tmp; mv out.tmp out
Packit 352660
  if cmp out $BUILDTESTDIR/$EXPECTED > /dev/null ; then : ; else
Packit 352660
    echo "*** Test failed: $TEST"
Packit 352660
    echo "*** output is in 'out', expected output in '$EXPECTED'"
Packit 352660
    exit 1
Packit 352660
  fi
Packit 352660
  rm -f out
Packit 352660
}
Packit 352660
Packit 352660
prep() {
Packit 352660
  rm -rf $CACHEDIR
Packit 352660
  rm -rf $FONTDIR
Packit 352660
  mkdir $FONTDIR
Packit 352660
}
Packit 352660
Packit 352660
dotest () {
Packit 352660
  TEST=$1
Packit 352660
  test x$VERBOSE = x || echo Running: $TEST
Packit 352660
}
Packit 352660
Packit 352660
sed "s!@FONTDIR@!$FONTDIR!
Packit 352660
s!@CACHEDIR@!$CACHEDIR!" < $TESTDIR/fonts.conf.in > fonts.conf
Packit 352660
Packit 352660
FONTCONFIG_FILE="$MyPWD"/fonts.conf
Packit 352660
export FONTCONFIG_FILE
Packit 352660
Packit 352660
dotest "Basic check"
Packit 352660
prep
Packit 352660
cp $FONT1 $FONT2 $FONTDIR
Packit 352660
check
Packit 352660
Packit 352660
dotest "With a subdir"
Packit 352660
prep
Packit 352660
cp $FONT1 $FONT2 $FONTDIR
Packit 352660
$FCCACHE $FONTDIR
Packit 352660
check
Packit 352660
Packit 352660
dotest "Subdir with a cache file"
Packit 352660
prep
Packit 352660
mkdir $FONTDIR/a
Packit 352660
cp $FONT1 $FONT2 $FONTDIR/a
Packit 352660
$FCCACHE $FONTDIR/a
Packit 352660
check
Packit 352660
Packit 352660
dotest "Complicated directory structure"
Packit 352660
prep
Packit 352660
mkdir $FONTDIR/a
Packit 352660
mkdir $FONTDIR/a/a
Packit 352660
mkdir $FONTDIR/b
Packit 352660
mkdir $FONTDIR/b/a
Packit 352660
cp $FONT1 $FONTDIR/a
Packit 352660
cp $FONT2 $FONTDIR/b/a
Packit 352660
check
Packit 352660
Packit 352660
dotest "Subdir with an out-of-date cache file"
Packit 352660
prep
Packit 352660
mkdir $FONTDIR/a
Packit 352660
$FCCACHE $FONTDIR/a
Packit 352660
sleep 1
Packit 352660
cp $FONT1 $FONT2 $FONTDIR/a
Packit 352660
check
Packit 352660
Packit 352660
dotest "Dir with an out-of-date cache file"
Packit 352660
prep
Packit 352660
cp $FONT1 $FONTDIR
Packit 352660
$FCCACHE $FONTDIR
Packit 352660
sleep 1
Packit 352660
mkdir $FONTDIR/a
Packit 352660
cp $FONT2 $FONTDIR/a
Packit 352660
check
Packit 352660
Packit 352660
dotest "Re-creating .uuid"
Packit 352660
prep
Packit 352660
cp $FONT1 $FONTDIR
Packit 352660
$FCCACHE $FONTDIR
Packit 352660
cat $FONTDIR/.uuid > out1
Packit 352660
$FCCACHE -f $FONTDIR
Packit 352660
cat $FONTDIR/.uuid > out2
Packit 352660
if cmp out1 out2 > /dev/null ; then : ; else
Packit 352660
  echo "*** Test failed: $TEST"
Packit 352660
  echo "*** .uuid was modified unexpectedly"
Packit 352660
  exit 1
Packit 352660
fi
Packit 352660
$FCCACHE -r $FONTDIR
Packit 352660
cat $FONTDIR/.uuid > out2
Packit 352660
if cmp out1 out2 > /dev/null ; then
Packit 352660
  echo "*** Test failed: $TEST"
Packit 352660
  echo "*** .uuid wasn't modified"
Packit 352660
  exit 1
Packit 352660
fi
Packit 352660
rm -f out1 out2
Packit 352660
Packit 352660
dotest "Consistency between .uuid and cache name"
Packit 352660
prep
Packit 352660
cp $FONT1 $FONTDIR
Packit 352660
$FCCACHE $FONTDIR
Packit 352660
cat $FONTDIR/.uuid
Packit 352660
$FCCACHE -r $FONTDIR
Packit 352660
uuid=`cat $FONTDIR/.uuid`
Packit 352660
ls $CACHEDIR/$uuid*
Packit 352660
if [ $? != 0 ]; then
Packit 352660
  echo "*** Test failed: $TEST"
Packit 352660
  echo "No cache for $uuid"
Packit 352660
  ls $CACHEDIR
Packit 352660
  exit 1
Packit 352660
fi
Packit 352660
n=`ls -1 $CACHEDIR/*cache-* | wc -l`
Packit 352660
if [ $n != 1 ]; then
Packit 352660
  echo "*** Test failed: $TEST"
Packit 352660
  echo "Unexpected cache was created"
Packit 352660
  ls $CACHEDIR
Packit 352660
  exit 1
Packit 352660
fi
Packit 352660
Packit 352660
dotest "Keep mtime of the font directory"
Packit 352660
prep
Packit 352660
cp $FONT1 $FONTDIR
Packit 352660
touch -d @0 $FONTDIR
Packit 352660
stat $FONTDIR | grep Modify > out1
Packit 352660
$FCCACHE $FONTDIR
Packit 352660
stat $FONTDIR | grep Modify > out2
Packit 352660
if cmp out1 out2 > /dev/null ; then : ; else
Packit 352660
    echo "*** Test failed: $TEST"
Packit 352660
    echo "mtime was modified"
Packit 352660
    exit 1
Packit 352660
fi
Packit 352660
Packit 352660
if [ x"$BWRAP" != "x" ]; then
Packit 352660
dotest "Basic functionality with the bind-mounted cache dir"
Packit 352660
prep
Packit 352660
cp $FONT1 $FONT2 $FONTDIR
Packit 352660
$FCCACHE $FONTDIR
Packit 352660
sleep 1
Packit 352660
ls -l $CACHEDIR > out1
Packit 352660
TESTTMPDIR=`mktemp -d /tmp/fontconfig.XXXXXXXX`
Packit 352660
sed "s!@FONTDIR@!$TESTTMPDIR/fonts!
Packit 352660
s!@CACHEDIR@!$TESTTMPDIR/cache.dir!" < $TESTDIR/fonts.conf.in > bind-fonts.conf
Packit 352660
$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
Packit 352660
$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
Packit 352660
$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
Packit 352660
ls -l $CACHEDIR > out2
Packit 352660
if cmp out1 out2 > /dev/null ; then : ; else
Packit 352660
  echo "*** Test failed: $TEST"
Packit 352660
  echo "cache was updated."
Packit 352660
  exit 1
Packit 352660
fi
Packit 352660
if [ x`cat xxx` != "x$TESTTMPDIR/fonts/4x6.pcf" ]; then
Packit 352660
  echo "*** Test failed: $TEST"
Packit 352660
  echo "file property doesn't point to the new place: $TESTTMPDIR/fonts/4x6.pcf"
Packit 352660
  exit 1
Packit 352660
fi
Packit 352660
if cmp flist1 flist2 > /dev/null ; then : ; else
Packit 352660
  echo "*** Test failed: $TEST"
Packit 352660
  echo "file properties doesn't point to the new places"
Packit 352660
  echo "Expected result:"
Packit 352660
  cat flist2
Packit 352660
  echo "Actual result:"
Packit 352660
  cat flist1
Packit 352660
  exit 1
Packit 352660
fi
Packit 352660
rm -rf $TESTTMPDIR out1 out2 xxx flist1 flist2 bind-fonts.conf
Packit 352660
fi
Packit 352660
Packit 352660
dotest "sysroot option"
Packit 352660
prep
Packit 352660
mkdir -p $MyPWD/sysroot/$FONTDIR
Packit 352660
mkdir -p $MyPWD/sysroot/$CACHEDIR
Packit 352660
cp $FONT1 $MyPWD/sysroot/$FONTDIR
Packit 352660
cp $MyPWD/fonts.conf $MyPWD/sysroot/$MyPWD/fonts.conf
Packit 352660
$FCCACHE -y $MyPWD/sysroot
Packit 352660
stat $MyPWD/sysroot/$FONTDIR/.uuid
Packit 352660
if test $? != 0; then
Packit 352660
  echo "*** Test failed: $TEST"
Packit 352660
  exit 1
Packit 352660
fi
Packit 352660
Packit 352660
dotest "creating uuid-based cache file on sysroot"
Packit 352660
uuid=`cat $MyPWD/sysroot/$FONTDIR/.uuid`
Packit 352660
ls $MyPWD/sysroot/$CACHEDIR/$uuid*
Packit 352660
if [ $? != 0 ]; then
Packit 352660
  echo "*** Test failed: $TEST"
Packit 352660
  echo "No cache for $uuid"
Packit 352660
  ls $MyPWD/sysroot/$CACHEDIR
Packit 352660
  exit 1
Packit 352660
fi
Packit 352660
Packit 352660
rm -rf $MyPWD/sysroot
Packit 352660
Packit Service 4ad037
# dotest "deleting .uuid file on empty dir"
Packit Service 4ad037
# prep
Packit Service 4ad037
# cp $FONT1 $FONT2 $FONTDIR
Packit Service 4ad037
# $FCCACHE $FONTDIR
Packit Service 4ad037
# sleep 1
Packit Service 4ad037
# rm -f $FONTDIR/*pcf
Packit Service 4ad037
# $FCCACHE $FONTDIR
Packit Service 4ad037
# rmdir $FONTDIR > /dev/null 2>&1
Packit Service 4ad037
# if [ $? != 0 ]; then
Packit Service 4ad037
#   echo "*** Test failed: $TEST"
Packit Service 4ad037
#   echo "$FONTDIR isn't empty"
Packit Service 4ad037
#   ls -al $FONTDIR
Packit Service 4ad037
#   exit 1
Packit Service 4ad037
# fi
Packit 352660
Packit 352660
rm -rf $FONTDIR $CACHEFILE $CACHEDIR $FONTCONFIG_FILE out