Fix errors on shellcheck

Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/-/issues/235
This commit is contained in:
Akira TAGOH 2020-04-10 17:27:15 +09:00
parent 9c46ef4aac
commit f3e049967e
1 changed files with 162 additions and 161 deletions

View File

@ -1,4 +1,4 @@
#!/bin/sh #!/bin/bash
# fontconfig/test/run-test.sh # fontconfig/test/run-test.sh
# #
# Copyright © 2000 Keith Packard # Copyright © 2000 Keith Packard
@ -23,20 +23,18 @@
set -e set -e
case "$OSTYPE" in case "$OSTYPE" in
msys ) MyPWD=`pwd -W` ;; # On Msys/MinGW, returns a MS Windows style path. msys ) MyPWD=$(pwd -W) ;; # On Msys/MinGW, returns a MS Windows style path.
* ) MyPWD=`pwd` ;; # On any other platforms, returns a Unix style path. * ) MyPWD=$(pwd) ;; # On any other platforms, returns a Unix style path.
esac esac
TESTDIR=${srcdir-"$MyPWD"} TESTDIR=${srcdir-"$MyPWD"}
BUILDTESTDIR=${builddir-"$MyPWD"} BUILDTESTDIR=${builddir-"$MyPWD"}
BASEDIR=`mktemp -d --tmpdir fontconfig.XXXXXXXX` BASEDIR=$(mktemp -d --tmpdir fontconfig.XXXXXXXX)
FONTDIR="$BASEDIR"/fonts FONTDIR="$BASEDIR"/fonts
CACHEDIR="$BASEDIR"/cache.dir CACHEDIR="$BASEDIR"/cache.dir
EXPECTED=${EXPECTED-"out.expected"} EXPECTED=${EXPECTED-"out.expected"}
ECHO=true
FCLIST="$LOG_COMPILER ../fc-list/fc-list$EXEEXT" FCLIST="$LOG_COMPILER ../fc-list/fc-list$EXEEXT"
FCCACHE="$LOG_COMPILER ../fc-cache/fc-cache$EXEEXT" FCCACHE="$LOG_COMPILER ../fc-cache/fc-cache$EXEEXT"
@ -48,13 +46,15 @@ FONT1=$TESTDIR/4x6.pcf
FONT2=$TESTDIR/8x16.pcf FONT2=$TESTDIR/8x16.pcf
check () { check () {
$FCLIST - family pixelsize | sort > out {
echo "=" >> out $FCLIST - family pixelsize | sort;
$FCLIST - family pixelsize | sort >> out echo "=";
echo "=" >> out $FCLIST - family pixelsize | sort;
$FCLIST - family pixelsize | sort >> out echo "=";
$FCLIST - family pixelsize | sort;
} > out
tr -d '\015' <out >out.tmp; mv out.tmp out tr -d '\015' <out >out.tmp; mv out.tmp out
if cmp out $BUILDTESTDIR/$EXPECTED > /dev/null ; then : ; else if cmp out "$BUILDTESTDIR"/"$EXPECTED" > /dev/null ; then : ; else
echo "*** Test failed: $TEST" echo "*** Test failed: $TEST"
echo "*** output is in 'out', expected output in '$EXPECTED'" echo "*** output is in 'out', expected output in '$EXPECTED'"
exit 1 exit 1
@ -63,114 +63,114 @@ check () {
} }
prep() { prep() {
rm -rf $CACHEDIR rm -rf "$CACHEDIR"
rm -rf $FONTDIR rm -rf "$FONTDIR"
mkdir $FONTDIR mkdir "$FONTDIR"
} }
dotest () { dotest () {
TEST=$1 TEST=$1
test x$VERBOSE = x || echo Running: $TEST test x"$VERBOSE" = x || echo "Running: $TEST"
} }
sed "s!@FONTDIR@!$FONTDIR! sed "s!@FONTDIR@!$FONTDIR!
s!@REMAPDIR@!! s!@REMAPDIR@!!
s!@CACHEDIR@!$CACHEDIR!" < $TESTDIR/fonts.conf.in > fonts.conf s!@CACHEDIR@!$CACHEDIR!" < "$TESTDIR"/fonts.conf.in > fonts.conf
FONTCONFIG_FILE="$MyPWD"/fonts.conf FONTCONFIG_FILE="$MyPWD"/fonts.conf
export FONTCONFIG_FILE export FONTCONFIG_FILE
dotest "Basic check" dotest "Basic check"
prep prep
cp $FONT1 $FONT2 $FONTDIR cp "$FONT1" "$FONT2" "$FONTDIR"
if [ -n ${SOURCE_DATE_EPOCH:-} ] && [ ${#SOURCE_DATE_EPOCH} -gt 0 ]; then if [ -n "${SOURCE_DATE_EPOCH:-}" ] && [ ${#SOURCE_DATE_EPOCH} -gt 0 ]; then
touch -m -t "`date -d \"@${SOURCE_DATE_EPOCH}\" +%y%m%d%H%M.%S`" $FONTDIR touch -m -t "$(date -d @"${SOURCE_DATE_EPOCH}" +%y%m%d%H%M.%S)" "$FONTDIR"
fi fi
check check
dotest "With a subdir" dotest "With a subdir"
prep prep
cp $FONT1 $FONT2 $FONTDIR cp "$FONT1" "$FONT2" "$FONTDIR"
if [ -n ${SOURCE_DATE_EPOCH:-} ] && [ ${#SOURCE_DATE_EPOCH} -gt 0 ]; then if [ -n "${SOURCE_DATE_EPOCH:-}" ] && [ ${#SOURCE_DATE_EPOCH} -gt 0 ]; then
touch -m -t "`date -d \"@${SOURCE_DATE_EPOCH}\" +%y%m%d%H%M.%S`" $FONTDIR touch -m -t "$(date -d @"${SOURCE_DATE_EPOCH}" +%y%m%d%H%M.%S)" "$FONTDIR"
fi fi
$FCCACHE $FONTDIR $FCCACHE "$FONTDIR"
check check
dotest "Subdir with a cache file" dotest "Subdir with a cache file"
prep prep
mkdir $FONTDIR/a mkdir "$FONTDIR"/a
cp $FONT1 $FONT2 $FONTDIR/a cp "$FONT1" "$FONT2" "$FONTDIR"/a
if [ -n ${SOURCE_DATE_EPOCH:-} ] && [ ${#SOURCE_DATE_EPOCH} -gt 0 ]; then if [ -n "${SOURCE_DATE_EPOCH:-}" ] && [ ${#SOURCE_DATE_EPOCH} -gt 0 ]; then
touch -m -t "`date -d \"@${SOURCE_DATE_EPOCH}\" +%y%m%d%H%M.%S`" $FONTDIR/a touch -m -t "$(date -d @"${SOURCE_DATE_EPOCH}" +%y%m%d%H%M.%S)" "$FONTDIR"/a
fi fi
$FCCACHE $FONTDIR/a $FCCACHE "$FONTDIR"/a
check check
dotest "Complicated directory structure" dotest "Complicated directory structure"
prep prep
mkdir $FONTDIR/a mkdir "$FONTDIR"/a
mkdir $FONTDIR/a/a mkdir "$FONTDIR"/a/a
mkdir $FONTDIR/b mkdir "$FONTDIR"/b
mkdir $FONTDIR/b/a mkdir "$FONTDIR"/b/a
cp $FONT1 $FONTDIR/a cp "$FONT1" "$FONTDIR"/a
if [ -n ${SOURCE_DATE_EPOCH:-} ] && [ ${#SOURCE_DATE_EPOCH} -gt 0 ]; then if [ -n "${SOURCE_DATE_EPOCH:-}" ] && [ ${#SOURCE_DATE_EPOCH} -gt 0 ]; then
touch -m -t "`date -d \"@${SOURCE_DATE_EPOCH}\" +%y%m%d%H%M.%S`" $FONTDIR/a touch -m -t "$(date -d @"${SOURCE_DATE_EPOCH}" +%y%m%d%H%M.%S)" "$FONTDIR"/a
fi fi
cp $FONT2 $FONTDIR/b/a cp "$FONT2" "$FONTDIR"/b/a
if [ -n ${SOURCE_DATE_EPOCH:-} ] && [ ${#SOURCE_DATE_EPOCH} -gt 0 ]; then if [ -n "${SOURCE_DATE_EPOCH:-}" ] && [ ${#SOURCE_DATE_EPOCH} -gt 0 ]; then
touch -m -t "`date -d \"@${SOURCE_DATE_EPOCH}\" +%y%m%d%H%M.%S`" $FONTDIR/b/a touch -m -t "$(date -d @"${SOURCE_DATE_EPOCH}" +%y%m%d%H%M.%S)" "$FONTDIR"/b/a
fi fi
check check
dotest "Subdir with an out-of-date cache file" dotest "Subdir with an out-of-date cache file"
prep prep
mkdir $FONTDIR/a mkdir "$FONTDIR"/a
$FCCACHE $FONTDIR/a $FCCACHE "$FONTDIR"/a
sleep 1 sleep 1
cp $FONT1 $FONT2 $FONTDIR/a cp "$FONT1" "$FONT2" "$FONTDIR"/a
check check
dotest "Dir with an out-of-date cache file" dotest "Dir with an out-of-date cache file"
prep prep
cp $FONT1 $FONTDIR cp "$FONT1" "$FONTDIR"
$FCCACHE $FONTDIR $FCCACHE "$FONTDIR"
sleep 1 sleep 1
mkdir $FONTDIR/a mkdir "$FONTDIR"/a
cp $FONT2 $FONTDIR/a cp "$FONT2" "$FONTDIR"/a
check check
dotest "Keep mtime of the font directory" dotest "Keep mtime of the font directory"
prep prep
cp $FONT1 $FONTDIR cp "$FONT1" "$FONTDIR"
touch -d @0 $FONTDIR touch -d @0 "$FONTDIR"
stat $FONTDIR | grep Modify > out1 stat "$FONTDIR" | grep Modify > out1
$FCCACHE $FONTDIR $FCCACHE "$FONTDIR"
stat $FONTDIR | grep Modify > out2 stat "$FONTDIR" | grep Modify > out2
if cmp out1 out2 > /dev/null ; then : ; else if cmp out1 out2 > /dev/null ; then : ; else
echo "*** Test failed: $TEST" echo "*** Test failed: $TEST"
echo "mtime was modified" echo "mtime was modified"
exit 1 exit 1
fi fi
if [ x"$BWRAP" != "x" -a "x$EXEEXT" = "x" ]; then if [ x"$BWRAP" != "x" ] && [ "x$EXEEXT" = "x" ]; then
dotest "Basic functionality with the bind-mounted cache dir" dotest "Basic functionality with the bind-mounted cache dir"
prep prep
cp $FONT1 $FONT2 $FONTDIR cp "$FONT1" "$FONT2" "$FONTDIR"
if [ -n ${SOURCE_DATE_EPOCH:-} ] && [ ${#SOURCE_DATE_EPOCH} -gt 0 ]; then if [ -n "${SOURCE_DATE_EPOCH:-}" ] && [ ${#SOURCE_DATE_EPOCH} -gt 0 ]; then
touch -m -t "`date -d \"@${SOURCE_DATE_EPOCH}\" +%y%m%d%H%M.%S`" $FONTDIR touch -m -t "$(date -d @"${SOURCE_DATE_EPOCH}" +%y%m%d%H%M.%S)" "$FONTDIR"
fi fi
$FCCACHE $FONTDIR $FCCACHE "$FONTDIR"
sleep 1 sleep 1
ls -l $CACHEDIR > out1 ls -l "$CACHEDIR" > out1
TESTTMPDIR=`mktemp -d /tmp/fontconfig.XXXXXXXX` TESTTMPDIR=$(mktemp -d /tmp/fontconfig.XXXXXXXX)
sed "s!@FONTDIR@!$TESTTMPDIR/fonts! sed "s!@FONTDIR@!$TESTTMPDIR/fonts!
s!@REMAPDIR@!<remap-dir as-path="'"'"$FONTDIR"'"'">$TESTTMPDIR/fonts</remap-dir>! s!@REMAPDIR@!<remap-dir as-path="'"'"$FONTDIR"'"'">$TESTTMPDIR/fonts</remap-dir>!
s!@CACHEDIR@!$TESTTMPDIR/cache.dir!" < $TESTDIR/fonts.conf.in > bind-fonts.conf 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/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 $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
$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 $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
ls -l $CACHEDIR > out2 ls -l "$CACHEDIR" > out2
if cmp out1 out2 > /dev/null ; then : ; else if cmp out1 out2 > /dev/null ; then : ; else
echo "*** Test failed: $TEST" echo "*** Test failed: $TEST"
echo "cache was created/updated." echo "cache was created/updated."
@ -180,7 +180,7 @@ if cmp out1 out2 > /dev/null ; then : ; else
cat out2 cat out2
exit 1 exit 1
fi fi
if [ x`cat xxx` != "x$TESTTMPDIR/fonts/4x6.pcf" ]; then if [ x"$(cat xxx)" != "x$TESTTMPDIR/fonts/4x6.pcf" ]; then
echo "*** Test failed: $TEST" echo "*** Test failed: $TEST"
echo "file property doesn't point to the new place: $TESTTMPDIR/fonts/4x6.pcf" echo "file property doesn't point to the new place: $TESTTMPDIR/fonts/4x6.pcf"
exit 1 exit 1
@ -194,45 +194,45 @@ if cmp flist1 flist2 > /dev/null ; then : ; else
cat flist1 cat flist1
exit 1 exit 1
fi fi
rm -rf $TESTTMPDIR out1 out2 xxx flist1 flist2 bind-fonts.conf rm -rf "$TESTTMPDIR" out1 out2 xxx flist1 flist2 bind-fonts.conf
dotest "Different directory content between host and sandbox" dotest "Different directory content between host and sandbox"
prep prep
cp $FONT1 $FONTDIR cp "$FONT1" "$FONTDIR"
if [ -n ${SOURCE_DATE_EPOCH:-} ] && [ ${#SOURCE_DATE_EPOCH} -gt 0 ]; then if [ -n "${SOURCE_DATE_EPOCH:-}" ] && [ ${#SOURCE_DATE_EPOCH} -gt 0 ]; then
touch -m -t "`date -d \"@${SOURCE_DATE_EPOCH}\" +%y%m%d%H%M.%S`" $FONTDIR touch -m -t "$(date -d @"${SOURCE_DATE_EPOCH}" +%y%m%d%H%M.%S)" "$FONTDIR"
fi fi
$FCCACHE $FONTDIR $FCCACHE "$FONTDIR"
sleep 1 sleep 1
ls -1 --color=no $CACHEDIR/*cache*> out1 ls -1 --color=no "$CACHEDIR"/*cache*> out1
stat -c '%n %s %y %z' `cat out1` > stat1 stat -c '%n %s %y %z' "$(cat out1)" > stat1
TESTTMPDIR=`mktemp -d /tmp/fontconfig.XXXXXXXX` TESTTMPDIR=$(mktemp -d /tmp/fontconfig.XXXXXXXX)
TESTTMP2DIR=`mktemp -d /tmp/fontconfig.XXXXXXXX` TESTTMP2DIR=$(mktemp -d /tmp/fontconfig.XXXXXXXX)
cp $FONT2 $TESTTMP2DIR cp "$FONT2" "$TESTTMP2DIR"
if [ -n ${SOURCE_DATE_EPOCH:-} ] && [ ${#SOURCE_DATE_EPOCH} -gt 0 ]; then if [ -n "${SOURCE_DATE_EPOCH:-}" ] && [ ${#SOURCE_DATE_EPOCH} -gt 0 ]; then
touch -m -t "`date -d \"@${SOURCE_DATE_EPOCH}\" +%y%m%d%H%M.%S`" $TESTTMP2DIR touch -m -t "$(date -d @"${SOURCE_DATE_EPOCH}" +%y%m%d%H%M.%S)" "$TESTTMP2DIR"
fi fi
sed "s!@FONTDIR@!$TESTTMPDIR/fonts</dir><dir salt="'"'"salt-to-make-different"'"'">$FONTDIR! sed "s!@FONTDIR@!$TESTTMPDIR/fonts</dir><dir salt="'"'"salt-to-make-different"'"'">$FONTDIR!
s!@REMAPDIR@!<remap-dir as-path="'"'"$FONTDIR"'"'">$TESTTMPDIR/fonts</remap-dir>! s!@REMAPDIR@!<remap-dir as-path="'"'"$FONTDIR"'"'">$TESTTMPDIR/fonts</remap-dir>!
s!@CACHEDIR@!$TESTTMPDIR/cache.dir!" < $TESTDIR/fonts.conf.in > bind-fonts.conf s!@CACHEDIR@!$TESTTMPDIR/cache.dir!" < "$TESTDIR"/fonts.conf.in > bind-fonts.conf
$BWRAP --bind / / --bind $CACHEDIR $TESTTMPDIR/cache.dir --bind $FONTDIR $TESTTMPDIR/fonts --bind $TESTTMP2DIR $FONTDIR --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 "$TESTTMP2DIR" "$FONTDIR" --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 $TESTTMP2DIR $FONTDIR --bind .. $TESTTMPDIR/build --dev-bind /dev /dev --setenv FONTCONFIG_FILE $TESTTMPDIR/build/test/bind-fonts.conf $TESTTMPDIR/build/test/test-bz106618$EXEEXT | sort > flist1 $BWRAP --bind / / --bind "$CACHEDIR" "$TESTTMPDIR"/cache.dir --bind "$FONTDIR" "$TESTTMPDIR"/fonts --bind "$TESTTMP2DIR" "$FONTDIR" --bind .. "$TESTTMPDIR"/build --dev-bind /dev /dev --setenv FONTCONFIG_FILE "$TESTTMPDIR"/build/test/bind-fonts.conf "$TESTTMPDIR"/build/test/test-bz106618"$EXEEXT" | sort > flist1
$BWRAP --bind / / --bind $CACHEDIR $TESTTMPDIR/cache.dir --bind $FONTDIR $TESTTMPDIR/fonts --bind $TESTTMP2DIR $FONTDIR --bind .. $TESTTMPDIR/build --dev-bind /dev /dev find $TESTTMPDIR/fonts/ -type f -name '*.pcf' | sort > flist2 $BWRAP --bind / / --bind "$CACHEDIR" "$TESTTMPDIR"/cache.dir --bind "$FONTDIR" "$TESTTMPDIR"/fonts --bind "$TESTTMP2DIR" "$FONTDIR" --bind .. "$TESTTMPDIR"/build --dev-bind /dev /dev find "$TESTTMPDIR"/fonts/ -type f -name '*.pcf' | sort > flist2
ls -1 --color=no $CACHEDIR/*cache* > out2 ls -1 --color=no "$CACHEDIR"/*cache* > out2
stat -c '%n %s %y %z' `cat out1` > stat2 stat -c '%n %s %y %z' "$(cat out1)" > stat2
if cmp stat1 stat2 > /dev/null ; then : ; else if cmp stat1 stat2 > /dev/null ; then : ; else
echo "*** Test failed: $TEST" echo "*** Test failed: $TEST"
echo "cache was created/updated." echo "cache was created/updated."
cat stat1 stat2 cat stat1 stat2
exit 1 exit 1
fi fi
if grep -v -- "`cat out1`" out2 > /dev/null ; then : ; else if grep -v -- "$(cat out1)" out2 > /dev/null ; then : ; else
echo "*** Test failed: $TEST" echo "*** Test failed: $TEST"
echo "cache wasn't created for dir inside sandbox." echo "cache wasn't created for dir inside sandbox."
cat out1 out2 cat out1 out2
exit 1 exit 1
fi fi
if [ x`cat xxx` != "x$TESTTMPDIR/fonts/4x6.pcf" ]; then if [ x"$(cat xxx)" != "x$TESTTMPDIR/fonts/4x6.pcf" ]; then
echo "*** Test failed: $TEST" echo "*** Test failed: $TEST"
echo "file property doesn't point to the new place: $TESTTMPDIR/fonts/4x6.pcf" echo "file property doesn't point to the new place: $TESTTMPDIR/fonts/4x6.pcf"
exit 1 exit 1
@ -246,25 +246,25 @@ if cmp flist1 flist2 > /dev/null ; then
cat flist1 cat flist1
exit 1 exit 1
fi fi
rm -rf $TESTTMPDIR $TESTTMP2DIR out1 out2 xxx flist1 flist2 stat1 stat2 bind-fonts.conf rm -rf "$TESTTMPDIR" "$TESTTMP2DIR" out1 out2 xxx flist1 flist2 stat1 stat2 bind-fonts.conf
dotest "Check consistency of MD5 in cache name" dotest "Check consistency of MD5 in cache name"
prep prep
mkdir -p $FONTDIR/sub mkdir -p "$FONTDIR"/sub
cp $FONT1 $FONTDIR/sub cp "$FONT1" "$FONTDIR"/sub
if [ -n ${SOURCE_DATE_EPOCH:-} ] && [ ${#SOURCE_DATE_EPOCH} -gt 0 ]; then if [ -n "${SOURCE_DATE_EPOCH:-}" ] && [ ${#SOURCE_DATE_EPOCH} -gt 0 ]; then
touch -m -t "`date -d \"@${SOURCE_DATE_EPOCH}\" +%y%m%d%H%M.%S`" $FONTDIR/sub touch -m -t "$(date -d @"${SOURCE_DATE_EPOCH}" +%y%m%d%H%M.%S)" "$FONTDIR"/sub
fi fi
$FCCACHE $FONTDIR $FCCACHE "$FONTDIR"
sleep 1 sleep 1
(cd $CACHEDIR; ls -1 --color=no *cache*) > out1 (cd "$CACHEDIR"; ls -1 --color=no ./*cache*) > out1
TESTTMPDIR=`mktemp -d /tmp/fontconfig.XXXXXXXX` TESTTMPDIR=$(mktemp -d /tmp/fontconfig.XXXXXXXX)
mkdir -p $TESTTMPDIR/cache.dir mkdir -p "$TESTTMPDIR"/cache.dir
sed "s!@FONTDIR@!$TESTTMPDIR/fonts! sed "s!@FONTDIR@!$TESTTMPDIR/fonts!
s!@REMAPDIR@!<remap-dir as-path="'"'"$FONTDIR"'"'">$TESTTMPDIR/fonts</remap-dir>! s!@REMAPDIR@!<remap-dir as-path="'"'"$FONTDIR"'"'">$TESTTMPDIR/fonts</remap-dir>!
s!@CACHEDIR@!$TESTTMPDIR/cache.dir!" < $TESTDIR/fonts.conf.in > bind-fonts.conf s!@CACHEDIR@!$TESTTMPDIR/cache.dir!" < "$TESTDIR"/fonts.conf.in > bind-fonts.conf
$BWRAP --bind / / --bind $FONTDIR $TESTTMPDIR/fonts --bind .. $TESTTMPDIR/build --dev-bind /dev /dev --setenv FONTCONFIG_FILE $TESTTMPDIR/build/test/bind-fonts.conf $TESTTMPDIR/build/fc-cache/fc-cache$EXEEXT $TESTTMPDIR/fonts $BWRAP --bind / / --bind "$FONTDIR" "$TESTTMPDIR"/fonts --bind .. "$TESTTMPDIR"/build --dev-bind /dev /dev --setenv FONTCONFIG_FILE "$TESTTMPDIR"/build/test/bind-fonts.conf "$TESTTMPDIR"/build/fc-cache/fc-cache"$EXEEXT" "$TESTTMPDIR"/fonts
(cd $TESTTMPDIR/cache.dir; ls -1 --color=no *cache*) > out2 (cd "$TESTTMPDIR"/cache.dir; ls -1 --color=no ./*cache*) > out2
if cmp out1 out2 > /dev/null ; then : ; else if cmp out1 out2 > /dev/null ; then : ; else
echo "*** Test failed: $TEST" echo "*** Test failed: $TEST"
echo "cache was created unexpectedly." echo "cache was created unexpectedly."
@ -274,32 +274,32 @@ if cmp out1 out2 > /dev/null ; then : ; else
cat out2 cat out2
exit 1 exit 1
fi fi
rm -rf $TESTTMPDIR out1 out2 bind-fonts.conf rm -rf "$TESTTMPDIR" out1 out2 bind-fonts.conf
dotest "Fallback to uuid" dotest "Fallback to uuid"
prep prep
cp $FONT1 $FONTDIR cp "$FONT1" "$FONTDIR"
if [ -n ${SOURCE_DATE_EPOCH:-} ] && [ ${#SOURCE_DATE_EPOCH} -gt 0 ]; then if [ -n "${SOURCE_DATE_EPOCH:-}" ] && [ ${#SOURCE_DATE_EPOCH} -gt 0 ]; then
touch -m -t "`date -d \"@${SOURCE_DATE_EPOCH}\" +%y%m%d%H%M.%S`" $FONTDIR touch -m -t "$(date -d @"${SOURCE_DATE_EPOCH}" +%y%m%d%H%M.%S)" "$FONTDIR"
fi fi
touch -d @`stat -c %Y $FONTDIR` $FONTDIR touch -d @"$(stat -c %Y "$FONTDIR")" "$FONTDIR"
$FCCACHE $FONTDIR $FCCACHE "$FONTDIR"
sleep 1 sleep 1
_cache=`ls -1 --color=no $CACHEDIR/*cache*` _cache=$(ls -1 --color=no "$CACHEDIR"/*cache*)
_mtime=`stat -c %Y $FONTDIR` _mtime=$(stat -c %Y "$FONTDIR")
_uuid=`uuidgen` _uuid=$(uuidgen)
_newcache=`echo $_cache | sed "s/\([0-9a-f]*\)\(\-.*\)/$_uuid\2/"` _newcache=$(echo "$_cache" | sed "s/\([0-9a-f]*\)\(\-.*\)/$_uuid\2/")
mv $_cache $_newcache mv "$_cache" "$_newcache"
echo $_uuid > $FONTDIR/.uuid echo "$_uuid" > "$FONTDIR"/.uuid
touch -d @$_mtime $FONTDIR touch -d @"$_mtime" "$FONTDIR"
(cd $CACHEDIR; ls -1 --color=no *cache*) > out1 (cd "$CACHEDIR"; ls -1 --color=no ./*cache*) > out1
TESTTMPDIR=`mktemp -d /tmp/fontconfig.XXXXXXXX` TESTTMPDIR=$(mktemp -d /tmp/fontconfig.XXXXXXXX)
mkdir -p $TESTTMPDIR/cache.dir mkdir -p "$TESTTMPDIR"/cache.dir
sed "s!@FONTDIR@!$TESTTMPDIR/fonts! sed "s!@FONTDIR@!$TESTTMPDIR/fonts!
s!@REMAPDIR@!<remap-dir as-path="'"'"$FONTDIR"'"'">$TESTTMPDIR/fonts</remap-dir>! s!@REMAPDIR@!<remap-dir as-path="'"'"$FONTDIR"'"'">$TESTTMPDIR/fonts</remap-dir>!
s!@CACHEDIR@!$TESTTMPDIR/cache.dir!" < $TESTDIR/fonts.conf.in > bind-fonts.conf 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 "" $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 ""
(cd $CACHEDIR; ls -1 --color=no *cache*) > out2 (cd "$CACHEDIR"; ls -1 --color=no ./*cache*) > out2
if cmp out1 out2 > /dev/null ; then : ; else if cmp out1 out2 > /dev/null ; then : ; else
echo "*** Test failed: $TEST" echo "*** Test failed: $TEST"
echo "cache was created unexpectedly." echo "cache was created unexpectedly."
@ -309,7 +309,7 @@ if cmp out1 out2 > /dev/null ; then : ; else
cat out2 cat out2
exit 1 exit 1
fi fi
rm -rf $TESTTMPDIR out1 out2 bind-fonts.conf rm -rf "$TESTTMPDIR" out1 out2 bind-fonts.conf
else else
echo "No bubblewrap installed. skipping..." echo "No bubblewrap installed. skipping..."
@ -318,51 +318,50 @@ fi # if [ x"$BWRAP" != "x" -a "x$EXEEXT" = "x" ]
if [ "x$EXEEXT" = "x" ]; then if [ "x$EXEEXT" = "x" ]; then
dotest "sysroot option" dotest "sysroot option"
prep prep
mkdir -p $MyPWD/sysroot/$FONTDIR mkdir -p "$MyPWD"/sysroot/"$FONTDIR"
mkdir -p $MyPWD/sysroot/$CACHEDIR mkdir -p "$MyPWD"/sysroot/"$CACHEDIR"
mkdir -p $MyPWD/sysroot/$MyPWD mkdir -p "$MyPWD"/sysroot/"$MyPWD"
cp $FONT1 $MyPWD/sysroot/$FONTDIR cp "$FONT1" "$MyPWD"/sysroot/"$FONTDIR"
if [ -n ${SOURCE_DATE_EPOCH:-} ] && [ ${#SOURCE_DATE_EPOCH} -gt 0 ]; then if [ -n "${SOURCE_DATE_EPOCH:-}" ] && [ ${#SOURCE_DATE_EPOCH} -gt 0 ]; then
touch -m -t "`date -d \"@${SOURCE_DATE_EPOCH}\" +%y%m%d%H%M.%S`" $MyPWD/sysroot/$FONTDIR touch -m -t "$(date -d @"${SOURCE_DATE_EPOCH}" +%y%m%d%H%M.%S)" "$MyPWD"/sysroot/"$FONTDIR"
fi fi
cp $MyPWD/fonts.conf $MyPWD/sysroot/$MyPWD/fonts.conf cp "$MyPWD"/fonts.conf "$MyPWD"/sysroot/"$MyPWD"/fonts.conf
$FCCACHE -y $MyPWD/sysroot $FCCACHE -y "$MyPWD"/sysroot
dotest "creating cache file on sysroot" dotest "creating cache file on sysroot"
md5=`echo -n $FONTDIR | md5sum | sed 's/ .*$//'` md5=$(printf "%s" "$FONTDIR" | md5sum | sed 's/ .*$//')
echo "checking for cache file $md5" echo "checking for cache file $md5"
ls "$MyPWD/sysroot/$CACHEDIR/$md5"* if ! ls "$MyPWD/sysroot/$CACHEDIR/$md5"*; then
if [ $? != 0 ]; then
echo "*** Test failed: $TEST" echo "*** Test failed: $TEST"
echo "No cache for $FONTDIR ($md5)" echo "No cache for $FONTDIR ($md5)"
ls $MyPWD/sysroot/$CACHEDIR ls "$MyPWD"/sysroot/"$CACHEDIR"
exit 1 exit 1
fi fi
rm -rf $MyPWD/sysroot rm -rf "$MyPWD"/sysroot
dotest "read newer caches when multiple places are allowed to store" dotest "read newer caches when multiple places are allowed to store"
prep prep
cp $FONT1 $FONT2 $FONTDIR cp "$FONT1" "$FONT2" "$FONTDIR"
if [ -n ${SOURCE_DATE_EPOCH:-} ] && [ ${#SOURCE_DATE_EPOCH} -gt 0 ]; then if [ -n "${SOURCE_DATE_EPOCH:-}" ] && [ ${#SOURCE_DATE_EPOCH} -gt 0 ]; then
touch -m -t "`date -d \"@${SOURCE_DATE_EPOCH}\" +%y%m%d%H%M.%S`" $FONTDIR touch -m -t "$(date -d @"${SOURCE_DATE_EPOCH}" +%y%m%d%H%M.%S)" "$FONTDIR"
fi fi
MYCACHEBASEDIR=`mktemp -d /tmp/fontconfig.XXXXXXXX` MYCACHEBASEDIR=$(mktemp -d /tmp/fontconfig.XXXXXXXX)
MYCACHEDIR=$MYCACHEBASEDIR/cache.dir MYCACHEDIR="$MYCACHEBASEDIR"/cache.dir
MYOWNCACHEDIR=$MYCACHEBASEDIR/owncache.dir MYOWNCACHEDIR="$MYCACHEBASEDIR"/owncache.dir
MYCONFIG=`mktemp /tmp/fontconfig.XXXXXXXX` MYCONFIG=$(mktemp /tmp/fontconfig.XXXXXXXX)
mkdir -p $MYCACHEDIR mkdir -p "$MYCACHEDIR"
mkdir -p $MYOWNCACHEDIR mkdir -p "$MYOWNCACHEDIR"
sed "s!@FONTDIR@!$FONTDIR! sed "s!@FONTDIR@!$FONTDIR!
s!@REMAPDIR@!! s!@REMAPDIR@!!
s!@CACHEDIR@!$MYCACHEDIR!" < $TESTDIR/fonts.conf.in > my-fonts.conf s!@CACHEDIR@!$MYCACHEDIR!" < "$TESTDIR"/fonts.conf.in > my-fonts.conf
FONTCONFIG_FILE=$MyPWD/my-fonts.conf $FCCACHE $FONTDIR FONTCONFIG_FILE="$MyPWD"/my-fonts.conf $FCCACHE "$FONTDIR"
sleep 1 sleep 1
cat<<EOF>$MYCONFIG cat<<EOF>"$MYCONFIG"
<fontconfig> <fontconfig>
<match target="scan"> <match target="scan">
<test name="file"><string>$FONTDIR/4x6.pcf</string></test> <test name="file"><string>$FONTDIR/4x6.pcf</string></test>
@ -372,28 +371,30 @@ cat<<EOF>$MYCONFIG
EOF EOF
sed "s!@FONTDIR@!$FONTDIR! sed "s!@FONTDIR@!$FONTDIR!
s!@REMAPDIR@!<include ignore_missing=\"yes\">$MYCONFIG</include>! s!@REMAPDIR@!<include ignore_missing=\"yes\">$MYCONFIG</include>!
s!@CACHEDIR@!$MYOWNCACHEDIR!" < $TESTDIR/fonts.conf.in > my-fonts.conf s!@CACHEDIR@!$MYOWNCACHEDIR!" < "$TESTDIR"/fonts.conf.in > my-fonts.conf
if [ -n ${SOURCE_DATE_EPOCH:-} ]; then if [ -n "${SOURCE_DATE_EPOCH:-}" ]; then
old_epoch=${SOURCE_DATE_EPOCH} old_epoch=${SOURCE_DATE_EPOCH}
SOURCE_DATE_EPOCH=`expr $SOURCE_DATE_EPOCH + 1` SOURCE_DATE_EPOCH=$(("$SOURCE_DATE_EPOCH" + 1))
fi fi
FONTCONFIG_FILE=$MyPWD/my-fonts.conf $FCCACHE -f $FONTDIR FONTCONFIG_FILE="$MyPWD"/my-fonts.conf $FCCACHE -f "$FONTDIR"
if [ -n ${SOURCE_DATE_EPOCH:-} ]; then if [ -n "${SOURCE_DATE_EPOCH:-}" ]; then
SOURCE_DATE_EPOCH=${old_epoch} SOURCE_DATE_EPOCH=${old_epoch}
fi fi
sed "s!@FONTDIR@!$FONTDIR! sed "s!@FONTDIR@!$FONTDIR!
s!@REMAPDIR@!<include ignore_missing=\"yes\">$MYCONFIG</include>! s!@REMAPDIR@!<include ignore_missing=\"yes\">$MYCONFIG</include>!
s!@CACHEDIR@!$MYCACHEDIR</cachedir><cachedir>$MYOWNCACHEDIR!" < $TESTDIR/fonts.conf.in > my-fonts.conf s!@CACHEDIR@!$MYCACHEDIR</cachedir><cachedir>$MYOWNCACHEDIR!" < "$TESTDIR"/fonts.conf.in > my-fonts.conf
FONTCONFIG_FILE=$MyPWD/my-fonts.conf $FCLIST - family pixelsize | sort > my-out {
echo "=" >> my-out FONTCONFIG_FILE="$MyPWD"/my-fonts.conf $FCLIST - family pixelsize | sort;
FONTCONFIG_FILE=$MyPWD/my-fonts.conf $FCLIST - family pixelsize | sort >> my-out echo "=";
echo "=" >> my-out FONTCONFIG_FILE="$MyPWD"/my-fonts.conf $FCLIST - family pixelsize | sort;
FONTCONFIG_FILE=$MyPWD/my-fonts.conf $FCLIST - family pixelsize | sort >> my-out echo "=";
FONTCONFIG_FILE="$MyPWD"/my-fonts.conf $FCLIST - family pixelsize | sort;
} > my-out
tr -d '\015' <my-out >my-out.tmp; mv my-out.tmp my-out tr -d '\015' <my-out >my-out.tmp; mv my-out.tmp my-out
sed -e 's/pixelsize=6/pixelsize=8/g' $BUILDTESTDIR/$EXPECTED > my-out.expected sed -e 's/pixelsize=6/pixelsize=8/g' "$BUILDTESTDIR"/"$EXPECTED" > my-out.expected
if cmp my-out my-out.expected > /dev/null ; then : ; else if cmp my-out my-out.expected > /dev/null ; then : ; else
echo "*** Test failed: $TEST" echo "*** Test failed: $TEST"
@ -405,21 +406,21 @@ if cmp my-out my-out.expected > /dev/null ; then : ; else
exit 1 exit 1
fi fi
rm -rf $MYCACHEBASEDIR $MYCONFIG my-fonts.conf my-out my-out.expected rm -rf "$MYCACHEBASEDIR" "$MYCONFIG" my-fonts.conf my-out my-out.expected
fi # if [ "x$EXEEXT" = "x" ] fi # if [ "x$EXEEXT" = "x" ]
if [ -x $BUILDTESTDIR/test-crbug1004254 ]; then if [ -x "$BUILDTESTDIR"/test-crbug1004254 ]; then
dotest "MT-safe global config" dotest "MT-safe global config"
prep prep
curl -s -o $FONTDIR/noto.zip https://noto-website-2.storage.googleapis.com/pkgs/NotoSans-hinted.zip curl -s -o "$FONTDIR"/noto.zip https://noto-website-2.storage.googleapis.com/pkgs/NotoSans-hinted.zip
(cd $FONTDIR; unzip noto.zip) (cd "$FONTDIR"; unzip noto.zip)
if [ -n ${SOURCE_DATE_EPOCH:-} ] && [ ${#SOURCE_DATE_EPOCH} -gt 0 ]; then if [ -n "${SOURCE_DATE_EPOCH:-}" ] && [ ${#SOURCE_DATE_EPOCH} -gt 0 ]; then
touch -m -t "`date -d \"@${SOURCE_DATE_EPOCH}\" +%y%m%d%H%M.%S`" $FONTDIR touch -m -t "$(date -d @"${SOURCE_DATE_EPOCH}" +%y%m%d%H%M.%S)" "$FONTDIR"
fi fi
$BUILDTESTDIR/test-crbug1004254 "$BUILDTESTDIR"/test-crbug1004254
else else
echo "No test-crbug1004254: skipped" echo "No test-crbug1004254: skipped"
fi fi
rm -rf $FONTDIR $CACHEFILE $CACHEDIR $BASEDIR $FONTCONFIG_FILE out rm -rf "$FONTDIR" "$CACHEFILE" "$CACHEDIR" "$BASEDIR" "$FONTCONFIG_FILE" out