1# Copyright (c) 2011 The Chromium OS Authors. All rights reserved. 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5import utils 6from autotest_lib.client.bin import test 7from autotest_lib.client.common_lib import autotemp 8 9class desktopui_FontCache(test.test): 10 version = 1 11 _mounted = False 12 _new_cache = None 13 _FONTCACHE = "/usr/share/cache/fontconfig" 14 15 16 def _mount_cache(self): 17 utils.system("mount -n --bind %s %s" % (self._new_cache.name, 18 self._FONTCACHE)) 19 self._mounted = True 20 21 def _unmount_cache(self): 22 if self._mounted: 23 utils.system("umount -n %s" % self._FONTCACHE) 24 self._mounted = False 25 26 def cleanup(self): 27 self._unmount_cache() 28 if self._new_cache: 29 self._new_cache.clean() 30 31 32 def run_once(self): 33 self._new_cache = autotemp.tempdir(unique_id="new-font-cache") 34 # Generate a new cache and compare it to the existing cache. Ideally, we 35 # would simply point fc-cache to a new cache location, however, that 36 # doesn't seem possible. So, just bind mount the existing cache location 37 # out of rootfs temporarily. 38 self._mount_cache() 39 utils.system("fc-cache -fv") 40 self._unmount_cache() 41 utils.system("diff -qr %s %s" % (self._FONTCACHE, self._new_cache.name)) 42