Commit Graph

111 Commits

Author SHA1 Message Date
Akira TAGOH bd95bafba0 Add some missing constant names for weight.
Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/-/issues/348
2023-01-25 23:38:40 +09:00
Akira TAGOH dac7f285c5 Add back sort command
Oops
2022-09-29 00:04:00 +09:00
Akira TAGOH a10d07682a Fix test cases for wrong use of remap-dir 2022-09-28 23:30:06 +09:00
Akira TAGOH 8a150f634f Add test/wrapper-script.sh to the archive
Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/-/issues/307
2022-01-28 18:13:21 +09:00
Ben Wagner 6e414d61c7 Extend test thread args lifetime
The argument passed to each thread in test-pthread.c indicates a thread
number to report when finished. This value is read out by the thread
into a local variable early in the thread's execution. Currently, the
address passed as this argument is the address of a loop local. However,
it is possible that the created thread will not be scheduled to run or
will not read the argument before the thread creation loop finishes and
the local is destroyed. This can lead to odd behavior, usually observed
as multiple threads reporting the same thread_num.

Fix this issue by storing the thread arguments in a parallel array to
the array of threads. This ensures that the thread arguments are in
scope as long as the threads themselves.

Discovered with tests/test-pthread with AddressSanitizer enabled.
2021-09-06 04:06:16 +00:00
Ryan Schmidt 8b3de9bd7f Fix run-test.sh to work with BSD mktemp
Avoid the GNU-specific --tmpdir flag to mkdir and always prefer to use
the directory specified in TMPDIR rather than /tmp.

See https://gitlab.freedesktop.org/fontconfig/fontconfig/-/issues/288
2021-07-14 04:34:15 +00:00
Akira TAGOH 4d43f84188 Do not set different score to non-string values
Non-string values in a cache is supposed to choose one from them.
Due to the change of da1c9f7a, there was a regression on scoring for
matching functions.  So reverting the behavior for evaluating non-string
values to the previous one.

Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/-/issues/286
2021-07-08 14:47:36 +09:00
Akira TAGOH da1c9f7a6c Fix score evaluation for multiple values in properties
Sometimes fonts has multiple values in family and sub-family in order to unify
other variants into one. they basically make difference in sub-family though,
they also still have standalone family and sub-family. in that case, sub-family is
likely to be Regular.

fontconfig couldn't recognize the difference between :family=Foo:style=Regular
and :family=Foo Caption:style=Regular for example because fontconfig didn't
give different score on matching result for the position of multiple values in
a cache.
Thus, when querying a font like :family=Foo:style=Regular may results
:family=Foo Caption:style=Regular. (see the test case for more details)

To fix this situation, giving different score according to the position
of multiple values in a cache as well as the position of multiple values
in a query.

Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/-/issues/283
2021-06-28 08:51:58 +00:00
Ben Wagner ba15d41bdc Fix stack use after scope in FcConfigCompareValue
Discovered by AddressSanitizer. When left_o and right_o are promoted the
promoted values are placed on the stack in FcValuePromotionBuffer.
The FcValuePromotionBuffers must then continue to be in scope while
left_o and right_o point into their content. In 9d4e5d0f the
FcValuePromotionBuffers were moved into the incorrect scope, leaving
left_o and right_o pointing into an object whose lifetime has ended.
This is similar to left and right which appear to have a smaller scope
but are actually required to be in the larger scope.

Correct this by moving the FcValuePromotionBuffers to the proper scope.
Leave the left and right FcValues where they are since they are in the
correct scope already.

This also adds to test-conf the ability to create charset, langset,
range, and matrix in patterns. This allows for a simple test which fails
under AddressSanitizer before this change and passes after.
2021-02-16 11:30:32 -05:00
Ben Wagner bd7123ac41 Clean up test-family-matching test.
Correct the type of TestMatchPattern's 'ret' from TestResult to
TestMatchResult to match the actual return type (and values assigned to
it).

