Boot an image carrying a font and have fontconfig report the caches it checks: every one must match its directory, and nothing may be written, neither to the system cache nor to a per-user one.
AI-Generated: Claude Opus 5.5 (Claude Code) Signed-off-by: Alex Kiernan <[email protected]> --- meta/lib/oeqa/selftest/cases/fontcache.py | 42 +++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/meta/lib/oeqa/selftest/cases/fontcache.py b/meta/lib/oeqa/selftest/cases/fontcache.py new file mode 100644 index 000000000000..df88a229aab2 --- /dev/null +++ b/meta/lib/oeqa/selftest/cases/fontcache.py @@ -0,0 +1,42 @@ +# +# Copyright OpenEmbedded Contributors +# +# SPDX-License-Identifier: MIT +# + +import re + +from oeqa.selftest.case import OESelftestTestCase +from oeqa.core.decorator import OETestTag +from oeqa.utils.commands import bitbake, runqemu + +class FontCache(OESelftestTestCase): + + @OETestTag("runqemu") + def test_image_font_cache_is_valid(self): + """ + Summary: Check the fontconfig caches built into an image are used + Expected: fontconfig accepts the cache of every font directory and + writes no cache of its own, system or per-user + Product: oe-core + """ + features = 'EXTRA_IMAGE_FEATURES = "empty-root-password allow-empty-password allow-root-login"\n' + features += 'IMAGE_INSTALL:append = " ttf-bitstream-vera"\n' + self.write_config(features) + bitbake('core-image-minimal') + + with runqemu('core-image-minimal') as qemu: + # FC_DEBUG=16 reports each cache fontconfig checks and each one it + # writes. An empty HOME catches a per-user cache, which fontconfig + # writes whenever it cannot use the system one. + status, output = qemu.run_serial( + 'H=$(mktemp -d); HOME=$H XDG_CACHE_HOME=$H FC_DEBUG=16 fc-match sans-serif; echo "user cache: [$(ls -A $H)]"') + self.assertEqual(status, 1, msg=output) + + checks = re.findall(r'FcCacheTimeValid dir "([^"]+)" cache checksum (\d+) dir checksum (\d+)', output) + self.assertTrue(checks, msg="fontconfig checked no cache:\n" + output) + for directory, cache, mtime in checks: + self.assertEqual(cache, mtime, msg="%s: the cache records mtime %s, the directory has %s\n%s" % (directory, cache, mtime, output)) + + self.assertNotIn('FcDirCacheWriteDir', output, msg="fontconfig rewrote a cache:\n" + output) + self.assertIn('user cache: []', output, msg="fontconfig wrote a per-user cache:\n" + output) -- 2.43.0
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#247720): https://lists.openembedded.org/g/openembedded-core/message/247720 Mute This Topic: https://lists.openembedded.org/mt/121730207/21656 Group Owner: [email protected] Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
