fontconfig: Branch 'main' - 2 commits

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



 src/fccfg.c                      |    7 --
 src/fcint.h                      |    1 
 test/run-test.d/functions        |   55 ++++++++++++++++++++
 test/run-test.d/remap-flatpak.sh |  104 +++++++++++++++++++++++++++++++++++++++
 test/test-conf.c                 |    1 
 5 files changed, 159 insertions(+), 9 deletions(-)

New commits:
commit b0a5af1bd2ec8cffd718b437751b7a845c38eee9
Author: Akira TAGOH <akira@xxxxxxxxx>
Date:   Mon Mar 6 17:01:38 2023 +0900

    Add another test case for flatpak

diff --git a/test/run-test.d/functions b/test/run-test.d/functions
new file mode 100644
index 0000000..38e3db9
--- /dev/null
+++ b/test/run-test.d/functions
@@ -0,0 +1,55 @@
+#! /bin/sh
+# -*- sh -*-
+# Copyright (C) 2023 fontconfig Authors
+# SPDX-License-Identifier: MIT
+
+set -e
+
+: "${TMPDIR=/tmp}"
+
+case "$OSTYPE" in
+    msys ) MyPWD=$(pwd -W) ;;  # On Msys/MinGW, returns a MS Windows style path.
+    *    ) MyPWD=$(pwd)    ;;  # On any other platforms, returns a Unix style path.
+esac
+
+TESTDIR=${srcdir-"$MyPWD"}
+BUILDTESTDIR=${builddir-"$MyPWD"}
+
+BASEDIR=$(mktemp -d "$TMPDIR"/fontconfig.XXXXXXXX)
+FONTDIR="$BASEDIR"/fonts
+CACHEDIR="$BASEDIR"/cache.dir
+EXPECTED=${EXPECTED-"out.expected"}
+
+FCLIST="$LOG_COMPILER ../../fc-list/fc-list$EXEEXT"
+FCCACHE="$LOG_COMPILER ../../fc-cache/fc-cache$EXEEXT"
+FCMATCH="$LOG_COMPILER ../../fc-match/fc-match$EXEEXT"
+
+if [ -x "$(command -v bwrap)" ]; then
+    BWRAP="$(command -v bwrap)"
+fi
+
+FONT1=$TESTDIR/../4x6.pcf
+FONT2=$TESTDIR/../8x16.pcf
+TEST=""
+
+clean_exit() {
+    rc=$?
+    trap - INT TERM ABRT EXIT
+    if [ "x$TEST" != "x" ]; then
+        echo "Aborting from '$TEST' with the exit code $rc"
+    fi
+    rm -rf $BASEDIR
+    exit $rc
+}
+trap clean_exit INT TERM ABRT EXIT
+
+prep() {
+    rm -rf "$CACHEDIR"
+    rm -rf "$FONTDIR"
+    mkdir "$FONTDIR"
+}
+
+dotest () {
+    TEST=$1
+    test x"$VERBOSE" = x || echo "Running: $TEST"
+}
diff --git a/test/run-test.d/remap-flatpak.sh b/test/run-test.d/remap-flatpak.sh
new file mode 100644
index 0000000..36d31bd
--- /dev/null
+++ b/test/run-test.d/remap-flatpak.sh
@@ -0,0 +1,104 @@
+#! /bin/sh
+# -*- sh -*-
+# Copyright (C) 2023 fontconfig Authors
+# SPDX-License-Identifier: MIT
+
+. $(dirname $0)/functions
+
+dotest "Remap - same family name but different filename"
+prep
+
+TESTRESULT1=$(mktemp "$TMPDIR"/fontconfig.XXXXXXXX)
+TESTRESULT2=$(mktemp "$TMPDIR"/fontconfig.XXXXXXXX)
+TESTRESULT3=$(mktemp "$TMPDIR"/fontconfig.XXXXXXXX)
+TESTFONT1DIR=$(mktemp -d "$TMPDIR"/fontconfig.XXXXXXXX)
+TESTFONT2DIR=$(mktemp -d "$TMPDIR"/fontconfig.XXXXXXXX)
+TESTCACHE1DIR=$(mktemp -d "$TMPDIR"/fontconfig.XXXXXXXX)
+TESTCACHE2DIR=$(mktemp -d "$TMPDIR"/fontconfig.XXXXXXXX)
+TESTBUILD1DIR=$(mktemp -d "$TMPDIR"/fontconfig.XXXXXXXX)
+TESTBUILD2DIR=$(mktemp -d "$TMPDIR"/fontconfig.XXXXXXXX)
+TESTRUNDIR=$(mktemp -d "$TMPDIR"/fontconfig.XXXXXXXX)
+mkdir -p "$TESTBUILD1DIR"/build
+mkdir -p "$TESTBUILD2DIR"/build
+mkdir -p "$TESTRUNDIR"/fonts
+mkdir -p "$TESTRUNDIR"/fonts-cache
+cp "$FONT1" "$TESTFONT1DIR"/foo.pcf
+cp "$FONT1" "$TESTFONT2DIR"/bar.pcf
+touch -m -t $(date -d @0 +%y%m%d%H%M.%S) "$TESTFONT1DIR"
+touch -m -t $(date -d @0 +%y%m%d%H%M.%S) "$TESTFONT1DIR"/*
+touch -m -t $(date -d @0 +%y%m%d%H%M.%S) "$TESTFONT2DIR"
+touch -m -t $(date -d @0 +%y%m%d%H%M.%S) "$TESTFONT2DIR"/*
+
+cat<<_EOF_>>"$TESTBUILD1DIR"/fonts.conf
+<fontconfig>
+  <dir>/usr/share/fonts</dir>
+  <cachedir>/usr/lib/fontconfig/cache</cachedir>
+</fontconfig>
+_EOF_
+cat<<_EOF_>>"$TESTBUILD2DIR"/fonts.conf
+<fontconfig>
+  <dir salt="flatpak">/usr/share/fonts</dir>
+  <cachedir>/usr/lib/fontconfig/cache</cachedir>
+</fontconfig>
+_EOF_
+cat<<_EOF_>>"$TESTBUILD2DIR"/bind-fonts.conf
+<fontconfig>
+<dir salt="flatpak">/usr/share/fonts</dir>
+<dir>$TESTRUNDIR/fonts</dir>
+<cachedir>/usr/lib/fontconfig/cache</cachedir>
+<cachedir>$TESTRUNDIR/fonts-cache</cachedir>
+
+<remap-dir as-path="/usr/share/fonts">$TESTRUNDIR/fonts</remap-dir>
+</fontconfig>
+_EOF_
+
+# Generate host caches
+$BWRAP --bind / / --bind "$TESTCACHE1DIR" /usr/lib/fontconfig/cache --bind "$TESTFONT1DIR" /usr/share/fonts --bind "$TESTBUILD1DIR" /usr/share/fontconfig --dev-bind /dev /dev --setenv FONTCONFIG_FILE "$TESTBUILD1DIR"/fonts.conf $FCCACHE
+touch -m -t $(date -d @0 +%y%m%d%H%M.%S) "$TESTCACHE1DIR"
+touch -m -t $(date -d @0 +%y%m%d%H%M.%S) "$TESTCACHE1DIR"/*
+$BWRAP --bind / / --bind "$TESTCACHE1DIR" /usr/lib/fontconfig/cache --bind "$TESTFONT1DIR" /usr/share/fonts --bind "$TESTBUILD1DIR" /usr/share/fontconfig --dev-bind /dev /dev --setenv FONTCONFIG_FILE "$TESTBUILD1DIR"/fonts.conf $FCMATCH Fixed file > "$TESTRESULT1"
+
+if grep foo.pcf "$TESTRESULT1" > /dev/null; then : ; else
+    echo "*** Test failed: $TEST"
+    echo "file property doesn't point to the expected file."
+    cat "$TESTRESULT1"
+    exit 1
+fi
+
+# Generate runtime caches
+$BWRAP --bind / / --bind "$TESTCACHE2DIR" /usr/lib/fontconfig/cache --bind "$TESTFONT2DIR" /usr/share/fonts --bind "$TESTBUILD2DIR" /usr/share/fontconfig --dev-bind /dev /dev --setenv FONTCONFIG_FILE "$TESTBUILD2DIR"/fonts.conf $FCCACHE
+touch -m -t $(date -d @0 +%y%m%d%H%M.%S) "$TESTCACHE2DIR"
+touch -m -t $(date -d @0 +%y%m%d%H%M.%S) "$TESTCACHE2DIR"/*
+$BWRAP --bind / / --bind "$TESTCACHE2DIR" /usr/lib/fontconfig/cache --bind "$TESTFONT2DIR" /usr/share/fonts --bind "$TESTBUILD2DIR" /usr/share/fontconfig --dev-bind /dev /dev --setenv FONTCONFIG_FILE "$TESTBUILD2DIR"/fonts.conf $FCMATCH Fixed file > "$TESTRESULT2"
+
+if grep bar.pcf "$TESTRESULT2" > /dev/null; then : ; else
+    echo "*** Test failed: $TEST"
+    echo "file property doesn't point to the expected file."
+    cat "$TESTRESULT2"
+    exit 1
+fi
+
+# Ask for fonts on similar environemnt to flatpak
+$BWRAP --bind / / --ro-bind "$TESTCACHE2DIR" /usr/lib/fontconfig/cache --ro-bind "$TESTFONT2DIR" /usr/share/fonts --bind "$TESTBUILD2DIR" /usr/share/fontconfig --ro-bind "$TESTRUNDIR" "$TESTRUNDIR" --ro-bind "$TESTCACHE1DIR" "$TESTRUNDIR"/fonts-cache --ro-bind "$TESTFONT1DIR" "$TESTRUNDIR"/fonts --dev-bind /dev /dev --setenv FONTCONFIG_FILE "$TESTBUILD2DIR"/bind-fonts.conf $FCMATCH Fixed file > "$TESTRESULT3"
+$BWRAP --bind / / --ro-bind "$TESTCACHE2DIR" /usr/lib/fontconfig/cache --ro-bind "$TESTFONT2DIR" /usr/share/fonts --bind "$TESTBUILD2DIR" /usr/share/fontconfig --ro-bind "$TESTRUNDIR" "$TESTRUNDIR" --ro-bind "$TESTCACHE1DIR" "$TESTRUNDIR"/fonts-cache --ro-bind "$TESTFONT1DIR" "$TESTRUNDIR"/fonts --dev-bind /dev /dev --setenv FONTCONFIG_FILE "$TESTBUILD2DIR"/bind-fonts.conf ls $(sed 's/:file=//' "$TESTRESULT3") > /dev/null
+
+# Check the amount of cache files
+if [ $(ls "$TESTCACHE1DIR"|wc -l) == 2 ]; then : ; else
+    echo "*** Test failed: $TEST"
+    echo "Too much cache files created at host cache dir."
+    ls "$TESTCACHE1DIR"
+    exit 1
+fi
+if [ $(ls "$TESTCACHE2DIR"|wc -l) == 2 ]; then : ; else
+    echo "*** Test failed: $TEST"
+    echo "Too much cache files created at runtime cache dir."
+    ls "$TESTCACHE2DIR"
+    exit 1
+fi
+
+rm -rf "$TESTFONT1DIR" "$TESTFONT2DIR" "$TESTCACHE1DIR" "$TESTCACHE2DIR" "$TESTBUILD1DIR" "$TESTBUILD2DIR"
+rm -f "$TESTRESULT1" "$TESTRESULT2"
+
+TEST=""
+
+echo "Success."
commit 860b9997ef6be88bde2071a0307601230fabccbb
Author: Akira TAGOH <akira@xxxxxxxxx>
Date:   Mon Mar 6 15:34:58 2023 +0900

    Clean up unused code

diff --git a/src/fccfg.c b/src/fccfg.c
index f62e228..655bb99 100644
--- a/src/fccfg.c
+++ b/src/fccfg.c
@@ -147,10 +147,6 @@ FcConfigCreate (void)
     if (!config->configDirs)
 	goto bail1;
 
-    config->configMapDirs = FcStrSetCreate();
-    if (!config->configMapDirs)
-	goto bail1_5;
-
     config->configFiles = FcStrSetCreate ();
     if (!config->configFiles)
 	goto bail2;
@@ -230,8 +226,6 @@ bail4:
 bail3:
     FcStrSetDestroy (config->configFiles);
 bail2:
-    FcStrSetDestroy (config->configMapDirs);
-bail1_5:
     FcStrSetDestroy (config->configDirs);
 bail1:
     free (config);
@@ -370,7 +364,6 @@ FcConfigDestroy (FcConfig *config)
 	(void) fc_atomic_ptr_cmpexch (&_fcConfig, config, NULL);
 
 	FcStrSetDestroy (config->configDirs);
-	FcStrSetDestroy (config->configMapDirs);
 	FcStrSetDestroy (config->fontDirs);
 	FcStrSetDestroy (config->cacheDirs);
 	FcStrSetDestroy (config->configFiles);
diff --git a/src/fcint.h b/src/fcint.h
index 0c5f5e7..fbf0e81 100644
--- a/src/fcint.h
+++ b/src/fcint.h
@@ -524,7 +524,6 @@ struct _FcConfig {
      * and those directives may occur in any order
      */
     FcStrSet	*configDirs;	    /* directories to scan for fonts */
-    FcStrSet	*configMapDirs;	    /* mapped names to generate cache entries */
     /*
      * List of directories containing fonts,
      * built by recursively scanning the set
diff --git a/test/test-conf.c b/test/test-conf.c
index 1a52c6e..235dce5 100644
--- a/test/test-conf.c
+++ b/test/test-conf.c
@@ -29,7 +29,6 @@
 
 struct _FcConfig {
     FcStrSet	*configDirs;	    /* directories to scan for fonts */
-    FcStrSet    *configMapDirs;
     FcStrSet	*fontDirs;
     FcStrSet	*cacheDirs;
     FcStrSet	*configFiles;	    /* config files loaded */



[Index of Archives]     [Fedora Fonts]     [Fedora Users]     [Fedora Cloud]     [Kernel]     [Fedora Packaging]     [Fedora Desktop]     [PAM]     [Gimp Graphics Editor]     [Yosemite News]

  Powered by Linux