2020-04-10 10:27:15 +02:00
|
|
|
#!/bin/bash
|
2014-01-17 05:05:25 +01:00
|
|
|
# fontconfig/test/run-test.sh
|
|
|
|
#
|
|
|
|
# Copyright © 2000 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 author(s) not be used in
|
|
|
|
# advertising or publicity pertaining to distribution of the software without
|
|
|
|
# specific, written prior permission. The authors make no
|
|
|
|
# representations about the suitability of this software for any purpose. It
|
|
|
|
# is provided "as is" without express or implied warranty.
|
|
|
|
#
|
|
|
|
# THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
|
|
|
# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
|
|
|
# EVENT SHALL THE AUTHOR(S) 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.
|
2019-11-01 06:43:42 +01:00
|
|
|
set -e
|
|
|
|
|
2021-07-09 00:29:16 +02:00
|
|
|
: "${TMPDIR=/tmp}"
|
|
|
|
|
2015-11-24 02:46:34 +01:00
|
|
|
case "$OSTYPE" in
|
2020-04-10 10:27:15 +02:00
|
|
|
msys ) MyPWD=$(pwd -W) ;; # On Msys/MinGW, returns a MS Windows style path.
|
|
|
|
* ) MyPWD=$(pwd) ;; # On any other platforms, returns a Unix style path.
|
2015-11-24 02:46:34 +01:00
|
|
|
esac
|
2003-10-27 11:44:13 +01:00
|
|
|
|
2015-11-24 02:46:34 +01:00
|
|
|
TESTDIR=${srcdir-"$MyPWD"}
|
2018-03-28 11:53:52 +02:00
|
|
|
BUILDTESTDIR=${builddir-"$MyPWD"}
|
2015-11-24 02:46:34 +01:00
|
|
|
|
2021-07-09 00:29:16 +02:00
|
|
|
BASEDIR=$(mktemp -d "$TMPDIR"/fontconfig.XXXXXXXX)
|
2019-03-26 06:07:34 +01:00
|
|
|
FONTDIR="$BASEDIR"/fonts
|
|
|
|
CACHEDIR="$BASEDIR"/cache.dir
|
2017-03-21 04:25:45 +01:00
|
|
|
EXPECTED=${EXPECTED-"out.expected"}
|
2003-03-01 06:55:17 +01:00
|
|
|
|
2019-03-22 08:45:09 +01:00
|
|
|
FCLIST="$LOG_COMPILER ../fc-list/fc-list$EXEEXT"
|
|
|
|
FCCACHE="$LOG_COMPILER ../fc-cache/fc-cache$EXEEXT"
|
2003-03-01 06:55:17 +01:00
|
|
|
|
2019-12-05 11:55:06 +01:00
|
|
|
if [ -x "$(command -v bwrap)" ]; then
|
|
|
|
BWRAP="$(command -v bwrap)"
|
2017-11-15 15:30:26 +01:00
|
|
|
fi
|
|
|
|
|
2003-10-27 11:44:13 +01:00
|
|
|
FONT1=$TESTDIR/4x6.pcf
|
|
|
|
FONT2=$TESTDIR/8x16.pcf
|
2020-08-25 05:49:30 +02:00
|
|
|
TEST=""
|
|
|
|
|
|
|
|
clean_exit() {
|
|
|
|
rc=$?
|
Portable trap conditions in run-test.sh.
Posix says:
The condition can be EXIT, 0 (equivalent to EXIT), or a signal
specified using a symbolic name, without the SIG prefix, as listed
in the tables of signal names in the <signal.h> header defined in
the Base Definitions volume of IEEE Std 1003.1-2001, Chapter 13,
Headers; for example, HUP, INT, QUIT, TERM. Implementations may
permit names with the SIG prefix or ignore case in signal names as
an extension.
Remove 'SIG' from trap conditions in run-test.sh for portability.
2020-12-10 20:00:40 +01:00
|
|
|
trap - INT TERM ABRT EXIT
|
2020-08-25 05:49:30 +02:00
|
|
|
if [ "x$TEST" != "x" ]; then
|
|
|
|
echo "Aborting from '$TEST' with the exit code $rc"
|
|
|
|
fi
|
|
|
|
exit $rc
|
|
|
|
}
|
Portable trap conditions in run-test.sh.
Posix says:
The condition can be EXIT, 0 (equivalent to EXIT), or a signal
specified using a symbolic name, without the SIG prefix, as listed
in the tables of signal names in the <signal.h> header defined in
the Base Definitions volume of IEEE Std 1003.1-2001, Chapter 13,
Headers; for example, HUP, INT, QUIT, TERM. Implementations may
permit names with the SIG prefix or ignore case in signal names as
an extension.
Remove 'SIG' from trap conditions in run-test.sh for portability.
2020-12-10 20:00:40 +01:00
|
|
|
trap clean_exit INT TERM ABRT EXIT
|
2003-10-27 11:44:13 +01:00
|
|
|
|
2003-03-01 06:55:17 +01:00
|
|
|
check () {
|
2020-04-10 10:27:15 +02:00
|
|
|
{
|
|
|
|
$FCLIST - family pixelsize | sort;
|
|
|
|
echo "=";
|
|
|
|
$FCLIST - family pixelsize | sort;
|
|
|
|
echo "=";
|
|
|
|
$FCLIST - family pixelsize | sort;
|
|
|
|
} > out
|
2003-06-16 00:57:21 +02:00
|
|
|
tr -d '\015' <out >out.tmp; mv out.tmp out
|
2020-04-10 10:27:15 +02:00
|
|
|
if cmp out "$BUILDTESTDIR"/"$EXPECTED" > /dev/null ; then : ; else
|
2003-03-01 06:55:17 +01:00
|
|
|
echo "*** Test failed: $TEST"
|
2017-03-21 04:25:45 +01:00
|
|
|
echo "*** output is in 'out', expected output in '$EXPECTED'"
|
2003-10-27 11:44:13 +01:00
|
|
|
exit 1
|
2003-03-01 06:55:17 +01:00
|
|
|
fi
|
2018-08-29 12:01:45 +02:00
|
|
|
rm -f out
|
2003-03-01 06:55:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
prep() {
|
2020-04-10 10:27:15 +02:00
|
|
|
rm -rf "$CACHEDIR"
|
|
|
|
rm -rf "$FONTDIR"
|
|
|
|
mkdir "$FONTDIR"
|
2003-03-01 06:55:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
dotest () {
|
|
|
|
TEST=$1
|
2020-04-10 10:27:15 +02:00
|
|
|
test x"$VERBOSE" = x || echo "Running: $TEST"
|
2003-03-01 06:55:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
sed "s!@FONTDIR@!$FONTDIR!
|
2019-01-29 08:03:58 +01:00
|
|
|
s!@REMAPDIR@!!
|
2020-04-10 10:27:15 +02:00
|
|
|
s!@CACHEDIR@!$CACHEDIR!" < "$TESTDIR"/fonts.conf.in > fonts.conf
|
2003-03-01 06:55:17 +01:00
|
|
|
|
2015-11-24 02:46:34 +01:00
|
|
|
FONTCONFIG_FILE="$MyPWD"/fonts.conf
|
2003-03-01 06:55:17 +01:00
|
|
|
export FONTCONFIG_FILE
|
|
|
|
|
|
|
|
dotest "Basic check"
|
|
|
|
prep
|
2020-04-10 10:27:15 +02:00
|
|
|
cp "$FONT1" "$FONT2" "$FONTDIR"
|
|
|
|
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"
|
2019-07-31 15:18:51 +02:00
|
|
|
fi
|
2003-03-01 06:55:17 +01:00
|
|
|
check
|
|
|
|
|
|
|
|
dotest "With a subdir"
|
|
|
|
prep
|
2020-04-10 10:27:15 +02:00
|
|
|
cp "$FONT1" "$FONT2" "$FONTDIR"
|
|
|
|
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"
|
2019-07-31 15:18:51 +02:00
|
|
|
fi
|
2020-04-10 10:27:15 +02:00
|
|
|
$FCCACHE "$FONTDIR"
|
2003-03-01 06:55:17 +01:00
|
|
|
check
|
|
|
|
|
|
|
|
dotest "Subdir with a cache file"
|
|
|
|
prep
|
2020-04-10 10:27:15 +02:00
|
|
|
mkdir "$FONTDIR"/a
|
|
|
|
cp "$FONT1" "$FONT2" "$FONTDIR"/a
|
|
|
|
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
|
2019-07-31 15:18:51 +02:00
|
|
|
fi
|
2020-04-10 10:27:15 +02:00
|
|
|
$FCCACHE "$FONTDIR"/a
|
2003-03-01 06:55:17 +01:00
|
|
|
check
|
|
|
|
|
|
|
|
dotest "Complicated directory structure"
|
|
|
|
prep
|
2020-04-10 10:27:15 +02:00
|
|
|
mkdir "$FONTDIR"/a
|
|
|
|
mkdir "$FONTDIR"/a/a
|
|
|
|
mkdir "$FONTDIR"/b
|
|
|
|
mkdir "$FONTDIR"/b/a
|
|
|
|
cp "$FONT1" "$FONTDIR"/a
|
|
|
|
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
|
2019-07-31 15:18:51 +02:00
|
|
|
fi
|
2020-04-10 10:27:15 +02:00
|
|
|
cp "$FONT2" "$FONTDIR"/b/a
|
|
|
|
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
|
2019-07-31 15:18:51 +02:00
|
|
|
fi
|
2003-03-01 06:55:17 +01:00
|
|
|
check
|
|
|
|
|
|
|
|
dotest "Subdir with an out-of-date cache file"
|
|
|
|
prep
|
2020-04-10 10:27:15 +02:00
|
|
|
mkdir "$FONTDIR"/a
|
|
|
|
$FCCACHE "$FONTDIR"/a
|
2003-03-01 06:55:17 +01:00
|
|
|
sleep 1
|
2020-04-10 10:27:15 +02:00
|
|
|
cp "$FONT1" "$FONT2" "$FONTDIR"/a
|
2003-03-01 06:55:17 +01:00
|
|
|
check
|
|
|
|
|
|
|
|
dotest "Dir with an out-of-date cache file"
|
|
|
|
prep
|
2020-04-10 10:27:15 +02:00
|
|
|
cp "$FONT1" "$FONTDIR"
|
|
|
|
$FCCACHE "$FONTDIR"
|
2003-03-01 06:55:17 +01:00
|
|
|
sleep 1
|
2020-04-10 10:27:15 +02:00
|
|
|
mkdir "$FONTDIR"/a
|
|
|
|
cp "$FONT2" "$FONTDIR"/a
|
2003-03-01 06:55:17 +01:00
|
|
|
check
|
|
|
|
|
2017-12-18 13:26:29 +01:00
|
|
|
dotest "Keep mtime of the font directory"
|
|
|
|
prep
|
2020-04-10 10:27:15 +02:00
|
|
|
cp "$FONT1" "$FONTDIR"
|
|
|
|
touch -d @0 "$FONTDIR"
|
2020-12-08 14:26:25 +01:00
|
|
|
stat -c '%y' "$FONTDIR" > out1
|
2020-04-10 10:27:15 +02:00
|
|
|
$FCCACHE "$FONTDIR"
|
2020-12-08 14:26:25 +01:00
|
|
|
stat -c '%y' "$FONTDIR" > out2
|
2017-12-18 13:26:29 +01:00
|
|
|
if cmp out1 out2 > /dev/null ; then : ; else
|
|
|
|
echo "*** Test failed: $TEST"
|
|
|
|
echo "mtime was modified"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2020-04-10 10:27:15 +02:00
|
|
|
if [ x"$BWRAP" != "x" ] && [ "x$EXEEXT" = "x" ]; then
|
2017-11-15 15:30:26 +01:00
|
|
|
dotest "Basic functionality with the bind-mounted cache dir"
|
|
|
|
prep
|
2020-04-10 10:27:15 +02:00
|
|
|
cp "$FONT1" "$FONT2" "$FONTDIR"
|
|
|
|
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"
|
2019-07-31 15:18:51 +02:00
|
|
|
fi
|
2020-04-10 10:27:15 +02:00
|
|
|
$FCCACHE "$FONTDIR"
|
2017-11-15 15:30:26 +01:00
|
|
|
sleep 1
|
2020-04-10 10:27:15 +02:00
|
|
|
ls -l "$CACHEDIR" > out1
|
2021-07-09 00:29:16 +02:00
|
|
|
TESTTMPDIR=$(mktemp -d "$TMPDIR"/fontconfig.XXXXXXXX)
|
2022-09-28 16:30:06 +02:00
|
|
|
# Once font dir is remapped, we could use $FONTDIR as different one in theory.
|
|
|
|
# but we don't use it here and to avoid duplicate entries, set the non-existing
|
|
|
|
# directory here.
|
|
|
|
sed "s!@FONTDIR@!$FONTDIR/a!
|
2019-01-29 08:03:58 +01:00
|
|
|
s!@REMAPDIR@!<remap-dir as-path="'"'"$FONTDIR"'"'">$TESTTMPDIR/fonts</remap-dir>!
|
2020-04-10 10:27:15 +02:00
|
|
|
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
|
2022-09-28 17:04:00 +02:00
|
|
|
$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
|
2020-04-10 10:27:15 +02:00
|
|
|
$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
|
2019-01-29 08:03:58 +01:00
|
|
|
if cmp out1 out2 > /dev/null ; then : ; else
|
|
|
|
echo "*** Test failed: $TEST"
|
|
|
|
echo "cache was created/updated."
|
2019-04-04 08:47:34 +02:00
|
|
|
echo "Before:"
|
|
|
|
cat out1
|
|
|
|
echo "After:"
|
|
|
|
cat out2
|
2019-01-29 08:03:58 +01:00
|
|
|
exit 1
|
|
|
|
fi
|
2020-04-10 10:27:15 +02:00
|
|
|
if [ x"$(cat xxx)" != "x$TESTTMPDIR/fonts/4x6.pcf" ]; then
|
2017-11-15 15:30:26 +01:00
|
|
|
echo "*** Test failed: $TEST"
|
2018-05-25 08:24:44 +02:00
|
|
|
echo "file property doesn't point to the new place: $TESTTMPDIR/fonts/4x6.pcf"
|
2017-11-15 15:30:26 +01:00
|
|
|
exit 1
|
|
|
|
fi
|
2018-05-25 08:24:44 +02:00
|
|
|
if cmp flist1 flist2 > /dev/null ; then : ; else
|
|
|
|
echo "*** Test failed: $TEST"
|
|
|
|
echo "file properties doesn't point to the new places"
|
|
|
|
echo "Expected result:"
|
|
|
|
cat flist2
|
|
|
|
echo "Actual result:"
|
|
|
|
cat flist1
|
|
|
|
exit 1
|
|
|
|
fi
|
2020-04-10 10:27:15 +02:00
|
|
|
rm -rf "$TESTTMPDIR" out1 out2 xxx flist1 flist2 bind-fonts.conf
|
2019-01-31 11:17:47 +01:00
|
|
|
|
|
|
|
dotest "Different directory content between host and sandbox"
|
|
|
|
prep
|
2020-04-10 10:27:15 +02:00
|
|
|
cp "$FONT1" "$FONTDIR"
|
|
|
|
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"
|
2019-07-31 15:18:51 +02:00
|
|
|
fi
|
2020-04-10 10:27:15 +02:00
|
|
|
$FCCACHE "$FONTDIR"
|
2019-01-31 11:17:47 +01:00
|
|
|
sleep 1
|
2020-04-10 10:27:15 +02:00
|
|
|
ls -1 --color=no "$CACHEDIR"/*cache*> out1
|
|
|
|
stat -c '%n %s %y %z' "$(cat out1)" > stat1
|
2021-07-09 00:29:16 +02:00
|
|
|
TESTTMPDIR=$(mktemp -d "$TMPDIR"/fontconfig.XXXXXXXX)
|
|
|
|
TESTTMP2DIR=$(mktemp -d "$TMPDIR"/fontconfig.XXXXXXXX)
|
2020-04-10 10:27:15 +02:00
|
|
|
cp "$FONT2" "$TESTTMP2DIR"
|
|
|
|
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"
|
2019-07-31 15:18:51 +02:00
|
|
|
fi
|
2019-01-31 11:17:47 +01:00
|
|
|
sed "s!@FONTDIR@!$TESTTMPDIR/fonts</dir><dir salt="'"'"salt-to-make-different"'"'">$FONTDIR!
|
|
|
|
s!@REMAPDIR@!<remap-dir as-path="'"'"$FONTDIR"'"'">$TESTTMPDIR/fonts</remap-dir>!
|
2020-04-10 10:27:15 +02:00
|
|
|
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/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
|
|
|
|
ls -1 --color=no "$CACHEDIR"/*cache* > out2
|
|
|
|
stat -c '%n %s %y %z' "$(cat out1)" > stat2
|
2019-01-31 11:17:47 +01:00
|
|
|
if cmp stat1 stat2 > /dev/null ; then : ; else
|
|
|
|
echo "*** Test failed: $TEST"
|
|
|
|
echo "cache was created/updated."
|
|
|
|
cat stat1 stat2
|
|
|
|
exit 1
|
|
|
|
fi
|
2020-04-10 10:27:15 +02:00
|
|
|
if grep -v -- "$(cat out1)" out2 > /dev/null ; then : ; else
|
2019-01-31 11:17:47 +01:00
|
|
|
echo "*** Test failed: $TEST"
|
|
|
|
echo "cache wasn't created for dir inside sandbox."
|
|
|
|
cat out1 out2
|
|
|
|
exit 1
|
|
|
|
fi
|
2020-04-10 10:27:15 +02:00
|
|
|
if [ x"$(cat xxx)" != "x$TESTTMPDIR/fonts/4x6.pcf" ]; then
|
2019-01-31 11:17:47 +01:00
|
|
|
echo "*** Test failed: $TEST"
|
|
|
|
echo "file property doesn't point to the new place: $TESTTMPDIR/fonts/4x6.pcf"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
if cmp flist1 flist2 > /dev/null ; then
|
|
|
|
echo "*** Test failed: $TEST"
|
|
|
|
echo "Missing fonts should be available on sandbox"
|
|
|
|
echo "Expected result:"
|
|
|
|
cat flist2
|
|
|
|
echo "Actual result:"
|
|
|
|
cat flist1
|
|
|
|
exit 1
|
|
|
|
fi
|
2020-04-10 10:27:15 +02:00
|
|
|
rm -rf "$TESTTMPDIR" "$TESTTMP2DIR" out1 out2 xxx flist1 flist2 stat1 stat2 bind-fonts.conf
|
2019-01-31 11:17:47 +01:00
|
|
|
|
2019-04-04 08:47:34 +02:00
|
|
|
dotest "Check consistency of MD5 in cache name"
|
|
|
|
prep
|
2020-04-10 10:27:15 +02:00
|
|
|
mkdir -p "$FONTDIR"/sub
|
|
|
|
cp "$FONT1" "$FONTDIR"/sub
|
|
|
|
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
|
2019-07-31 15:18:51 +02:00
|
|
|
fi
|
2020-04-10 10:27:15 +02:00
|
|
|
$FCCACHE "$FONTDIR"
|
2019-04-04 08:47:34 +02:00
|
|
|
sleep 1
|
2020-04-10 10:27:15 +02:00
|
|
|
(cd "$CACHEDIR"; ls -1 --color=no ./*cache*) > out1
|
2021-07-09 00:29:16 +02:00
|
|
|
TESTTMPDIR=$(mktemp -d "$TMPDIR"/fontconfig.XXXXXXXX)
|
2020-04-10 10:27:15 +02:00
|
|
|
mkdir -p "$TESTTMPDIR"/cache.dir
|
2022-09-28 16:30:06 +02:00
|
|
|
# Once font dir is remapped, we could use $FONTDIR as different one in theory.
|
|
|
|
# but we don't use it here and to avoid duplicate entries, set the non-existing
|
|
|
|
# directory here.
|
|
|
|
sed "s!@FONTDIR@!$FONTDIR/a!
|
2019-04-04 08:47:34 +02:00
|
|
|
s!@REMAPDIR@!<remap-dir as-path="'"'"$FONTDIR"'"'">$TESTTMPDIR/fonts</remap-dir>!
|
2020-04-10 10:27:15 +02:00
|
|
|
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
|
|
|
|
(cd "$TESTTMPDIR"/cache.dir; ls -1 --color=no ./*cache*) > out2
|
2019-04-04 08:47:34 +02:00
|
|
|
if cmp out1 out2 > /dev/null ; then : ; else
|
|
|
|
echo "*** Test failed: $TEST"
|
|
|
|
echo "cache was created unexpectedly."
|
|
|
|
echo "Before:"
|
|
|
|
cat out1
|
|
|
|
echo "After:"
|
|
|
|
cat out2
|
|
|
|
exit 1
|
2017-11-15 15:30:26 +01:00
|
|
|
fi
|
2020-04-10 10:27:15 +02:00
|
|
|
rm -rf "$TESTTMPDIR" out1 out2 bind-fonts.conf
|
2019-04-04 08:47:34 +02:00
|
|
|
|
2019-04-04 14:14:20 +02:00
|
|
|
dotest "Fallback to uuid"
|
|
|
|
prep
|
2020-04-10 10:27:15 +02:00
|
|
|
cp "$FONT1" "$FONTDIR"
|
|
|
|
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"
|
2019-07-31 15:18:51 +02:00
|
|
|
fi
|
2020-04-10 10:27:15 +02:00
|
|
|
touch -d @"$(stat -c %Y "$FONTDIR")" "$FONTDIR"
|
|
|
|
$FCCACHE "$FONTDIR"
|
2019-04-04 14:14:20 +02:00
|
|
|
sleep 1
|
2020-04-10 10:27:15 +02:00
|
|
|
_cache=$(ls -1 --color=no "$CACHEDIR"/*cache*)
|
|
|
|
_mtime=$(stat -c %Y "$FONTDIR")
|
|
|
|
_uuid=$(uuidgen)
|
|
|
|
_newcache=$(echo "$_cache" | sed "s/\([0-9a-f]*\)\(\-.*\)/$_uuid\2/")
|
|
|
|
mv "$_cache" "$_newcache"
|
|
|
|
echo "$_uuid" > "$FONTDIR"/.uuid
|
|
|
|
touch -d @"$_mtime" "$FONTDIR"
|
|
|
|
(cd "$CACHEDIR"; ls -1 --color=no ./*cache*) > out1
|
2021-07-09 00:29:16 +02:00
|
|
|
TESTTMPDIR=$(mktemp -d "$TMPDIR"/fontconfig.XXXXXXXX)
|
2020-04-10 10:27:15 +02:00
|
|
|
mkdir -p "$TESTTMPDIR"/cache.dir
|
2019-04-04 14:14:20 +02:00
|
|
|
sed "s!@FONTDIR@!$TESTTMPDIR/fonts!
|
|
|
|
s!@REMAPDIR@!<remap-dir as-path="'"'"$FONTDIR"'"'">$TESTTMPDIR/fonts</remap-dir>!
|
2020-04-10 10:27:15 +02:00
|
|
|
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 ""
|
|
|
|
(cd "$CACHEDIR"; ls -1 --color=no ./*cache*) > out2
|
2019-04-04 14:14:20 +02:00
|
|
|
if cmp out1 out2 > /dev/null ; then : ; else
|
|
|
|
echo "*** Test failed: $TEST"
|
|
|
|
echo "cache was created unexpectedly."
|
|
|
|
echo "Before:"
|
|
|
|
cat out1
|
|
|
|
echo "After:"
|
|
|
|
cat out2
|
|
|
|
exit 1
|
|
|
|
fi
|
2020-04-10 10:27:15 +02:00
|
|
|
rm -rf "$TESTTMPDIR" out1 out2 bind-fonts.conf
|
2019-04-04 14:14:20 +02:00
|
|
|
|
2019-04-04 08:47:34 +02:00
|
|
|
else
|
|
|
|
echo "No bubblewrap installed. skipping..."
|
|
|
|
fi # if [ x"$BWRAP" != "x" -a "x$EXEEXT" = "x" ]
|
2017-11-15 15:30:26 +01:00
|
|
|
|
2019-03-22 08:45:09 +01:00
|
|
|
if [ "x$EXEEXT" = "x" ]; then
|
2018-05-13 09:21:58 +02:00
|
|
|
dotest "sysroot option"
|
|
|
|
prep
|
2020-04-10 10:27:15 +02:00
|
|
|
mkdir -p "$MyPWD"/sysroot/"$FONTDIR"
|
|
|
|
mkdir -p "$MyPWD"/sysroot/"$CACHEDIR"
|
|
|
|
mkdir -p "$MyPWD"/sysroot/"$MyPWD"
|
|
|
|
cp "$FONT1" "$MyPWD"/sysroot/"$FONTDIR"
|
|
|
|
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"
|
2019-07-31 15:18:51 +02:00
|
|
|
fi
|
2020-04-10 10:27:15 +02:00
|
|
|
cp "$MyPWD"/fonts.conf "$MyPWD"/sysroot/"$MyPWD"/fonts.conf
|
|
|
|
$FCCACHE -y "$MyPWD"/sysroot
|
2018-05-13 09:21:58 +02:00
|
|
|
|
2018-10-30 00:25:13 +01:00
|
|
|
dotest "creating cache file on sysroot"
|
2020-04-10 10:27:15 +02:00
|
|
|
md5=$(printf "%s" "$FONTDIR" | md5sum | sed 's/ .*$//')
|
2018-10-30 00:25:13 +01:00
|
|
|
echo "checking for cache file $md5"
|
2020-04-10 10:27:15 +02:00
|
|
|
if ! ls "$MyPWD/sysroot/$CACHEDIR/$md5"*; then
|
2018-05-13 09:21:58 +02:00
|
|
|
echo "*** Test failed: $TEST"
|
2018-10-30 00:25:13 +01:00
|
|
|
echo "No cache for $FONTDIR ($md5)"
|
2020-04-10 10:27:15 +02:00
|
|
|
ls "$MyPWD"/sysroot/"$CACHEDIR"
|
2018-05-13 09:21:58 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2020-04-10 10:27:15 +02:00
|
|
|
rm -rf "$MyPWD"/sysroot
|
2018-05-13 09:21:58 +02:00
|
|
|
|
2019-10-28 09:11:38 +01:00
|
|
|
dotest "read newer caches when multiple places are allowed to store"
|
|
|
|
prep
|
2020-04-10 10:27:15 +02:00
|
|
|
cp "$FONT1" "$FONT2" "$FONTDIR"
|
|
|
|
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"
|
2019-10-28 09:11:38 +01:00
|
|
|
fi
|
2021-07-09 00:29:16 +02:00
|
|
|
MYCACHEBASEDIR=$(mktemp -d "$TMPDIR"/fontconfig.XXXXXXXX)
|
2020-04-10 10:27:15 +02:00
|
|
|
MYCACHEDIR="$MYCACHEBASEDIR"/cache.dir
|
|
|
|
MYOWNCACHEDIR="$MYCACHEBASEDIR"/owncache.dir
|
2021-07-09 00:29:16 +02:00
|
|
|
MYCONFIG=$(mktemp "$TMPDIR"/fontconfig.XXXXXXXX)
|
2019-10-28 09:11:38 +01:00
|
|
|
|
2020-04-10 10:27:15 +02:00
|
|
|
mkdir -p "$MYCACHEDIR"
|
|
|
|
mkdir -p "$MYOWNCACHEDIR"
|
2019-10-28 09:11:38 +01:00
|
|
|
|
|
|
|
sed "s!@FONTDIR@!$FONTDIR!
|
|
|
|
s!@REMAPDIR@!!
|
2020-04-10 10:27:15 +02:00
|
|
|
s!@CACHEDIR@!$MYCACHEDIR!" < "$TESTDIR"/fonts.conf.in > my-fonts.conf
|
2019-10-28 09:11:38 +01:00
|
|
|
|
2020-04-10 10:27:15 +02:00
|
|
|
FONTCONFIG_FILE="$MyPWD"/my-fonts.conf $FCCACHE "$FONTDIR"
|
2019-10-28 09:11:38 +01:00
|
|
|
|
|
|
|
sleep 1
|
2020-04-10 10:27:15 +02:00
|
|
|
cat<<EOF>"$MYCONFIG"
|
2019-10-28 09:11:38 +01:00
|
|
|
<fontconfig>
|
|
|
|
<match target="scan">
|
|
|
|
<test name="file"><string>$FONTDIR/4x6.pcf</string></test>
|
|
|
|
<edit name="pixelsize"><int>8</int></edit>
|
|
|
|
</match>
|
|
|
|
</fontconfig>
|
|
|
|
EOF
|
|
|
|
sed "s!@FONTDIR@!$FONTDIR!
|
|
|
|
s!@REMAPDIR@!<include ignore_missing=\"yes\">$MYCONFIG</include>!
|
2020-04-10 10:27:15 +02:00
|
|
|
s!@CACHEDIR@!$MYOWNCACHEDIR!" < "$TESTDIR"/fonts.conf.in > my-fonts.conf
|
2019-10-28 09:11:38 +01:00
|
|
|
|
2020-04-10 10:27:15 +02:00
|
|
|
if [ -n "${SOURCE_DATE_EPOCH:-}" ]; then
|
2019-10-28 09:11:38 +01:00
|
|
|
old_epoch=${SOURCE_DATE_EPOCH}
|
2020-04-10 10:27:15 +02:00
|
|
|
SOURCE_DATE_EPOCH=$(("$SOURCE_DATE_EPOCH" + 1))
|
2019-10-28 09:11:38 +01:00
|
|
|
fi
|
2020-04-10 10:27:15 +02:00
|
|
|
FONTCONFIG_FILE="$MyPWD"/my-fonts.conf $FCCACHE -f "$FONTDIR"
|
|
|
|
if [ -n "${SOURCE_DATE_EPOCH:-}" ]; then
|
2019-10-28 09:11:38 +01:00
|
|
|
SOURCE_DATE_EPOCH=${old_epoch}
|
|
|
|
fi
|
|
|
|
|
|
|
|
sed "s!@FONTDIR@!$FONTDIR!
|
|
|
|
s!@REMAPDIR@!<include ignore_missing=\"yes\">$MYCONFIG</include>!
|
2020-04-10 10:27:15 +02:00
|
|
|
s!@CACHEDIR@!$MYCACHEDIR</cachedir><cachedir>$MYOWNCACHEDIR!" < "$TESTDIR"/fonts.conf.in > my-fonts.conf
|
|
|
|
|
|
|
|
{
|
|
|
|
FONTCONFIG_FILE="$MyPWD"/my-fonts.conf $FCLIST - family pixelsize | sort;
|
|
|
|
echo "=";
|
|
|
|
FONTCONFIG_FILE="$MyPWD"/my-fonts.conf $FCLIST - family pixelsize | sort;
|
|
|
|
echo "=";
|
|
|
|
FONTCONFIG_FILE="$MyPWD"/my-fonts.conf $FCLIST - family pixelsize | sort;
|
|
|
|
} > my-out
|
2019-10-28 09:11:38 +01:00
|
|
|
tr -d '\015' <my-out >my-out.tmp; mv my-out.tmp my-out
|
2020-04-10 10:27:15 +02:00
|
|
|
sed -e 's/pixelsize=6/pixelsize=8/g' "$BUILDTESTDIR"/"$EXPECTED" > my-out.expected
|
2019-10-28 09:11:38 +01:00
|
|
|
|
|
|
|
if cmp my-out my-out.expected > /dev/null ; then : ; else
|
|
|
|
echo "*** Test failed: $TEST"
|
|
|
|
echo "*** output is in 'my-out', expected output in 'my-out.expected'"
|
|
|
|
echo "Actual Result"
|
|
|
|
cat my-out
|
|
|
|
echo "Expected Result"
|
|
|
|
cat my-out.expected
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2020-04-10 10:27:15 +02:00
|
|
|
rm -rf "$MYCACHEBASEDIR" "$MYCONFIG" my-fonts.conf my-out my-out.expected
|
2019-10-28 09:11:38 +01:00
|
|
|
|
2019-04-04 12:59:47 +02:00
|
|
|
fi # if [ "x$EXEEXT" = "x" ]
|
|
|
|
|
2020-04-10 10:27:15 +02:00
|
|
|
if [ -x "$BUILDTESTDIR"/test-crbug1004254 ]; then
|
2019-11-01 06:43:42 +01:00
|
|
|
dotest "MT-safe global config"
|
|
|
|
prep
|
2020-04-10 10:27:15 +02:00
|
|
|
curl -s -o "$FONTDIR"/noto.zip https://noto-website-2.storage.googleapis.com/pkgs/NotoSans-hinted.zip
|
|
|
|
(cd "$FONTDIR"; unzip noto.zip)
|
|
|
|
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"
|
2019-11-01 06:43:42 +01:00
|
|
|
fi
|
2020-04-10 10:27:15 +02:00
|
|
|
"$BUILDTESTDIR"/test-crbug1004254
|
2019-11-01 06:43:42 +01:00
|
|
|
else
|
|
|
|
echo "No test-crbug1004254: skipped"
|
|
|
|
fi
|
|
|
|
|
2020-07-14 12:24:36 +02:00
|
|
|
if [ "x$EXEEXT" = "x" ]; then
|
|
|
|
|
|
|
|
dotest "empty XDG_CACHE_HOME"
|
|
|
|
prep
|
|
|
|
export XDG_CACHE_HOME=""
|
|
|
|
export old_HOME="$HOME"
|
2021-07-09 00:29:16 +02:00
|
|
|
export temp_HOME=$(mktemp -d "$TMPDIR"/fontconfig.XXXXXXXX)
|
2020-07-14 12:24:36 +02:00
|
|
|
export HOME="$temp_HOME"
|
|
|
|
cp "$FONT1" "$FONT2" "$FONTDIR"
|
|
|
|
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"
|
|
|
|
fi
|
|
|
|
echo "<fontconfig><dir>$FONTDIR</dir><cachedir prefix=\"xdg\">fontconfig</cachedir></fontconfig>" > my-fonts.conf
|
|
|
|
FONTCONFIG_FILE="$MyPWD"/my-fonts.conf $FCCACHE "$FONTDIR" || :
|
|
|
|
if [ -d "$HOME"/.cache ] && [ -d "$HOME"/.cache/fontconfig ]; then : ; else
|
|
|
|
echo "*** Test failed: $TEST"
|
|
|
|
echo "No \$HOME/.cache/fontconfig directory"
|
|
|
|
ls -a "$HOME"
|
|
|
|
ls -a "$HOME"/.cache
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
export HOME="$old_HOME"
|
|
|
|
rm -rf "$temp_HOME" my-fonts.conf
|
|
|
|
unset XDG_CACHE_HOME
|
|
|
|
unset old_HOME
|
|
|
|
unset temp_HOME
|
|
|
|
|
|
|
|
fi # if [ "x$EXEEXT" = "x" ]
|
|
|
|
|
2020-04-10 10:27:15 +02:00
|
|
|
rm -rf "$FONTDIR" "$CACHEFILE" "$CACHEDIR" "$BASEDIR" "$FONTCONFIG_FILE" out
|
2020-08-25 05:49:30 +02:00
|
|
|
|
|
|
|
TEST=""
|