Fix leak of TestMatchPattern's 'xml' and TestFamily's 'pat'.

Simplify TestMatchPattern cleanup and ensure cleanup always happens.
2021-01-07 07:03:42 +00:00
Ben Wagner b1e1a87512 Test all not_eq for family names.
Any early out checks must give the same answer as FcConfigCompareValue.
An accelerator was added for family names which treated all ops as if
they were FcOpEqual, giving the wrong answer for other non-equivalent ops
(for example FcOpContains or FcOpNotEqual).

This adds a test which passes before the accelerator was introduced,
fails after, and will pass again after !142 lands. This tests the all
not_eq case.
2020-12-28 11:01:38 -05:00
Szunti df29933e1a Check qual and compare for family tests
Fixes #267. Hash table lookups assumed qual="any" compare="eq".
Add a test too.
2020-12-17 04:51:20 +00:00
Ben Wagner 921ede9f46 Fix test-conf string to integer conversion.
The test-conf build_pattern attempted to convert known constant strings
into integer values. However, it did so by always converting the string
value to an integer if possible and then complaining if the key wasn't
of the expected type. This lead to error messages on "style": "Regular"
since "Regular" was recognized as "weight".

Instead, only attempt conversion from string to integer if the key is
the name of an object which can take an integer type. This eliminates
the spurious non-fatal errors reported when parsing
test-90-synthetic.json.

This also fixes an issue where the created value was given the type of
the object found, but the integer field was assigned. Instead, check
that the object type can take an integer and always set the value type
to integer.
2020-12-16 10:16:40 -05:00
Ben Wagner b35c72dbc7 Always run-test-conf, but skip if not built.
The test-conf test requires libjson-c to be available in order to be
built. However, there has been no user indication that additional tests
could be built if the json-c development files were available.

Continue to not build test-conf if json-c is not available, but do run
the test harness. The test harness is updated to SKIP the test if the
test-conf binary is unavailable.
2020-12-15 19:44:48 -05:00
Ben Wagner 5cd11d19df Fix wild frees and leak of fs in test-conf.
Reported by AddressSanitizer when running test-conf. The `query`,
`result`, and `result_fs` were not initialized to NULL so could result
in a wild free when first initialized.

The `method` was also not initialized to NULL so comparisons could be
made against random data if it had not yet been assigned.

The outer `fs` was never destroyed, but is also not used, so remove.
2020-12-14 12:34:21 -05:00
Ben Wagner d55eaa6b31 Fix leaks in fcxml.c, fc-match.c, and tests.
Fix leaks reported by AddressSanitizer when running 'make check'.
2020-12-14 10:54:11 +00:00
Ben Wagner c00a51f4c8 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 14:00:40 -05:00
Szunti ac3c9ba95d Fix locale dependent behaviour in run-test.sh
'stat ... | grep Modify' fails on non english locales. stat -c '%y'
used in most of the places, but one exception remained.
2020-12-08 14:26:25 +01:00
Niklas Guertler 31edc2880e Increased timeout for meson tests to 600sec to make tests work on Darwin 2020-11-28 01:16:36 +00:00
Akira TAGOH 3ae08a8601 Make more clearer the license terms
COPYING is missing non-expat license terms for some files and some files is also missing license terms. This is changes to makes it clearer and update.

Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/-/issues/219
2020-09-03 06:25:30 +00:00
Akira TAGOH abbd87ac2c Add some tweaks into runtest.sh to see progress 2020-08-25 12:50:27 +09:00
Tim-Philipp Müller 57a224f51d Add Meson build system
See https://mesonbuild.com
2020-07-31 07:26:11 +00:00
Akira TAGOH 437f03299b Fix empty XDG_CACHE_HOME Behavior
Use the default $HOME/.cache one for empty XDG_CACHE_HOME.

Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/-/issues/243
2020-07-14 19:48:11 +09:00
Tim-Philipp Müller a30e4db967 fccompat: fix build on Windows without unistd.h
https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/access-waccess?view=vs-2019
2020-07-07 03:48:34 +00:00
Akira TAGOH f3e049967e Fix errors on shellcheck
Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/-/issues/235
2020-04-10 17:27:15 +09:00
Akira TAGOH 8bddcb1137 Fix a test fail when no bwrap was available
Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/issues/201
2019-12-05 19:55:06 +09:00
Akira TAGOH 23ab038281 Fix gcc warnings with -Wpointer-sign
Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/issues/184
2019-11-06 20:28:58 +09:00
Akira TAGOH b5bcf61fe7 Use FcConfigReference/Destroy appropriately instead of FcConfigGetCurrent
This may improves to be MT-safe.

Reported at https://bugs.chromium.org/p/chromium/issues/detail?id=1004254
2019-11-01 14:44:47 +09:00
Akira TAGOH c9862b6ea7 Read latest cache in paths
Right now fontconfig uses a cache found first in a path and
cachedirs are the order of the system-wide path and then the user path.
this is due to avoid writing caches into the user path when running as root.

However, changing caches by certain config only, e.g. using <match target="scan">
may not take effect by this behavior, because it may be stored into the user path.

Thus, needing to find the latest cache out from paths.

Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/issues/182
2019-10-28 17:15:07 +09:00
Akira TAGOH 75eadca266 Warn as well if no directory name for cachedir provided
cachedir is used to determine where cache files are stored.
the empty directory will ends up to put them under the top of
directory of XDG_CACHE_HOME. that messes it up and must be avoided.

As a note, if you want to read/write something from the top of
XDG_DATA_HOME (dir) and/or XDG_CACHE_HOME (cachedir),
put "." instead of the empty.

https://gitlab.freedesktop.org/fontconfig/fontconfig/issues/180
2019-10-08 20:12:12 +09:00
Akira TAGOH fcada52291 Do not return FcFalse from FcConfigParseAndLoad*() if complain is set to false
https://bugzilla.redhat.com/show_bug.cgi?id=1744377
2019-08-28 17:48:29 +09:00
Akira TAGOH 01e4f088bf Fix the fails of make check when SOURCE_DATE_EPOCH is set
Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/issues/172
2019-07-31 13:18:51 +00:00
Akira TAGOH e261e31731 Clean up temporary directory for tests 2019-07-23 04:18:59 +00:00
Jon Turney fd2e155665
Only use test wrapper-script if host is MinGW
Currently it fails if the executable extension is .exe, but wine isn't
available (e.g. on Cygwin)

Possibly the check to use this wrapper should be even more restrictive
e.g. checking if cross-building and/or if wine is available.
2019-04-15 20:42:48 +01:00
Akira TAGOH faa11fb642 Update the test case that is looking for uuid based on host 2019-04-04 12:14:20 +00:00
Akira TAGOH 7f61838435 Fallback uuid-based name to read a cache if no MD5-based cache available 2019-04-04 10:59:47 +00:00
Akira TAGOH 13d2a47d79 Fix unexpected cache name by double-slash in path 2019-04-04 06:47:34 +00:00
Akira TAGOH 34791c32f1 Don't share fonts and cache dir for testing
There seems a race condition on CI. so create an unique directory to avoid colision.
2019-04-03 12:02:09 +00:00
Akira TAGOH 9177cf2c38 Add back if !OS_WIN32 line 2019-04-03 12:02:09 +00:00
Akira TAGOH a39f30738d trivial testcase update 2019-04-03 12:02:09 +00:00
Akira TAGOH 2e8ce63514 Add salt attribute to dir and remap-dir elements
'salt' attribute affects a cache filename to generate different name from directory name.
This is useful when sharing caches with host on sandbox and/or give a filename differently:

    <dir salt="randomdata">/usr/share/fonts</dir>
    <remap-dir as-path="/usr/share/fonts" salt="salt for /usr/share/fonts on host">/run/host/fonts</remap-dir>

Applications can read caches as-is for fonts on /run/host/fonts where is mounted from host.
and write a cache for their own fonts on /usr/share/fonts with different name.
2019-04-03 12:02:09 +00:00
Akira TAGOH 916cf6caa3 Update testcase 2019-04-03 12:02:09 +00:00
Akira TAGOH 9d3fb5b385 Fix make check fail on run-test-conf.sh 2019-04-03 12:02:09 +00:00
Keith Packard c4324f54ee Replace UUID file mechanism with per-directory 'map' attribute [v2]
The UUID files would be placed in each font directory to provide the
unique cache name, independent of path, for that directory. The UUID
files are undesireable for a couple of reasons:

 1) They must be placed in the font directories to be useful. This
    requires modifying the font directories themselves, introducing
    potential visible timestamp changes when running multiple
    applications, and makes the cache processing inconsistent between
    applications with permission to write to the font directories and
    applications without such permission.

 2) The UUID contents were generated randomly, which makes the font
    cache not reproducible across multiple runs.

One proposed fix for 2) is to make the UUID dependent on the font
directory path, but once we do that, we can simply use the font
directory path itself as the key as the original MD5-based font cache
naming mechanism did.

The goal of the UUID file mechanism was to fix startup time of
flatpaks; as the font path names inside the flatpak did not match the
font path names in the base system, the font cache would need to be
reconstructed the first time the flatpak was launched.

The new mechanism for doing this is to allow each '<dir>' element in
the configuration include a 'map' attribute. When looking for a cache
file for a particular directory, if the directory name starts with the
contents of the <dir> element, that portion of the name will be
replaced with the value of the 'map' attribute.

Outside of the flatpak, nothing need change -- fontconfig will build
cache files using real directory names.

Inside the flatpak, the custom fonts.conf file will now include
mappings such as this:

	<dir map="/usr/share/fonts">/run/host/fonts</dir>

When scanning the directory /run/host/fonts/ttf, fontconfig will
use the name /usr/share/fonts/ttf as the source for building the cache
file name.

The existing FC_FILE replacement code used for the UUID-based
implementation continues to correctly adapt font path names seen by
applications.

v2:
	Leave FcDirCacheCreateUUID stub around to avoid removing
	public API function.

	Document 'map' attribute of <dir> element in
	fontconfig-user.sgml

	Suggested-by: Akira TAGOH <akira@tagoh.org>

Signed-off-by: Keith Packard <keithp@keithp.com>
2019-04-03 12:02:09 +00:00
Keith Packard 4cde12bfda Remove UUID-related tests
Remove test-hash
Remove UUID tests from run-test.sh

Signed-off-by: Keith Packard <keithp@keithp.com>
2019-04-03 12:02:09 +00:00
Keith Packard a8c4fc5e1f Add delays to test-bz106632, check UptoDate separately
On a file system with one-second time stamps, extra delays are needed
between cache modification operations to ensure that fontconfig isn't
fooled.

And, when the timestamps are checked correctly, we need to make sure
that FcConfigUptoDate returns false whenever we change a font
directory, so separate that out from the call to reinitialize the core
config.

Signed-off-by: Keith Packard <keithp@keithp.com>
2019-04-03 12:02:09 +00:00
Keith Packard 2a81aa51f0 Remove '-u' option from run-test-conf.sh
This causes a failure when evaluating $OSTYPE on systems which do not
set that variable (everything but Msys/MinGW)

Signed-off-by: Keith Packard <keithp@keithp.com>
2019-04-03 12:02:09 +00:00
Akira TAGOH 809f040bc3 Don't test bind-mount thing for MinGW 2019-03-23 07:19:08 +00:00
Akira TAGOH 92caab9c76 Fix make distcheck error 2019-03-23 06:27:39 +00:00
Akira TAGOH f6810ede60 Fix make check on cross-compiled env 2019-03-22 16:51:38 +09:00